diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/Constants.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/Constants.java new file mode 100644 index 0000000000000000000000000000000000000000..09ec8935ee1f5a7b8ecb99a9878c7cc5829d9400 --- /dev/null +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/Constants.java @@ -0,0 +1,30 @@ +/* + * Copyright 2010 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.etlserver; + +/** + * + * + * @author Izabela Adamczyk + */ +public class Constants +{ + + public static final String ERROR_MARKER_FILE = "_delete_me_after_correcting_errors"; + public static final String USER_LOG_FILE = "error-log.txt"; + +} diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/SampleRegisteringDropbox.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/SampleRegisteringDropbox.java new file mode 100644 index 0000000000000000000000000000000000000000..9f5eadb43f88064b8ecc6cd4f5b137dce53f264b --- /dev/null +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/SampleRegisteringDropbox.java @@ -0,0 +1,224 @@ +/* + * Copyright 2010 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.etlserver; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; + +import org.apache.commons.io.FileUtils; +import org.apache.log4j.Logger; + +import ch.systemsx.cisd.common.filesystem.FileOperations; +import ch.systemsx.cisd.common.logging.LogCategory; +import ch.systemsx.cisd.common.logging.LogFactory; +import ch.systemsx.cisd.common.utilities.ExtendedProperties; +import ch.systemsx.cisd.common.utilities.PropertyUtils; +import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService; +import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetInformation; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchOperationKind; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; +import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.DatabaseInstanceIdentifier; +import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SpaceIdentifier; +import ch.systemsx.cisd.openbis.generic.shared.parser.GlobalProperties; +import ch.systemsx.cisd.openbis.generic.shared.parser.GlobalPropertiesLoader; +import ch.systemsx.cisd.openbis.generic.shared.parser.NamedInputStream; +import ch.systemsx.cisd.openbis.generic.shared.parser.SampleUploadSectionsParser; +import ch.systemsx.cisd.openbis.generic.shared.parser.SampleUploadSectionsParser.BatchSamplesOperation; +import ch.systemsx.cisd.openbis.generic.shared.parser.SampleUploadSectionsParser.SampleCodeGenerator; + +/** + * Registers samples from provided file. No data sets are created. + * + * @author Izabela Adamczyk + */ +public class SampleRegisteringDropbox implements IDataSetHandler +// WORKAROUND: {@link IDataSetHandler} has been used because it's the +// fastest way to implement required feature (sample batch registration via dropbox). It would +// be better to be able to configure a special dropbox directly in openBIS. +{ + + private static final String USER_KEY = "USER"; + + private static final String DEFAULT_SPACE_KEY = "DEFAULT_SPACE"; + + private static final String SAMPLE_TYPE_KEY = "SAMPLE_TYPE"; + + private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION, + SampleRegisteringDropbox.class); + + private final IEncapsulatedOpenBISService service; + + private String logDir; + + private String samplePrefix; + + public SampleRegisteringDropbox(Properties parentProperties, IDataSetHandler delegator, + IEncapsulatedOpenBISService service) + { + this.service = service; + Properties specificProperties = getSpecificProperties(parentProperties); + logDir = PropertyUtils.getMandatoryProperty(specificProperties, "error-log-dir"); + samplePrefix = PropertyUtils.getProperty(specificProperties, "sample-code-prefix", "S"); + } + + private static Properties getSpecificProperties(Properties properties) + { + return ExtendedProperties.getSubset(properties, IDataSetHandler.DATASET_HANDLER_KEY + '.', + true); + } + + public List<DataSetInformation> handleDataSet(File file) + { + File marker = new File(file.getParent(), createErrorMarkerFileName(file)); + File logFile = new File(new File(logDir), createErrorLogFileName(file)); + try + { + if (marker.exists()) + { + return createReturnValue(); + } + GlobalProperties properties = GlobalPropertiesLoader.load(file); + String defaultSpaceIdentifierOrNull = tryExtractSpaceIdentifier(properties); + String userOrNull = properties.tryGet(USER_KEY); + SampleType sampleType = extractSampleType(properties); + logGlobalPropertiesExtracted(file, defaultSpaceIdentifierOrNull, userOrNull, sampleType); + boolean generateCodesAutomatically = defaultSpaceIdentifierOrNull != null; + SampleCodeGenerator sampleCodeGeneratorOrNull = + tryCreateCodeGenrator(generateCodesAutomatically); + NamedInputStream stream = + new NamedInputStream(new FileInputStream(file), file.getName(), + FileUtils.readFileToByteArray(file)); + BatchSamplesOperation info = + SampleUploadSectionsParser.prepareSamples(sampleType, Arrays.asList(stream), + defaultSpaceIdentifierOrNull, sampleCodeGeneratorOrNull, true, + BatchOperationKind.REGISTRATION); + logSamplesExtracted(file, info); + service.registerSamples(info.getSamples(), userOrNull); + logSamplesRegistered(file, info); + } catch (Exception ex) + { + + String message = ex.getMessage(); + try + { + FileUtils.touch(marker); + FileUtils.writeStringToFile(logFile, message); + } catch (IOException logEx) + { + operationLog.error(String.format( + "Could not write to error log: [%s]. Message: [%s]", logFile.getPath(), + message)); + } + return createReturnValue(); + } + FileOperations.getMonitoredInstanceForCurrentThread().deleteRecursively(file); + logFileDeletion(file); + return createReturnValue(); + } + + private String createErrorLogFileName(File file) + { + return file.getName() + "_" + Constants.USER_LOG_FILE; + } + + private String createErrorMarkerFileName(File file) + { + return file.getName() + Constants.ERROR_MARKER_FILE; + } + + private ArrayList<DataSetInformation> createReturnValue() + { + return new ArrayList<DataSetInformation>(); + } + + private void logSamplesRegistered(File file, BatchSamplesOperation info) + { + String message = + String.format("%s samples extracted from file '%s' and registered", + info.getCodes().length, file.getName()); + operationLog.info(message); + } + + private void logFileDeletion(File file) + { + String message = + String.format("Deleting file '%s' after successfull registration of samples", + file.getName()); + operationLog.debug(message); + } + + private void logSamplesExtracted(File file, BatchSamplesOperation info) + { + String message = + String.format("Samples found in file '%s': %s", file.getName(), + info.getCodes().length); + operationLog.debug(message); + } + + private void logGlobalPropertiesExtracted(File file, String defaultSpaceIdentifierOrNull, + String userOrNull, SampleType sampleType) + { + String message = + String.format( + "Global properties extracted from file '%s': SAMPLE_TYPE(%s) DEFAULT_SPACE(%s) USER(%s)", + file.getName(), sampleType, defaultSpaceIdentifierOrNull, userOrNull); + operationLog.debug(message); + } + + private SampleType extractSampleType(GlobalProperties properties) + { + String sampleTypeCode = properties.get(SAMPLE_TYPE_KEY); + SampleType sampleType = new SampleType(); + sampleType.setCode(sampleTypeCode); + return sampleType; + } + + private String tryExtractSpaceIdentifier(GlobalProperties properties) + { + String spaceCodeOrNull = properties.tryGet(DEFAULT_SPACE_KEY); + if (spaceCodeOrNull == null) + { + return null; + } + return new SpaceIdentifier(DatabaseInstanceIdentifier.createHome(), spaceCodeOrNull) + .toString(); + } + + private SampleCodeGenerator tryCreateCodeGenrator(boolean generateCodesAutomatically) + { + if (generateCodesAutomatically) + { + return new SampleCodeGenerator() + { + + public List<String> generateCodes(int size) + { + return service.generateCodes(samplePrefix, size); + } + }; + } else + { + return null; + } + } + +} diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/EncapsulatedOpenBISService.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/EncapsulatedOpenBISService.java index 758805d7d0c904f0eaa3f9d69e154a631fef9f26..151975c2db01b93b4df55506d20ea13e7aaa0170 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/EncapsulatedOpenBISService.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/EncapsulatedOpenBISService.java @@ -48,6 +48,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListSampleCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewExperiment; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSamplesWithTypes; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.VocabularyTerm; @@ -79,8 +80,8 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SpaceIdentifier; public final class EncapsulatedOpenBISService implements IEncapsulatedOpenBISService, FactoryBean { - private static final Logger operationLog = - LogFactory.getLogger(LogCategory.OPERATION, EncapsulatedOpenBISService.class); + private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION, + EncapsulatedOpenBISService.class); private final IETLLIMSService service; @@ -436,6 +437,22 @@ public final class EncapsulatedOpenBISService implements IEncapsulatedOpenBISSer } } + synchronized public void registerSamples(List<NewSamplesWithTypes> newSamples, + String userIDOrNull) throws UserFailureException + { + assert newSamples != null : "Unspecified samples."; + + checkSessionToken(); + try + { + service.registerSamples(sessionToken, newSamples, userIDOrNull); + } catch (final InvalidSessionException ex) + { + authenticate(); + service.registerSamples(sessionToken, newSamples, userIDOrNull); + } + } + synchronized public long registerSample(NewSample newSample, String userIDOrNull) throws UserFailureException { @@ -766,4 +783,22 @@ public final class EncapsulatedOpenBISService implements IEncapsulatedOpenBISSer return service.tryGetDataSetForServer(sessionToken, dataSetCode); } + public List<String> generateCodes(String prefix, int size) + { + checkSessionToken(); + try + { + return primGenerateCodes(prefix, size); + } catch (final InvalidSessionException ex) + { + authenticate(); + return primGenerateCodes(prefix, size); + } + } + + private List<String> primGenerateCodes(String prefix, int size) + { + return service.generateCodes(sessionToken, prefix, size); + } + } \ No newline at end of file diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IEncapsulatedOpenBISService.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IEncapsulatedOpenBISService.java index c5c50e161fd96158b92ec7f34d89095b778e0a5f..fd0e21f0f964d55cdfc88d5f9ff4e633f5649d90 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IEncapsulatedOpenBISService.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IEncapsulatedOpenBISService.java @@ -34,6 +34,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListSampleCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewExperiment; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSamplesWithTypes; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.VocabularyTerm; @@ -162,6 +163,12 @@ public interface IEncapsulatedOpenBISService public long registerSample(final NewSample newSample, String userIDOrNull) throws UserFailureException; + /** + * Registers samples in batches. + */ + public void registerSamples(List<NewSamplesWithTypes> newSamples, String userIDOrNull) + throws UserFailureException; + /** * Updates sample specified by the argument. */ @@ -210,6 +217,11 @@ public interface IEncapsulatedOpenBISService */ public long drawANewUniqueID(); + /** + * Creates a new unique ID which can be used to create codes which are guaranteed to be unique. + */ + public List<String> generateCodes(String prefix, int size); + /** * Returns the version of the service. */ @@ -232,7 +244,7 @@ public interface IEncapsulatedOpenBISService public void updateDataSet(String code, List<NewProperty> properties, SpaceIdentifier space) throws UserFailureException; - // + // // Archiving // diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/CifexStorageProcessorTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/CifexStorageProcessorTest.java index e8d636d4ea0fa1586cacf178da5f72ccedcfa053..68233a4fdeedb2687440128afed8cce2e7c12e76 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/CifexStorageProcessorTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/CifexStorageProcessorTest.java @@ -32,7 +32,7 @@ import ch.systemsx.cisd.etlserver.DefaultStorageProcessorTest.TestProcedureAndDa */ public class CifexStorageProcessorTest extends AbstractFileSystemTestCase { - // TODO 2009-07-09 Izabela Adamczyk: Add more test cases + // TODO 2009-07-09, IA: Add more test cases private final static ITypeExtractor TYPE_EXTRACTOR = new TestProcedureAndDataTypeExtractor(); @@ -74,9 +74,11 @@ public class CifexStorageProcessorTest extends AbstractFileSystemTestCase assertEquals(false, incomingDataSetDirectory.exists()); assertEquals(true, storeData.isDirectory()); assertEquals(rootDir.getAbsolutePath(), storeData.getAbsolutePath()); - assertEquals("hello world", FileUtilities.loadToString( - new File(storeData, DefaultStorageProcessor.ORIGINAL_DIR + "/incoming/read.me")) - .trim()); + assertEquals( + "hello world", + FileUtilities.loadToString( + new File(storeData, DefaultStorageProcessor.ORIGINAL_DIR + + "/incoming/read.me")).trim()); } @Test diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ProjectSelectionTreeGridContainer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ProjectSelectionTreeGridContainer.java index 4764a35d88cc1df1b45b786a9d55c7867d7c0b4f..fafeb7b0c1fb10a6cb06746caa7e878370e20071 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ProjectSelectionTreeGridContainer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ProjectSelectionTreeGridContainer.java @@ -218,13 +218,6 @@ public final class ProjectSelectionTreeGridContainer extends LayoutContainer imp href); } }; - // TODO 2010-06-14, IA: try to adjust the size and use the info icon - // AbstractImagePrototype infoIcon = - // AbstractImagePrototype.create(viewContext.getImageBundle() - // .getInfoIcon()); - // - // final Widget detailsLink = - // LinkRenderer.getLinkWidgetWithHtml(listener, href, infoIcon.getHTML()); final Widget detailsLink = LinkRenderer.getLinkWidget(viewContext .getMessage(Dict.PROJECT_SELECTOR_DETAILS_LINK_LABEL), diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java index 413f85f3fb842a092db98837800139cf99f53ddd..d8675e5f5d05e841dfa4f5fe2c29fb85406a17f1 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java @@ -157,6 +157,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifi import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.GroupIdentifier; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ProjectIdentifier; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ProjectIdentifierFactory; +import ch.systemsx.cisd.openbis.generic.shared.parser.BisTabFileLoader; /** * The {@link ICommonClientService} implementation. diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractCommonServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractCommonServer.java index 00501c2733f19e508ef9b124df7b396581610b1d..b13229d1551f3093c5fd895a0aa691ee281e137c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractCommonServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractCommonServer.java @@ -80,8 +80,8 @@ abstract class AbstractCommonServer<T extends IServer> extends AbstractServer<T> if (unknownUsers.size() > 0) { throw UserFailureException.fromTemplate( - "Following persons unknown by the authentication service: [%s]", StringUtils - .join(userIDs, ",")); + "Following persons unknown by the authentication service: [%s]", + StringUtils.join(userIDs, ",")); } else { return newPersons; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java index 12d0eec08d76d31850dfd122a28cb3d9c0a47ded..3503c7f577d47d8069c809df7559a64050dc3794 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java @@ -41,7 +41,10 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DisplaySettings; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.GridCustomColumn; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSamplesWithTypes; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.RoleWithHierarchy.RoleCode; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.DataStorePE; import ch.systemsx.cisd.openbis.generic.shared.dto.GridCustomColumnPE; @@ -55,6 +58,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.SessionContextDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.SimpleSession; import ch.systemsx.cisd.openbis.generic.shared.translator.GridCustomExpressionTranslator.GridCustomColumnTranslator; import ch.systemsx.cisd.openbis.generic.shared.util.HibernateUtils; +import ch.systemsx.cisd.openbis.generic.shared.util.ServerUtils; /** * An <i>abstract</i> {@link IServer} implementation. @@ -83,11 +87,11 @@ public abstract class AbstractServer<T> extends AbstractServiceWithLogger<T> imp @Resource(name = ComponentNames.REMOTE_HOST_VALIDATOR) private IRemoteHostValidator remoteHostValidator; - + protected AbstractServer() { - operationLog.info(String.format("Creating new '%s' implementation: '%s'.", IServer.class - .getSimpleName(), getClass().getName())); + operationLog.info(String.format("Creating new '%s' implementation: '%s'.", + IServer.class.getSimpleName(), getClass().getName())); } protected AbstractServer(final ISessionManager<Session> sessionManager, @@ -108,7 +112,7 @@ public abstract class AbstractServer<T> extends AbstractServiceWithLogger<T> imp this.sampleTypeSlaveServerPlugin = sampleTypeSlaveServerPlugin; this.dataSetTypeSlaveServerPlugin = dataSetTypeSlaveServerPlugin; } - + public final void setSampleTypeSlaveServerPlugin( ISampleTypeSlaveServerPlugin sampleTypeSlaveServerPlugin) { @@ -173,7 +177,7 @@ public abstract class AbstractServer<T> extends AbstractServiceWithLogger<T> imp } return person; } - + protected final PersonPE getSystemUser() { return getSystemUser(daoFactory.getPersonDAO().listPersons()); @@ -410,4 +414,30 @@ public abstract class AbstractServer<T> extends AbstractServiceWithLogger<T> imp HibernateUtils.initialize(person.getAllPersonRoles()); session.setPerson(person); } + + protected void registerSamples(final Session session, + final NewSamplesWithTypes newSamplesWithType, PersonPE registratorOrNull) + { + final SampleType sampleType = newSamplesWithType.getSampleType(); + final List<NewSample> newSamples = newSamplesWithType.getNewSamples(); + assert sampleType != null : "Unspecified sample type."; + assert newSamples != null : "Unspecified new samples."; + + // Does nothing if samples list is empty. + if (newSamples.size() == 0) + { + return; + } + ServerUtils.prevalidate(newSamples, "sample"); + final String sampleTypeCode = sampleType.getCode(); + final SampleTypePE sampleTypePE = + getDAOFactory().getSampleTypeDAO().tryFindSampleTypeByCode(sampleTypeCode); + if (sampleTypePE == null) + { + throw UserFailureException.fromTemplate("Sample type with code '%s' does not exist.", + sampleTypeCode); + } + getSampleTypeSlaveServerPlugin(sampleTypePE).registerSamples(session, newSamples, + registratorOrNull); + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java index f2536d19ab7a3ac886f9462ef8e6046bd6729f1a..06790e63b4511bbfb2a4fd7a741d7f07f96ea92a 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java @@ -16,6 +16,7 @@ package ch.systemsx.cisd.openbis.generic.server; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -64,6 +65,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListOrSearchSampleCrite import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListSampleCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewExperiment; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSamplesWithTypes; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyTypeWithVocabulary; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; @@ -102,12 +104,12 @@ import ch.systemsx.cisd.openbis.generic.shared.translator.DataSetTypeTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.DatabaseInstanceTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.EntityPropertyTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.ExperimentTranslator; +import ch.systemsx.cisd.openbis.generic.shared.translator.ExperimentTranslator.LoadableFields; import ch.systemsx.cisd.openbis.generic.shared.translator.ExperimentTypeTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.ExternalDataTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.SampleTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.SampleTypeTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.VocabularyTermTranslator; -import ch.systemsx.cisd.openbis.generic.shared.translator.ExperimentTranslator.LoadableFields; import ch.systemsx.cisd.openbis.generic.shared.util.HibernateUtils; /** @@ -506,6 +508,20 @@ public class ETLService extends AbstractCommonServer<IETLService> implements IET return experimentBO.getExperiment().getId(); } + public void registerSamples(String sessionToken, + final List<NewSamplesWithTypes> newSamplesWithType, String userIDOrNull) + throws UserFailureException + { + assert sessionToken != null : "Unspecified session token."; + final Session session = getSession(sessionToken); + PersonPE registratorOrNull = + userIDOrNull != null ? getOrCreatePerson(sessionToken, userIDOrNull) : null; + for (NewSamplesWithTypes samples : newSamplesWithType) + { + registerSamples(session, samples, registratorOrNull); + } + } + public long registerSample(String sessionToken, NewSample newSample, String userIDOrNull) throws UserFailureException { @@ -753,4 +769,15 @@ public class ETLService extends AbstractCommonServer<IETLService> implements IET return VocabularyTermTranslator.translateTerms(vocabularyOrNull.getTerms()); } + public List<String> generateCodes(String sessionToken, String prefix, int number) + { + checkSession(sessionToken); + ArrayList<String> result = new ArrayList<String>(); + for (int i = 0; i < number; i++) + { + result.add(prefix + daoFactory.getCodeSequenceDAO().getNextCodeSequenceId()); + } + return result; + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLServiceLogger.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLServiceLogger.java index f2550a915474212e6b4b21b53bacffa72f2a14f2..d96caa707fedb168355c06ae759cb2393ad93d44 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLServiceLogger.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLServiceLogger.java @@ -36,6 +36,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListSampleCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewExperiment; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSamplesWithTypes; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.VocabularyTerm; @@ -93,9 +94,9 @@ public class ETLServiceLogger extends AbstractServerLogger implements IETLServic sessionToken, "registerDataStoreServer", "CODE(%s) DOWNLOAD-URL(%s) PORT(%s) DSS-TOKEN(%s) REPORTING_PLUGINS(%s), PROCESSING_PLUGINS(%s)", - code, downloadUrl, port, dssSessionToken, services - .getReportingServiceDescriptions(), services - .getProcessingServiceDescriptions()); + code, downloadUrl, port, dssSessionToken, + services.getReportingServiceDescriptions(), + services.getProcessingServiceDescriptions()); } public long registerSample(String sessionToken, NewSample newSample, String userIDOrNull) @@ -313,4 +314,33 @@ public class ETLServiceLogger extends AbstractServerLogger implements IETLServic return null; } + public void registerSamples(String sessionToken, List<NewSamplesWithTypes> newSamplesWithType, + String userIdOrNull) throws UserFailureException + { + + logTracking(sessionToken, "registerSamples", "NO_OF_SAMPLES(%s) USER(%s)", + print(newSamplesWithType), userIdOrNull); + + } + + private String print(List<NewSamplesWithTypes> newSamplesWithType) + { + StringBuilder sb = new StringBuilder(); + for (NewSamplesWithTypes samples : newSamplesWithType) + { + if (sb.length() != 0) + { + sb.append(", "); + } + sb.append(samples.getSampleType().getCode()); + sb.append(":").append(samples.getNewSamples().size()); + } + return sb.toString(); + } + + public List<String> generateCodes(String sessionToken, String prefix, int number) + { + logAccess(sessionToken, "generateCodes", "PREFIX(%s) NUMBER(%s)", prefix, number); + return null; + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/batch/SampleBatchRegistration.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/batch/SampleBatchRegistration.java index 5e1d825ca902827a04707e1da8b898d0484fb779..b82aead9cbf8748974b2040fed0a41641fceb183 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/batch/SampleBatchRegistration.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/batch/SampleBatchRegistration.java @@ -20,6 +20,7 @@ import java.util.List; import ch.systemsx.cisd.openbis.generic.server.business.bo.ISampleTable; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample; +import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; /** * {@link IBatchOperation} registering samples. @@ -32,15 +33,19 @@ public class SampleBatchRegistration implements IBatchOperation<NewSample> private final List<NewSample> entities; - public SampleBatchRegistration(ISampleTable businessTable, List<NewSample> entities) + private final PersonPE registratorOrNull; + + public SampleBatchRegistration(ISampleTable businessTable, List<NewSample> entities, + PersonPE registratorOrNull) { this.businessTable = businessTable; this.entities = entities; + this.registratorOrNull = registratorOrNull; } public void execute(List<NewSample> batch) { - businessTable.prepareForRegistration(batch); + businessTable.prepareForRegistration(batch, registratorOrNull); businessTable.save(); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractSampleBusinessObject.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractSampleBusinessObject.java index a08a01911963afb0119d9ac5df8c05aa042df7de..a4dfef76d3ae95f982f602ea0126dcaadc23ef10 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractSampleBusinessObject.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractSampleBusinessObject.java @@ -40,6 +40,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.EntityTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.EntityTypePropertyTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; +import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; import ch.systemsx.cisd.openbis.generic.shared.dto.RelationshipTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; @@ -109,7 +110,8 @@ abstract class AbstractSampleBusinessObject extends AbstractSampleIdentifierBusi final SamplePE createSample(final NewSample newSample, Map<String, SampleTypePE> sampleTypeCacheOrNull, Map<SampleOwnerIdentifier, SampleOwner> sampleOwnerCacheOrNull, - Map<String, ExperimentPE> experimentCacheOrNull) throws UserFailureException + Map<String, ExperimentPE> experimentCacheOrNull, PersonPE registratorOrNull) + throws UserFailureException { final SampleIdentifier sampleIdentifier = SampleIdentifierFactory.parse(newSample.getIdentifier()); @@ -130,7 +132,8 @@ abstract class AbstractSampleBusinessObject extends AbstractSampleIdentifierBusi final SamplePE samplePE = new SamplePE(); samplePE.setExperiment(experimentPE); samplePE.setCode(sampleIdentifier.getSampleSubCode()); - samplePE.setRegistrator(findRegistrator()); + PersonPE registrator = registratorOrNull != null ? registratorOrNull : findRegistrator(); + samplePE.setRegistrator(registrator); samplePE.setSampleType(sampleTypePE); samplePE.setSpace(sampleOwner.tryGetSpace()); samplePE.setDatabaseInstance(sampleOwner.tryGetDatabaseInstance()); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ISampleTable.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ISampleTable.java index 06c5266bc00326e09957e4826c4f916a56bef7b4..edf03ef6e9e455e23b74b9926f9cd96cd69e3d81 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ISampleTable.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ISampleTable.java @@ -22,6 +22,7 @@ import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample; import ch.systemsx.cisd.openbis.generic.shared.dto.ListSamplesByPropertyCriteria; +import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleBatchUpdatesDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; @@ -47,7 +48,8 @@ public interface ISampleTable /** * Prepares given samples for registration and stores them in this table. */ - public void prepareForRegistration(List<NewSample> newSamples) throws UserFailureException; + public void prepareForRegistration(List<NewSample> newSamples, PersonPE registratorOrNull) + throws UserFailureException; /** * Prepares given samples for update and stores them in this table. diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBO.java index 1093432bd17a6633bff5fbfb8a3aa5447c29e797..7b87d8daa5004351006e9468d853e7c29aa524a7 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBO.java @@ -128,7 +128,7 @@ public final class SampleBO extends AbstractSampleBusinessObject implements ISam { assert newSample != null : "Unspecified new sample."; - sample = createSample(newSample, null, null, null); + sample = createSample(newSample, null, null, null, null); dataChanged = true; onlyNewSamples = true; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleTable.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleTable.java index aaf147b7582b25515199d1034bae46cabed0ef40..10d9f665274524a69485ce7cb737a42300e349e4 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleTable.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleTable.java @@ -165,7 +165,8 @@ public final class SampleTable extends AbstractSampleBusinessObject implements I return samples; } - public void prepareForRegistration(List<NewSample> newSamples) throws UserFailureException + public void prepareForRegistration(List<NewSample> newSamples, PersonPE registratorOrNull) + throws UserFailureException { onlyNewSamples = true; samples = new ArrayList<SamplePE>(); @@ -178,7 +179,7 @@ public final class SampleTable extends AbstractSampleBusinessObject implements I new HashMap<SampleOwnerIdentifier, SampleOwner>(); for (NewSample sample : newSamples) { - add(sample, sampleTypeCache, sampleOwnerCache, experimentCache); + add(sample, sampleTypeCache, sampleOwnerCache, experimentCache, registratorOrNull); } setBatchUpdateMode(false); @@ -186,10 +187,12 @@ public final class SampleTable extends AbstractSampleBusinessObject implements I private void add(final NewSample newSample, final Map<String, SampleTypePE> sampleTypeCache, final Map<SampleOwnerIdentifier, SampleOwner> sampleOwnerCache, - Map<String, ExperimentPE> experimentCache) throws UserFailureException + Map<String, ExperimentPE> experimentCache, PersonPE registratorOrNull) + throws UserFailureException { assert newSample != null : "Unspecified new sample."; - samples.add(createSample(newSample, sampleTypeCache, sampleOwnerCache, experimentCache)); + samples.add(createSample(newSample, sampleTypeCache, sampleOwnerCache, experimentCache, + registratorOrNull)); dataChanged = true; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/plugin/ISampleTypeSlaveServerPlugin.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/plugin/ISampleTypeSlaveServerPlugin.java index 99ebea72a5d164efff21140809c609c06b3e467c..5f6f870cc51068a573b5c50540d735d074fdf4e6 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/plugin/ISampleTypeSlaveServerPlugin.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/plugin/ISampleTypeSlaveServerPlugin.java @@ -21,6 +21,7 @@ import java.util.List; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.openbis.generic.server.dataaccess.db.DAOFactory; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample; +import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleBatchUpdatesDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleParentWithDerivedDTO; @@ -46,8 +47,8 @@ public interface ISampleTypeSlaveServerPlugin /** * Registers given list of {@link NewSample NewSamples}. */ - void registerSamples(final Session session, final List<NewSample> newSamples) - throws UserFailureException; + void registerSamples(final Session session, final List<NewSample> newSamples, + PersonPE registratorOrNUll) throws UserFailureException; /** * Updates given list of samples. diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java index 9998fe1978911648af5d6510e0b7dde45d70fd69..be91421c2e9ece85c2ceeec4205169411833d24f 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java @@ -26,23 +26,25 @@ import ch.systemsx.cisd.openbis.generic.shared.authorization.ISessionProvider; import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.AuthorizationGuard; import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.ReturnValueFilter; import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.RolesAllowed; +import ch.systemsx.cisd.openbis.generic.shared.authorization.predicate.AbstractTechIdPredicate.ExperimentTechIdPredicate; import ch.systemsx.cisd.openbis.generic.shared.authorization.predicate.DataSetCodeCollectionPredicate; import ch.systemsx.cisd.openbis.generic.shared.authorization.predicate.DataSetCodePredicate; import ch.systemsx.cisd.openbis.generic.shared.authorization.predicate.ListSampleCriteriaPredicate; import ch.systemsx.cisd.openbis.generic.shared.authorization.predicate.ListSamplesByPropertyPredicate; import ch.systemsx.cisd.openbis.generic.shared.authorization.predicate.NewExperimentPredicate; import ch.systemsx.cisd.openbis.generic.shared.authorization.predicate.NewSamplePredicate; +import ch.systemsx.cisd.openbis.generic.shared.authorization.predicate.NewSamplesWithTypePredicate; import ch.systemsx.cisd.openbis.generic.shared.authorization.predicate.SampleOwnerIdentifierPredicate; import ch.systemsx.cisd.openbis.generic.shared.authorization.predicate.SampleTechIdPredicate; import ch.systemsx.cisd.openbis.generic.shared.authorization.predicate.SampleUpdatesPredicate; import ch.systemsx.cisd.openbis.generic.shared.authorization.predicate.SpaceIdentifierPredicate; -import ch.systemsx.cisd.openbis.generic.shared.authorization.predicate.AbstractTechIdPredicate.ExperimentTechIdPredicate; import ch.systemsx.cisd.openbis.generic.shared.authorization.validator.SampleValidator; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ArchiverDataSetCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetArchivingStatus; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetTypeWithVocabularyTerms; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseInstance; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind.ObjectKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DeletedDataSet; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExperimentType; @@ -51,11 +53,11 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListSampleCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewExperiment; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSamplesWithTypes; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.RoleWithHierarchy; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.VocabularyTerm; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind.ObjectKind; import ch.systemsx.cisd.openbis.generic.shared.dto.DataStoreServerInfo; import ch.systemsx.cisd.openbis.generic.shared.dto.ListSamplesByPropertyCriteria; import ch.systemsx.cisd.openbis.generic.shared.dto.NewExternalData; @@ -222,10 +224,19 @@ public interface IETLLIMSService extends IServer, ISessionProvider @AuthorizationGuard(guardClass = NewExperimentPredicate.class) NewExperiment experiment) throws UserFailureException; + /** + * Registers samples in batches. + */ + @Transactional + @RolesAllowed(RoleWithHierarchy.SPACE_ETL_SERVER) + @DatabaseUpdateModification(value = ObjectKind.SAMPLE) + public void registerSamples( + final String sessionToken, + @AuthorizationGuard(guardClass = NewSamplesWithTypePredicate.class) final List<NewSamplesWithTypes> newSamplesWithType, + String userIdOrNull) throws UserFailureException; + /** * Registers a new sample. - * - * @return the technical ID of the new sample. */ @Transactional @RolesAllowed(RoleWithHierarchy.SPACE_ETL_SERVER) @@ -295,7 +306,7 @@ public interface IETLLIMSService extends IServer, ISessionProvider public void deleteDataSet(String sessionToken, @AuthorizationGuard(guardClass = DataSetCodePredicate.class) String dataSetCode, String reason) throws UserFailureException; - + /** * Checks that the user of specified session has INSTANCE_ADMIN access rights. */ @@ -459,4 +470,11 @@ public interface IETLLIMSService extends IServer, ISessionProvider @AuthorizationGuard(guardClass = DataSetCodePredicate.class) String dataSetCode) throws UserFailureException; + /** + * Returns a list of unique codes. + */ + @Transactional + @RolesAllowed(RoleWithHierarchy.SPACE_ETL_SERVER) + public List<String> generateCodes(String sessionToken, String prefix, int number); + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/BatchRegistrationResult.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/BatchRegistrationResult.java similarity index 86% rename from openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/BatchRegistrationResult.java rename to openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/BatchRegistrationResult.java index c0e2ea35d13d1540c655b3e7c59e913bdd111e84..64a5803f3b7e8f88600e05d9c1abd553098bca81 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/BatchRegistrationResult.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/BatchRegistrationResult.java @@ -14,7 +14,9 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.generic.client.web.client.dto; +package ch.systemsx.cisd.openbis.generic.shared.basic.dto; + +import java.io.Serializable; import com.google.gwt.user.client.rpc.IsSerializable; @@ -24,8 +26,11 @@ import com.google.gwt.user.client.rpc.IsSerializable; * * @author Christian Ribeaud */ -public class BatchRegistrationResult implements IsSerializable +public class BatchRegistrationResult implements IsSerializable, Serializable { + + private static final long serialVersionUID = ServiceVersionHolder.VERSION; + private String fileName; private String message; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/NewSamplesWithTypes.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/NewSamplesWithTypes.java index 3c472c69c5eb5c5ed8cac505da7e1ddc7d8cc52a..6f6065a0bf8718422dff7fe61575379883678947 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/NewSamplesWithTypes.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/NewSamplesWithTypes.java @@ -16,15 +16,20 @@ package ch.systemsx.cisd.openbis.generic.shared.basic.dto; +import java.io.Serializable; import java.util.List; +import com.google.gwt.user.client.rpc.IsSerializable; + /** * Contains a list of new samples and their type. * * @author Izabela Adamczyk */ -public class NewSamplesWithTypes +public class NewSamplesWithTypes implements IsSerializable, Serializable { + private static final long serialVersionUID = ServiceVersionHolder.VERSION; + SampleType sampleType; List<NewSample> newSamples; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/BisTabFileLoader.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/BisTabFileLoader.java similarity index 98% rename from openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/BisTabFileLoader.java rename to openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/BisTabFileLoader.java index 3af17f97b1f01e9de2441624c90dc094b46a17d7..ea470420dc63e4db88eb5ef0df8423830dcfc489 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/BisTabFileLoader.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/BisTabFileLoader.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.generic.client.web.server; +package ch.systemsx.cisd.openbis.generic.shared.parser; import java.io.Reader; import java.util.List; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/GlobalProperties.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/GlobalProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..c35035444ab0f699734608a637cd29368189a8a1 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/GlobalProperties.java @@ -0,0 +1,69 @@ +/* + * Copyright 2010 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.parser; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Izabela Adamczyk + */ +public class GlobalProperties +{ + + private final Map<String, String> properties = new HashMap<String, String>(); + + public GlobalProperties() + { + } + + /** + * Adds property with given key and value.Throws {@link IllegalArgumentException} if property + * already defined. + */ + public void add(String key, String value) + { + if (properties.containsKey(key)) + { + throw new IllegalArgumentException(String.format("Property '%s' defined twice.", key)); + } + properties.put(key, value); + } + + /** + * Returns value of given property. Throws {@link IllegalArgumentException} if property not + * defined. + */ + public String get(String key) + { + String value = tryGet(key); + if (value == null) + { + throw new IllegalArgumentException(String.format("Property '%s' not defined.", key)); + } + return value; + } + + /** + * Returns value of given property. + */ + public String tryGet(String key) + { + return properties.get(key); + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/GlobalPropertiesLoader.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/GlobalPropertiesLoader.java new file mode 100644 index 0000000000000000000000000000000000000000..5e85cb99ec75cccc387243f81aba1aa4b9de7fee --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/GlobalPropertiesLoader.java @@ -0,0 +1,114 @@ +/* + * Copyright 2010 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.parser; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.InputStreamReader; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.io.LineIterator; +import org.apache.commons.lang.StringUtils; + +/** + * Loads global properties. + * <p> + * Global properties are defined as a comment and start with {@link #GLOBAL_PROPERTIES} followed by + * a new line character. Each property is defined in a separate line and has the following format: + * <p> + * # key = value + * </p> + * First line in a different format marks the end of global properties. (Empty line can be used). + * <p> + * Example: + * </p> + * </p> --- FILE ---<br> + * # GLOBAL_PROPERTIES: <br> + * # key1 = value1 <br> + * # key2 = value2 <br> + * <br> + * code parent experiment <br> + * --- EOF --- + * + * @author Izabela Adamczyk + */ +public class GlobalPropertiesLoader +{ + private static final String COMMENT_PREFIX = "#"; + + static String GLOBAL_PROPERTIES = "#GLOBAL_PROPERTIES:"; + + public static GlobalProperties load(File file) throws FileNotFoundException + { + GlobalProperties properties = new GlobalProperties(); + InputStreamReader reader = new FileReader(file); + try + { + LineIterator it = IOUtils.lineIterator(reader); + boolean propertiesStarted = false; + while (it.hasNext()) + { + String line = it.nextLine(); + if (isGlobalPropertiesStarter(line)) + { + propertiesStarted = true; + continue; + } + if (propertiesStarted) + { + String[] definitionOrNull = tryGetPropertyDefinition(line); + if (definitionOrNull != null) + { + properties.add(definitionOrNull[0], definitionOrNull[1]); + continue; + } else + { + return properties; + } + } + } + } finally + { + IOUtils.closeQuietly(reader); + } + return properties; + } + + private static String[] tryGetPropertyDefinition(String line) + { + String commentPrefix = COMMENT_PREFIX; + if (line.startsWith(commentPrefix)) + { + String[] splitted = StringUtils.split(line.substring(commentPrefix.length()), "=", 2); + if (splitted.length == 2) + { + String[] result = new String[2]; + result[0] = StringUtils.trim(splitted[0]); + result[1] = StringUtils.trim(splitted[1]); + return result; + } + } + return null; + } + + private static boolean isGlobalPropertiesStarter(String line) + { + return line.equals(GLOBAL_PROPERTIES); + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/NamedInputStream.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/NamedInputStream.java similarity index 95% rename from openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/NamedInputStream.java rename to openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/NamedInputStream.java index e9c2bc59aa7cf8788171280e3af0b20c998da03e..5556981bdb0bd8c0749551366314383239dc74f3 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/NamedInputStream.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/NamedInputStream.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.generic.client.web.server; +package ch.systemsx.cisd.openbis.generic.shared.parser; import java.io.InputStream; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/parser/NewSampleParserObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/NewSampleParserObjectFactory.java similarity index 98% rename from openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/parser/NewSampleParserObjectFactory.java rename to openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/NewSampleParserObjectFactory.java index f997cebd8e2db3261970b621e3d21cd88b407590..41f5bbe74e6a5f90d34d51a9c54e64dedf8eb9b4 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/parser/NewSampleParserObjectFactory.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/NewSampleParserObjectFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.plugin.generic.client.web.server.parser; +package ch.systemsx.cisd.openbis.generic.shared.parser; import java.util.ArrayList; import java.util.List; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/parser/SampleUploadSectionsParser.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/SampleUploadSectionsParser.java similarity index 96% rename from openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/parser/SampleUploadSectionsParser.java rename to openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/SampleUploadSectionsParser.java index 8955fccbf0d4c138782317d81ada9a19647cd4e2..47c649d5a6ecdd149c88acb7e969d05ebbcd9bc7 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/parser/SampleUploadSectionsParser.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/SampleUploadSectionsParser.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.plugin.generic.client.web.server.parser; +package ch.systemsx.cisd.openbis.generic.shared.parser; import java.io.InputStream; import java.io.InputStreamReader; @@ -32,10 +32,8 @@ import ch.systemsx.cisd.common.parser.IParserObjectFactory; import ch.systemsx.cisd.common.parser.IParserObjectFactoryFactory; import ch.systemsx.cisd.common.parser.IPropertyMapper; import ch.systemsx.cisd.common.parser.ParserException; -import ch.systemsx.cisd.openbis.generic.client.web.client.dto.BatchRegistrationResult; -import ch.systemsx.cisd.openbis.generic.client.web.server.BisTabFileLoader; -import ch.systemsx.cisd.openbis.generic.client.web.server.NamedInputStream; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchOperationKind; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSamplesWithTypes; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; @@ -274,8 +272,7 @@ public class SampleUploadSectionsParser sampleSections.size() == 1 ? "" : " (section:" + fs.getSectionName() + ")"; final List<NewSample> loadedSamples = tabFileLoader.load(new DelegatedReader(stringReader, multipartFile - .getOriginalFilename() - + sectionInFile)); + .getOriginalFilename() + sectionInFile)); if (loadedSamples.size() > 0) { newSamples.add(new NewSamplesWithTypes(typeFromSection, loadedSamples)); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/parser/UpdatedSampleParserObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/UpdatedSampleParserObjectFactory.java similarity index 98% rename from openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/parser/UpdatedSampleParserObjectFactory.java rename to openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/UpdatedSampleParserObjectFactory.java index 070e0ff03c684c76720b5325aca8ec781e767aeb..b9b089421beeb75f143615bf48641c1d0d4c26f8 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/parser/UpdatedSampleParserObjectFactory.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/parser/UpdatedSampleParserObjectFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.plugin.generic.client.web.server.parser; +package ch.systemsx.cisd.openbis.generic.shared.parser; import java.util.ArrayList; import java.util.HashSet; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/util/ServerUtils.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/util/ServerUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..e45c9057d3580f244fb96264460a9d75b6041216 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/util/ServerUtils.java @@ -0,0 +1,62 @@ +/* + * Copyright 2010 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.util; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import ch.systemsx.cisd.common.collections.CollectionUtils; +import ch.systemsx.cisd.common.exceptions.UserFailureException; + +/** + * Tools to be used by servers. + * + * @author Izabela Adamczyk + */ +public class ServerUtils +{ + /** + * @throws UserFailureException when list of entities contains duplicates. + */ + static public <T> void prevalidate(List<T> entities, String entityName) + { + Collection<T> duplicated = extractDuplicatedElements(entities); + if (duplicated.size() > 0) + { + throw UserFailureException.fromTemplate("Following %s(s) '%s' are duplicated.", + entityName, CollectionUtils.abbreviate(duplicated, 20)); + } + } + + private static <T> Collection<T> extractDuplicatedElements(List<T> entities) + { + Set<T> entitiesSet = new HashSet<T>(entities); + Collection<T> duplicated = new ArrayList<T>(); + for (T entity : entities) + { + // this element must have been duplicated + if (entitiesSet.remove(entity) == false) + { + duplicated.add(entity); + } + } + return duplicated; + } +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/IGenericClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/IGenericClientService.java index 0b4c4125f901ae01c18314b35fd3857f2aa9a1fd..1363d956e8e1c09c5ba6eb1002aea7bd0d995673 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/IGenericClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/IGenericClientService.java @@ -20,11 +20,11 @@ import java.util.Date; import java.util.List; import ch.systemsx.cisd.openbis.generic.client.web.client.IClientService; -import ch.systemsx.cisd.openbis.generic.client.web.client.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DataSetUpdates; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SampleUpdates; import ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureException; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetUpdateResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExperimentType; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/IGenericClientServiceAsync.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/IGenericClientServiceAsync.java index 382b42a679b05fe878bb209f9731e3d4bff145fb..fb626504f1a8de097998198c0d62574519340e77 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/IGenericClientServiceAsync.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/IGenericClientServiceAsync.java @@ -22,11 +22,11 @@ import java.util.List; import com.google.gwt.user.client.rpc.AsyncCallback; import ch.systemsx.cisd.openbis.generic.client.web.client.IClientServiceAsync; -import ch.systemsx.cisd.openbis.generic.client.web.client.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DataSetUpdates; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SampleUpdates; import ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureException; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetUpdateResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExperimentType; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/dataset/GenericDataSetBatchUpdateForm.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/dataset/GenericDataSetBatchUpdateForm.java index dbae9debc755e2450d82034a262bc11ec7631c79..16b4e9c4478eac50f709390f657c730e0c59d804 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/dataset/GenericDataSetBatchUpdateForm.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/dataset/GenericDataSetBatchUpdateForm.java @@ -41,8 +41,8 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.renderer.L import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.AbstractRegistrationForm; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.file.BasicFileFieldManager; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.WindowUtils; -import ch.systemsx.cisd.openbis.generic.client.web.client.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchOperationKind; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; import ch.systemsx.cisd.openbis.plugin.generic.client.web.client.IGenericClientServiceAsync; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/AbstractExperimentBatchRegistrationForm.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/AbstractExperimentBatchRegistrationForm.java index 5cfeaac41915e64eacdf1eef22b3135daeb05de8..8f8240fa949e67e596e14512ee958e45f5d9d5f3 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/AbstractExperimentBatchRegistrationForm.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/AbstractExperimentBatchRegistrationForm.java @@ -41,8 +41,8 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.renderer.L import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.AbstractRegistrationForm; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.file.BasicFileFieldManager; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.WindowUtils; -import ch.systemsx.cisd.openbis.generic.client.web.client.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchOperationKind; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExperimentType; import ch.systemsx.cisd.openbis.plugin.generic.client.web.client.IGenericClientServiceAsync; @@ -70,9 +70,9 @@ public abstract class AbstractExperimentBatchRegistrationForm extends AbstractRe private final BatchOperationKind batchOperationKind; - public AbstractExperimentBatchRegistrationForm(IViewContext<IGenericClientServiceAsync> viewContext, - ExperimentType type, BatchOperationKind batchOperationKind, - String sessionKey) + public AbstractExperimentBatchRegistrationForm( + IViewContext<IGenericClientServiceAsync> viewContext, ExperimentType type, + BatchOperationKind batchOperationKind, String sessionKey) { super(viewContext.getCommonViewContext(), createId(sessionKey)); this.viewContext = viewContext; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/material/AbstractMaterialBatchRegistrationForm.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/material/AbstractMaterialBatchRegistrationForm.java index add53daff630c8b2c873fc95c150b5e3358b32cb..d3632a87fb5a716422c5c570cf39eb978a8f00f4 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/material/AbstractMaterialBatchRegistrationForm.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/material/AbstractMaterialBatchRegistrationForm.java @@ -42,8 +42,8 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.renderer.L import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.AbstractRegistrationForm; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.file.BasicFileFieldManager; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.WindowUtils; -import ch.systemsx.cisd.openbis.generic.client.web.client.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchOperationKind; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.MaterialType; import ch.systemsx.cisd.openbis.plugin.generic.client.web.client.IGenericClientServiceAsync; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/GenericSampleBatchRegistrationForm.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/GenericSampleBatchRegistrationForm.java index 9ea7206eadddb5dd404df199e27eaaf77ac7b599..06096b580356e111f0b2a488cc5b51571fc2120d 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/GenericSampleBatchRegistrationForm.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/GenericSampleBatchRegistrationForm.java @@ -37,8 +37,8 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.GroupSe import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.field.CheckBoxField; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.FieldUtil; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.WindowUtils; -import ch.systemsx.cisd.openbis.generic.client.web.client.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchOperationKind; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Space; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/GenericSampleBatchUpdateForm.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/GenericSampleBatchUpdateForm.java index 3a05e7f142ab11da2c48644f79a84e67c07c0718..9302a9218c83e84b451b9f5f7896f869d3a90421 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/GenericSampleBatchUpdateForm.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/GenericSampleBatchUpdateForm.java @@ -43,8 +43,8 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.Abstrac import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.GroupSelectionWidget; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.file.BasicFileFieldManager; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.WindowUtils; -import ch.systemsx.cisd.openbis.generic.client.web.client.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchOperationKind; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Space; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/DataSetLoader.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/DataSetLoader.java index 9a513af115f0a031607d9d8496a2c8ccc5d5de26..9b9c6367a817e4d93619ef552f2465ee99a95eef 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/DataSetLoader.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/DataSetLoader.java @@ -26,10 +26,10 @@ import ch.systemsx.cisd.common.parser.IParserObjectFactory; import ch.systemsx.cisd.common.parser.IParserObjectFactoryFactory; import ch.systemsx.cisd.common.parser.IPropertyMapper; import ch.systemsx.cisd.common.parser.ParserException; -import ch.systemsx.cisd.openbis.generic.client.web.client.dto.BatchRegistrationResult; -import ch.systemsx.cisd.openbis.generic.client.web.server.BisTabFileLoader; -import ch.systemsx.cisd.openbis.generic.client.web.server.NamedInputStream; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewDataSet; +import ch.systemsx.cisd.openbis.generic.shared.parser.BisTabFileLoader; +import ch.systemsx.cisd.openbis.generic.shared.parser.NamedInputStream; import ch.systemsx.cisd.openbis.plugin.generic.client.web.server.parser.NewDataSetParserObjectFactory; /** diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/ExperimentLoader.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/ExperimentLoader.java index 733f0cbec5f49682eed81e6b686fded46f5ce2fb..7a2ce897af5e36e30c2d153ec0980fbdb2920927 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/ExperimentLoader.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/ExperimentLoader.java @@ -27,10 +27,10 @@ import ch.systemsx.cisd.common.parser.IParserObjectFactory; import ch.systemsx.cisd.common.parser.IParserObjectFactoryFactory; import ch.systemsx.cisd.common.parser.IPropertyMapper; import ch.systemsx.cisd.common.parser.ParserException; -import ch.systemsx.cisd.openbis.generic.client.web.client.dto.BatchRegistrationResult; -import ch.systemsx.cisd.openbis.generic.client.web.server.BisTabFileLoader; -import ch.systemsx.cisd.openbis.generic.client.web.server.NamedInputStream; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewBasicExperiment; +import ch.systemsx.cisd.openbis.generic.shared.parser.BisTabFileLoader; +import ch.systemsx.cisd.openbis.generic.shared.parser.NamedInputStream; import ch.systemsx.cisd.openbis.plugin.generic.client.web.server.parser.NewBasicExperimentParserObjectFactory; /** diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/GenericClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/GenericClientService.java index bf839cbf8dacbc839c515c61c71bbd4641cbe8b4..8c19f982985db4e00834c9bafc2f1689a441c4b2 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/GenericClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/GenericClientService.java @@ -33,17 +33,16 @@ import ch.rinn.restrictions.Private; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.servlet.IRequestContextProvider; import ch.systemsx.cisd.common.spring.IUncheckedMultipartFile; -import ch.systemsx.cisd.openbis.generic.client.web.client.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DataSetUpdates; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SampleUpdates; import ch.systemsx.cisd.openbis.generic.client.web.server.AbstractClientService; import ch.systemsx.cisd.openbis.generic.client.web.server.AttachmentRegistrationHelper; -import ch.systemsx.cisd.openbis.generic.client.web.server.NamedInputStream; import ch.systemsx.cisd.openbis.generic.client.web.server.UploadedFilesBean; import ch.systemsx.cisd.openbis.generic.client.web.server.translator.UserFailureExceptionTranslator; import ch.systemsx.cisd.openbis.generic.shared.IServer; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchOperationKind; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetUpdateResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExperimentType; @@ -74,10 +73,11 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ProjectIdentifier; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ProjectIdentifierFactory; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifierFactory; +import ch.systemsx.cisd.openbis.generic.shared.parser.NamedInputStream; +import ch.systemsx.cisd.openbis.generic.shared.parser.SampleUploadSectionsParser; +import ch.systemsx.cisd.openbis.generic.shared.parser.SampleUploadSectionsParser.BatchSamplesOperation; +import ch.systemsx.cisd.openbis.generic.shared.parser.SampleUploadSectionsParser.SampleCodeGenerator; import ch.systemsx.cisd.openbis.plugin.generic.client.web.client.IGenericClientService; -import ch.systemsx.cisd.openbis.plugin.generic.client.web.server.parser.SampleUploadSectionsParser; -import ch.systemsx.cisd.openbis.plugin.generic.client.web.server.parser.SampleUploadSectionsParser.BatchSamplesOperation; -import ch.systemsx.cisd.openbis.plugin.generic.client.web.server.parser.SampleUploadSectionsParser.SampleCodeGenerator; import ch.systemsx.cisd.openbis.plugin.generic.shared.IGenericServer; import ch.systemsx.cisd.openbis.plugin.generic.shared.ResourceNames; @@ -167,7 +167,6 @@ public class GenericClientService extends AbstractClientService implements IGene { throw UserFailureExceptionTranslator.translate(e); } - } public final List<BatchRegistrationResult> updateSamples(final SampleType sampleType, diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/MaterialLoader.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/MaterialLoader.java index 38a9d2691b22df2b57be8b84282c3b8c81c17125..ea7f61fc61df827b5867866e5aa35665e5290d13 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/MaterialLoader.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/MaterialLoader.java @@ -11,10 +11,10 @@ import ch.systemsx.cisd.common.parser.IParserObjectFactory; import ch.systemsx.cisd.common.parser.IParserObjectFactoryFactory; import ch.systemsx.cisd.common.parser.IPropertyMapper; import ch.systemsx.cisd.common.parser.ParserException; -import ch.systemsx.cisd.openbis.generic.client.web.client.dto.BatchRegistrationResult; -import ch.systemsx.cisd.openbis.generic.client.web.server.BisTabFileLoader; -import ch.systemsx.cisd.openbis.generic.client.web.server.NamedInputStream; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewMaterial; +import ch.systemsx.cisd.openbis.generic.shared.parser.BisTabFileLoader; +import ch.systemsx.cisd.openbis.generic.shared.parser.NamedInputStream; import ch.systemsx.cisd.openbis.plugin.generic.client.web.server.parser.NewMaterialParserObjectFactory; public class MaterialLoader diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/UpdatedExperimentLoader.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/UpdatedExperimentLoader.java index 780393ee3a05f8745e754c5d46840baa1bf75953..abc6eeff31440fc7074b743e528a480fc3baadff 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/UpdatedExperimentLoader.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/UpdatedExperimentLoader.java @@ -27,10 +27,10 @@ import ch.systemsx.cisd.common.parser.IParserObjectFactory; import ch.systemsx.cisd.common.parser.IParserObjectFactoryFactory; import ch.systemsx.cisd.common.parser.IPropertyMapper; import ch.systemsx.cisd.common.parser.ParserException; -import ch.systemsx.cisd.openbis.generic.client.web.client.dto.BatchRegistrationResult; -import ch.systemsx.cisd.openbis.generic.client.web.server.BisTabFileLoader; -import ch.systemsx.cisd.openbis.generic.client.web.server.NamedInputStream; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.UpdatedBasicExperiment; +import ch.systemsx.cisd.openbis.generic.shared.parser.BisTabFileLoader; +import ch.systemsx.cisd.openbis.generic.shared.parser.NamedInputStream; import ch.systemsx.cisd.openbis.plugin.generic.client.web.server.parser.UpdatedBasicExperimentParserObjectFactory; /** diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericSampleTypeSlaveServerPlugin.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericSampleTypeSlaveServerPlugin.java index 6cf0ad08ee06ba7b31d6340df45d6b8c5d179fad..60dc6f2cf84563056feb79bbca92ff0bebf19d0e 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericSampleTypeSlaveServerPlugin.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericSampleTypeSlaveServerPlugin.java @@ -31,6 +31,7 @@ import ch.systemsx.cisd.openbis.generic.server.business.bo.SampleHierarchyFiller import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; import ch.systemsx.cisd.openbis.generic.server.plugin.ISampleTypeSlaveServerPlugin; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample; +import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleBatchUpdatesDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleParentWithDerivedDTO; @@ -73,14 +74,14 @@ public final class GenericSampleTypeSlaveServerPlugin implements ISampleTypeSlav return new SampleParentWithDerivedDTO(sample, generated); } - public final void registerSamples(final Session session, final List<NewSample> newSamples) - throws UserFailureException + public final void registerSamples(final Session session, final List<NewSample> newSamples, + PersonPE registratorOrNUll) throws UserFailureException { assert session != null : "Unspecified session."; assert newSamples != null && newSamples.size() > 0 : "Unspecified sample or empty samples."; BatchOperationExecutor.executeInBatches(new SampleBatchRegistration(businessObjectFactory - .createSampleTable(session), newSamples)); + .createSampleTable(session), newSamples, registratorOrNUll)); } public void updateSamples(Session session, List<SampleBatchUpdatesDTO> updateSamples) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServer.java index 91d46c248d6aa6b511cf85af8a1d9ca0b03a94b8..8bfe51350dce3b2567b3d27c3c2f99b3c253984f 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServer.java @@ -34,7 +34,6 @@ import org.springframework.stereotype.Component; import ch.rinn.restrictions.Private; import ch.systemsx.cisd.authentication.ISessionManager; -import ch.systemsx.cisd.common.collections.CollectionUtils; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogFactory; @@ -117,6 +116,7 @@ import ch.systemsx.cisd.openbis.generic.shared.translator.ExperimentTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.MaterialTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.MaterialTypeTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.SampleTranslator; +import ch.systemsx.cisd.openbis.generic.shared.util.ServerUtils; import ch.systemsx.cisd.openbis.plugin.generic.shared.IGenericServer; import ch.systemsx.cisd.openbis.plugin.generic.shared.ResourceNames; @@ -287,7 +287,7 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen { if (samples.isAllowUpdateIfExist() == false) { - registerSamples(session, samples); + registerSamples(session, samples, null); } else { BatchOperationExecutor.executeInBatches(new SampleBatchRegisterOrUpdate( @@ -338,7 +338,7 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen SampleRegisterOrUpdateUtil.getSamplesToUpdate(newSamples, existingSamples); List<NewSample> samplesToRegister = new ArrayList<NewSample>(newSamples); samplesToRegister.removeAll(samplesToUpdate); - registerSamples(session, new NewSamplesWithTypes(sampleType, samplesToRegister)); + registerSamples(session, new NewSamplesWithTypes(sampleType, samplesToRegister), null); updateSamples(session, new NewSamplesWithTypes(sampleType, samplesToUpdate)); } @@ -366,7 +366,7 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen final Session session = getSession(sessionToken); for (NewSamplesWithTypes samples : newSamplesWithType) { - registerSamples(session, samples); + registerSamples(session, samples, null); } } @@ -392,7 +392,7 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen { return; } - prevalidate(newDataSets, "data set"); + ServerUtils.prevalidate(newDataSets, "data set"); final DataSetTypePE dataSetType = getDAOFactory().getDataSetTypeDAO().tryToFindDataSetTypeByCode( dataSets.getDataSetType().getCode()); @@ -404,30 +404,6 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen getDataSetTypeSlaveServerPlugin(dataSetType).updateDataSets(session, newDataSets); } - private void registerSamples(final Session session, final NewSamplesWithTypes newSamplesWithType) - { - final SampleType sampleType = newSamplesWithType.getSampleType(); - final List<NewSample> newSamples = newSamplesWithType.getNewSamples(); - assert sampleType != null : "Unspecified sample type."; - assert newSamples != null : "Unspecified new samples."; - - // Does nothing if samples list is empty. - if (newSamples.size() == 0) - { - return; - } - prevalidate(newSamples, "sample"); - final String sampleTypeCode = sampleType.getCode(); - final SampleTypePE sampleTypePE = - getDAOFactory().getSampleTypeDAO().tryFindSampleTypeByCode(sampleTypeCode); - if (sampleTypePE == null) - { - throw UserFailureException.fromTemplate("Sample type with code '%s' does not exist.", - sampleTypeCode); - } - getSampleTypeSlaveServerPlugin(sampleTypePE).registerSamples(session, newSamples); - } - private void updateSamples(final Session session, final NewSamplesWithTypes updatedSamplesWithType) { @@ -442,7 +418,7 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen return; } - prevalidate(updatedSamples, "sample"); + ServerUtils.prevalidate(updatedSamples, "sample"); final String sampleTypeCode = sampleType.getCode(); final SampleTypePE sampleTypePE = getDAOFactory().getSampleTypeDAO().tryFindSampleTypeByCode(sampleTypeCode); @@ -577,7 +553,7 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen { return; } - prevalidate(newMaterials, "material"); + ServerUtils.prevalidate(newMaterials, "material"); final MaterialTypePE materialTypePE = findMaterialType(materialTypeCode); final Session session = getSession(sessionToken); IBatchOperation<NewMaterial> strategy = new IBatchOperation<NewMaterial>() @@ -627,7 +603,7 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen int count; } final Counter counter = new Counter(); - prevalidate(newMaterials, "material"); + ServerUtils.prevalidate(newMaterials, "material"); final Map<String/* code */, Material> existingMaterials = listMaterials(sessionToken, materialTypeCode); final Session session = getSession(sessionToken); @@ -674,31 +650,6 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen return counter.count; } - private <T> void prevalidate(List<T> entities, String entityName) - { - Collection<T> duplicated = extractDuplicatedElements(entities); - if (duplicated.size() > 0) - { - throw UserFailureException.fromTemplate("Following %s(s) '%s' are duplicated.", - entityName, CollectionUtils.abbreviate(duplicated, 20)); - } - } - - private static <T> Collection<T> extractDuplicatedElements(List<T> entities) - { - Set<T> entitiesSet = new HashSet<T>(entities); - Collection<T> duplicated = new ArrayList<T>(); - for (T entity : entities) - { - // this element must have been duplicated - if (entitiesSet.remove(entity) == false) - { - duplicated.add(entity); - } - } - return duplicated; - } - private MaterialTypePE findMaterialType(String materialTypeCode) { final MaterialTypePE materialTypePE = @@ -902,7 +853,7 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen { return; } - prevalidate(newExperiments, "experiment"); + ServerUtils.prevalidate(newExperiments, "experiment"); final ExperimentTypePE experimentTypePE = (ExperimentTypePE) getDAOFactory().getEntityTypeDAO(EntityKind.EXPERIMENT) .tryToFindEntityTypeByCode(experiments.getExperimentTypeCode()); @@ -935,7 +886,7 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen { return; } - prevalidate(newExperiments, "experiment"); + ServerUtils.prevalidate(newExperiments, "experiment"); final ExperimentTypePE experimentTypePE = (ExperimentTypePE) getDAOFactory().getEntityTypeDAO(EntityKind.EXPERIMENT) .tryToFindEntityTypeByCode(experiments.getExperimentType().getCode()); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/parser/NewSampleParserObjectFactoryTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/parser/NewSampleParserObjectFactoryTest.java similarity index 99% rename from openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/parser/NewSampleParserObjectFactoryTest.java rename to openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/parser/NewSampleParserObjectFactoryTest.java index 200f3e5436cea21a2b4da9bc9f85cc01c7789d73..47ba5f7a534ca68ebfe2743a27ce5ab14c15d195 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/parser/NewSampleParserObjectFactoryTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/parser/NewSampleParserObjectFactoryTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.plugin.generic.client.web.server.parser; +package ch.systemsx.cisd.openbis.generic.shared.parser; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertFalse; diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/parser/UpdatedSampleParserObjectFactoryTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/parser/UpdatedSampleParserObjectFactoryTest.java similarity index 97% rename from openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/parser/UpdatedSampleParserObjectFactoryTest.java rename to openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/parser/UpdatedSampleParserObjectFactoryTest.java index ea811f8ad25471b9de2dd394401ef36e273090f3..476b21033f47cd29ee3e6c2b2bd7baa100f2f77e 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/parser/UpdatedSampleParserObjectFactoryTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/parser/UpdatedSampleParserObjectFactoryTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.plugin.generic.client.web.server.parser; +package ch.systemsx.cisd.openbis.generic.shared.parser; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertFalse; @@ -31,6 +31,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleBatchUpdateDetails; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.UpdatedSample; +import ch.systemsx.cisd.openbis.generic.shared.parser.UpdatedSampleParserObjectFactory; /** * Test cases for corresponding {@link UpdatedSampleParserObjectFactory} class. diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/GenericClientServiceTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/GenericClientServiceTest.java index 4f82fb95a4207cd42a2904effe8f92341df7cf2a..768ef64e93d73eeccb86076ec5c502b454e67aa6 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/GenericClientServiceTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/GenericClientServiceTest.java @@ -37,11 +37,11 @@ import org.testng.annotations.Test; import ch.rinn.restrictions.Friend; import ch.systemsx.cisd.common.filesystem.FileUtilities; -import ch.systemsx.cisd.openbis.generic.client.web.client.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.client.web.server.AbstractClientServiceTest; import ch.systemsx.cisd.openbis.generic.client.web.server.UploadedFilesBean; import ch.systemsx.cisd.openbis.generic.shared.CommonTestUtils; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataTypeCode; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityProperty; diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java index 0a95c2b1939bed5aa11ff94c232815b5a1fd5e27..356a37d1dc94882c6292f87e819f9cc2f2d1bfcf 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java @@ -278,7 +278,7 @@ public final class GenericServerTest extends AbstractServerTestCase one(sampleTypeDAO).tryFindSampleTypeByCode(sampleTypePE.getCode()); will(returnValue(sampleTypePE)); - one(sampleTypeSlaveServerPlugin).registerSamples(SESSION, newSamples); + one(sampleTypeSlaveServerPlugin).registerSamples(SESSION, newSamples, null); } }); createServer().registerOrUpdateSamples(SESSION_TOKEN, samplesWithTypes); @@ -303,7 +303,7 @@ public final class GenericServerTest extends AbstractServerTestCase one(sampleTypeDAO).tryFindSampleTypeByCode(sampleTypePE.getCode()); will(returnValue(sampleTypePE)); - one(sampleTypeSlaveServerPlugin).registerSamples(SESSION, newSamples); + one(sampleTypeSlaveServerPlugin).registerSamples(SESSION, newSamples, null); } }); createServer().registerSamples(SESSION_TOKEN, samplesWithTypes); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/BatchMaterialRegistrationAndUpdate.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/BatchMaterialRegistrationAndUpdate.java index cd2b960f5032562ed73cab24c4392397ef8a0cac..017bf434ede95fed54719fbe77f6c0c240136600 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/BatchMaterialRegistrationAndUpdate.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/BatchMaterialRegistrationAndUpdate.java @@ -31,7 +31,6 @@ import javax.servlet.http.HttpSession; import org.springframework.mock.web.MockMultipartFile; import org.testng.annotations.Test; -import ch.systemsx.cisd.openbis.generic.client.web.client.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DisplayedOrSelectedIdHolderCriteria; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.GridRowModels; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ListMaterialDisplayCriteria; @@ -41,6 +40,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.server.UploadedFilesBean; import ch.systemsx.cisd.openbis.generic.shared.basic.GridRowModel; import ch.systemsx.cisd.openbis.generic.shared.basic.IEntityInformationHolderWithPermId; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Material; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.MaterialIdentifier; diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/plugin/generic/ExperimentRegistrationTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/plugin/generic/ExperimentRegistrationTest.java index bb568d323ad7df982a77d8ce846fdf0ee1849a4f..4e36e6a16b36447e0cf43d6aa158577640349321 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/plugin/generic/ExperimentRegistrationTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/plugin/generic/ExperimentRegistrationTest.java @@ -28,7 +28,6 @@ import java.util.List; import org.apache.commons.lang.StringEscapeUtils; import org.testng.annotations.Test; -import ch.systemsx.cisd.openbis.generic.client.web.client.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ListSampleDisplayCriteria; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ResultSetWithEntityTypes; import ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureException; @@ -36,6 +35,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.GridRowModel; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Attachment; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.AttachmentWithContent; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchRegistrationResult; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExperimentType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; diff --git a/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/BatchDataSetHandler.java b/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/BatchDataSetHandler.java index 6beea54423e831e947dc756e06e7427758320fc3..a6df4b6c6cedb8e15c7b3fcbacfbe4a7a7bd7fa9 100644 --- a/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/BatchDataSetHandler.java +++ b/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/BatchDataSetHandler.java @@ -16,8 +16,6 @@ package ch.systemsx.cisd.yeastx.etl; -import static ch.systemsx.cisd.yeastx.etl.ConstantsYeastX.ERROR_MARKER_FILE; - import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -34,6 +32,7 @@ import ch.systemsx.cisd.common.filesystem.FileUtilities; import ch.systemsx.cisd.common.mail.IMailClient; import ch.systemsx.cisd.common.mail.MailClient; import ch.systemsx.cisd.common.utilities.ExtendedProperties; +import ch.systemsx.cisd.etlserver.Constants; import ch.systemsx.cisd.etlserver.IDataSetHandler; import ch.systemsx.cisd.etlserver.utils.PreprocessingExecutor; import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService; @@ -94,8 +93,8 @@ public class BatchDataSetHandler implements IDataSetHandler return flushErrors(batchDir, mappingFile, log); } - return processDatasets(batchDir, log, mappingFile.tryGetMappings(), mappingFile - .getNotificationEmail()); + return processDatasets(batchDir, log, mappingFile.tryGetMappings(), + mappingFile.getNotificationEmail()); } private ArrayList<DataSetInformation> flushErrors(File batchDir, @@ -114,8 +113,8 @@ public class BatchDataSetHandler implements IDataSetHandler { String errorMsg = String.format("No datasets from '%s' directory can be processed because " - + "the try to acquire write access by openBIS has failed.", batchDir - .getName()); + + "the try to acquire write access by openBIS has failed.", + batchDir.getName()); log.error(errorMsg + " Try again after some time or contact your administrator."); log.adminError(errorMsg); } @@ -179,10 +178,9 @@ public class BatchDataSetHandler implements IDataSetHandler private void logUnknownMappings(Set<String> unknownMappings, LogUtils log) { String unknownFiles = CollectionUtils.abbreviate(unknownMappings, -1); - log - .error("There are following files mentioned in the mapping file which do not exist:\n" - + unknownFiles - + "\nBrowse the mapping file and check if you have not misspelled some file names."); + log.error("There are following files mentioned in the mapping file which do not exist:\n" + + unknownFiles + + "\nBrowse the mapping file and check if you have not misspelled some file names."); } private void logNonWritable(File file, LogUtils log) @@ -267,7 +265,7 @@ public class BatchDataSetHandler implements IDataSetHandler private static boolean errorMarkerFileExists(File batchDir) { - return new File(batchDir, ERROR_MARKER_FILE).isFile(); + return new File(batchDir, Constants.ERROR_MARKER_FILE).isFile(); } private static void cleanMappingFile(File batchDir, Set<String> processedFiles, LogUtils log) @@ -293,7 +291,7 @@ public class BatchDataSetHandler implements IDataSetHandler private static void touchErrorMarkerFile(File batchDir, LogUtils log) { - File errorMarkerFile = new File(batchDir, ERROR_MARKER_FILE); + File errorMarkerFile = new File(batchDir, Constants.ERROR_MARKER_FILE); if (errorMarkerFile.isFile()) { return; @@ -307,13 +305,11 @@ public class BatchDataSetHandler implements IDataSetHandler } if (ok == false) { - log - .adminError("Could not create an error marker file '%s'.", errorMarkerFile - .getPath()); + log.adminError("Could not create an error marker file '%s'.", errorMarkerFile.getPath()); } else { log.warning("Correct the errors and delete the '%s' file to start processing again.", - ERROR_MARKER_FILE); + Constants.ERROR_MARKER_FILE); } } @@ -349,8 +345,8 @@ public class BatchDataSetHandler implements IDataSetHandler if (ok == false) { LogUtils.adminWarn( - "The directory '%s' cannot be deleted although it seems to be empty.", dir - .getPath()); + "The directory '%s' cannot be deleted although it seems to be empty.", + dir.getPath()); } return ok; } diff --git a/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/ConstantsYeastX.java b/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/ConstantsYeastX.java index ceea820ce926a6f75fa05437b1529462f91e395b..4eb995b6de28dab8474c25f19a1caf6d44bb0ab0 100644 --- a/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/ConstantsYeastX.java +++ b/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/ConstantsYeastX.java @@ -21,10 +21,6 @@ package ch.systemsx.cisd.yeastx.etl; */ public class ConstantsYeastX { - public static final String ERROR_MARKER_FILE = "_delete_me_after_correcting_errors"; - - public static final String USER_LOG_FILE = "error-log.txt"; - public static final String FIAML_EXT = "fiaML"; public static final String EICML_EXT = "eicML"; diff --git a/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/LogUtils.java b/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/LogUtils.java index 188c98427847b48434615c65d240097aa480c59e..f354dc78c0c0fb5535a8971b7ed1d534e22f9892 100644 --- a/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/LogUtils.java +++ b/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/LogUtils.java @@ -29,6 +29,7 @@ import org.apache.log4j.Logger; import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogFactory; import ch.systemsx.cisd.common.mail.IMailClient; +import ch.systemsx.cisd.etlserver.Constants; /** * @author Tomasz Pylak @@ -208,7 +209,7 @@ class LogUtils private static File getUserLogFile(File loggingDir) { - return new File(loggingDir, ConstantsYeastX.USER_LOG_FILE); + return new File(loggingDir, Constants.USER_LOG_FILE); } public void adminError(String messageFormat, Object... arguments) @@ -233,7 +234,7 @@ class LogUtils public static boolean isUserLog(File file) { - return file.getName().equals(ConstantsYeastX.USER_LOG_FILE); + return file.getName().equals(Constants.USER_LOG_FILE); } public static boolean deleteUserLog(File loggingDir) diff --git a/rtd_yeastx/sourceTest/java/ch/systemsx/cisd/yeastx/etl/DataSetInformationParserTest.java b/rtd_yeastx/sourceTest/java/ch/systemsx/cisd/yeastx/etl/DataSetInformationParserTest.java index d056bea5afad0fe6741bb04b3c130f9512afb1e1..d82fb4095520346988c56f7f69f393042b10d682 100644 --- a/rtd_yeastx/sourceTest/java/ch/systemsx/cisd/yeastx/etl/DataSetInformationParserTest.java +++ b/rtd_yeastx/sourceTest/java/ch/systemsx/cisd/yeastx/etl/DataSetInformationParserTest.java @@ -29,6 +29,7 @@ import org.testng.annotations.Test; import ch.systemsx.cisd.base.tests.AbstractFileSystemTestCase; import ch.systemsx.cisd.common.filesystem.FileUtilities; import ch.systemsx.cisd.common.test.AssertionUtil; +import ch.systemsx.cisd.etlserver.Constants; import ch.systemsx.cisd.openbis.generic.shared.dto.NewProperty; /** @@ -111,7 +112,7 @@ public class DataSetInformationParserTest extends AbstractFileSystemTestCase private List<String> readLogFile() throws IOException, FileNotFoundException { - File log = new File(workingDirectory, ConstantsYeastX.USER_LOG_FILE); + File log = new File(workingDirectory, Constants.USER_LOG_FILE); List<String> logLines = readLines(log); return logLines; } diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/LibraryExtractor.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/LibraryExtractor.java index 0c59e69802f5ae4de4cb4ad908e2616a6e61b572..3001cfc0f386fa42e33e16d1c29df426120b45ee 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/LibraryExtractor.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/LibraryExtractor.java @@ -10,14 +10,14 @@ import java.util.List; import ch.systemsx.cisd.common.exceptions.Status; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.filesystem.FileOperations; -import ch.systemsx.cisd.openbis.generic.client.web.server.NamedInputStream; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BatchOperationKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewMaterial; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSamplesWithTypes; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; +import ch.systemsx.cisd.openbis.generic.shared.parser.NamedInputStream; +import ch.systemsx.cisd.openbis.generic.shared.parser.SampleUploadSectionsParser; +import ch.systemsx.cisd.openbis.generic.shared.parser.SampleUploadSectionsParser.BatchSamplesOperation; import ch.systemsx.cisd.openbis.plugin.generic.client.web.server.MaterialLoader; -import ch.systemsx.cisd.openbis.plugin.generic.client.web.server.parser.SampleUploadSectionsParser; -import ch.systemsx.cisd.openbis.plugin.generic.client.web.server.parser.SampleUploadSectionsParser.BatchSamplesOperation; import ch.systemsx.cisd.openbis.plugin.screening.client.web.server.library_tools.ScreeningLibraryTransformer; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.LibraryRegistrationInfo.RegistrationScope;