From cefd90c8ecb222be79fe80f80a45596313ab519b Mon Sep 17 00:00:00 2001 From: gakin <gakin> Date: Tue, 6 Jun 2017 08:02:35 +0000 Subject: [PATCH] SSDM-5162 Correct code formatting SVN: 38252 --- .../synchronizer/EntitySynchronizer.java | 131 ++- .../synchronizer/ISynchronizerFacade.java | 62 +- .../synchronizer/MasterDataSynchronizer.java | 76 +- .../synchronizer/SynchronizerFacade.java | 744 ++++++++++-------- 4 files changed, 552 insertions(+), 461 deletions(-) diff --git a/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/EntitySynchronizer.java b/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/EntitySynchronizer.java index 57dfde51275..2780f83fda1 100644 --- a/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/EntitySynchronizer.java +++ b/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/EntitySynchronizer.java @@ -283,7 +283,7 @@ public class EntitySynchronizer { verboseLogPhysicalDataSetRegistrations(physicalDSMap); } - + List<String> notRegisteredDataSetCodes = new ArrayList<>(); if (config.isDryRun() == false) { @@ -294,8 +294,8 @@ public class EntitySynchronizer notRegisteredDataSetCodes = dsRegistrationSummary.notRegisteredDataSetCodes; operationLog.info("Data set synchronization summary:\n" + dsRegistrationSummary.addedDsCount + " data set(s) were added.\n" - + dsRegistrationSummary.updatedDsCount - + " data set(s) were updated.\n" + + dsRegistrationSummary.updatedDsCount + + " data set(s) were updated.\n" + notRegisteredDataSetCodes.size() + " data set(s) FAILED to register.\n" + blackListedDataSetCodes.size() + " data set(s)" @@ -381,10 +381,12 @@ public class EntitySynchronizer } } } + private void verboseLogEntityOperations(AtomicEntityOperationDetails details) { List<NewSpace> spaceRegistrations = details.getSpaceRegistrations(); - if(spaceRegistrations.size() > 0) { + if (spaceRegistrations.size() > 0) + { operationLog.info("-------The following spaces will be created------- "); for (NewSpace newSpace : spaceRegistrations) { @@ -428,7 +430,8 @@ public class EntitySynchronizer private void verboseLogSampleUpdates(List<SampleUpdatesDTO> sampleUpdates) { - if (sampleUpdates.isEmpty() == false) { + if (sampleUpdates.isEmpty() == false) + { operationLog.info("-------The following samples will be updated-------"); for (SampleUpdatesDTO dto : sampleUpdates) { @@ -470,12 +473,10 @@ public class EntitySynchronizer if (identifier instanceof NewSample) { entityKind = SyncEntityKind.SAMPLE.getLabel(); - } - else if (identifier instanceof NewExperiment) + } else if (identifier instanceof NewExperiment) { entityKind = SyncEntityKind.EXPERIMENT.getLabel(); - } - else if (identifier instanceof NewExperiment) + } else if (identifier instanceof NewExperiment) { entityKind = SyncEntityKind.PROJECT.getLabel(); } @@ -537,8 +538,7 @@ public class EntitySynchronizer parentDataSetCodes.add(dataSet.getCode()); dsToParents.put(childDataSet.getCode(), new HashSet<String>(parentDataSetCodes)); } - } - else if (dataSetsToProcess.containsKey(conn.getToPermId()) && conn.getType().equals("Component")) + } else if (dataSetsToProcess.containsKey(conn.getToPermId()) && conn.getType().equals("Component")) { NewExternalData componentDataSet = dataSetsToProcess.get(conn.getToPermId()).getDataSet(); if (skippedDataSets.contains(componentDataSet.getCode()) == false) @@ -565,8 +565,7 @@ public class EntitySynchronizer if (physicalDSMap.containsKey(dataSet.getCode()) == false && service.tryGetDataSet(dataSet.getCode()) == null) { builder.dataSet(dataSet); - } - else + } else { datasetsToUpdate.put(dataSet.getCode(), dataSet); } @@ -597,10 +596,9 @@ public class EntitySynchronizer NewContainerDataSet containerDS = (NewContainerDataSet) dataSet; if (dsToContained.containsKey(containerDS.getCode())) { - dsBatchUpdatesDTO.setModifiedContainedDatasetCodesOrNull(dsToContained.get(dataSet.getCode()).toArray(new - String[containerDS.getContainedDataSetCodes().size()])); - } - else + dsBatchUpdatesDTO.setModifiedContainedDatasetCodesOrNull( + dsToContained.get(dataSet.getCode()).toArray(new String[containerDS.getContainedDataSetCodes().size()])); + } else { dsBatchUpdatesDTO.setModifiedContainedDatasetCodesOrNull(new String[0]); } @@ -611,8 +609,7 @@ public class EntitySynchronizer dsBatchUpdatesDTO.setModifiedParentDatasetCodesOrNull(dsToParents.get(dataSet.getCode()).toArray( new String[dataSet.getParentDataSetCodes().size()])); // TODO should this always be true or should we flag the ones that require parent update. Same for container - } - else + } else { dsBatchUpdatesDTO.setModifiedParentDatasetCodesOrNull(new String[0]); } @@ -623,8 +620,7 @@ public class EntitySynchronizer Sample sampleWithExperiment = service.tryGetSampleWithExperiment(sampleIdentifier); dsBatchUpdatesDTO.setSampleIdentifierOrNull(SampleIdentifierFactory.parse(sampleWithExperiment.getIdentifier())); dsBatchUpdatesDTO.getDetails().setSampleUpdateRequested(true); - } - else + } else { dsBatchUpdatesDTO.setSampleIdentifierOrNull(null); dsBatchUpdatesDTO.getDetails().setSampleUpdateRequested(true); @@ -636,16 +632,16 @@ public class EntitySynchronizer Experiment experiment = service.tryGetExperiment(expIdentifier); dsBatchUpdatesDTO.setExperimentIdentifierOrNull(ExperimentIdentifierFactory.parse(experiment.getIdentifier())); dsBatchUpdatesDTO.getDetails().setExperimentUpdateRequested(true); - } - else + } else { dsBatchUpdatesDTO.setExperimentIdentifierOrNull(null); dsBatchUpdatesDTO.getDetails().setExperimentUpdateRequested(true); } builder.dataSetUpdate(dsBatchUpdatesDTO); } - - if (config.isVerbose()) { + + if (config.isVerbose()) + { verboseLogDataSetUpdateOperation(builder.getDetails().getDataSetUpdates()); } if (config.isDryRun()) @@ -737,16 +733,16 @@ public class EntitySynchronizer { if (config.isVerbose() == true) { -// operationLog.info("-------The following master data will be synchronized-------"); -// verboseLogMasterData(masterData.getFileFormatTypesToProcess().keySet(), "File Formats"); -// verboseLogMasterData(masterData.getValidationPluginsToProcess().keySet(), "Validation Plugins"); -// verboseLogMasterData(masterData.getValidationPluginsToProcess().keySet(), "Validation Plugins"); -// verboseLogMasterData(masterData.getVocabulariesToProcess().keySet(), "Controlled Vocabularies"); -// verboseLogMasterData(masterData.getMaterialTypesToProcess().keySet(), "Material Types"); -// verboseLogMasterData(masterData.getSampleTypesToProcess().keySet(), "Sample Types"); -// verboseLogMasterData(masterData.getExperimentTypesToProcess().keySet(), "Experiment Types"); -// verboseLogMasterData(masterData.getDataSetTypesToProcess().keySet(), "Data set Types"); -// verboseLogMasterData(masterData.getPropertyTypesToProcess().keySet(), "Property Types"); + // operationLog.info("-------The following master data will be synchronized-------"); + // verboseLogMasterData(masterData.getFileFormatTypesToProcess().keySet(), "File Formats"); + // verboseLogMasterData(masterData.getValidationPluginsToProcess().keySet(), "Validation Plugins"); + // verboseLogMasterData(masterData.getValidationPluginsToProcess().keySet(), "Validation Plugins"); + // verboseLogMasterData(masterData.getVocabulariesToProcess().keySet(), "Controlled Vocabularies"); + // verboseLogMasterData(masterData.getMaterialTypesToProcess().keySet(), "Material Types"); + // verboseLogMasterData(masterData.getSampleTypesToProcess().keySet(), "Sample Types"); + // verboseLogMasterData(masterData.getExperimentTypesToProcess().keySet(), "Experiment Types"); + // verboseLogMasterData(masterData.getDataSetTypesToProcess().keySet(), "Data set Types"); + // verboseLogMasterData(masterData.getPropertyTypesToProcess().keySet(), "Property Types"); } MasterDataSynchronizer masterDataSyncronizer = new MasterDataSynchronizer(config.getHarvesterUser(), config.getHarvesterPass(), config.isDryRun(), operationLog); @@ -803,15 +799,13 @@ public class EntitySynchronizer ProjectPermId projectPermId = new ProjectPermId(permId); projectsToDelete.put(projectPermId, identifier); } - } - else if (entity.getEntityKind().equals(SyncEntityKind.EXPERIMENT.getLabel())) + } else if (entity.getEntityKind().equals(SyncEntityKind.EXPERIMENT.getLabel())) { ExperimentPermId experimentPermId = new ExperimentPermId(permId); if (incomingExperimentPermIds.contains(permId) == false) { experimentsToDelete.put(experimentPermId, identifier); - } - else + } else { NewExperiment exp = data.getExperimentsToProcess().get(permId).getExperiment(); if (typeCodeOrNull.equals(exp.getExperimentTypeCode()) == false) @@ -819,15 +813,13 @@ public class EntitySynchronizer experimentsToDelete.put(experimentPermId, identifier); } } - } - else if (entity.getEntityKind().equals(SyncEntityKind.SAMPLE.getLabel())) + } else if (entity.getEntityKind().equals(SyncEntityKind.SAMPLE.getLabel())) { SamplePermId samplePermId = new SamplePermId(permId); if (incomingSamplePermIds.contains(permId) == false) { samplesToDelete.put(samplePermId, identifier); - } - else + } else { NewSample smp = data.getSamplesToProcess().get(permId).getSample(); if (typeCodeOrNull.equals(smp.getSampleType().getCode()) == false) @@ -835,15 +827,13 @@ public class EntitySynchronizer samplesToDelete.put(samplePermId, identifier); } } - } - else if (entity.getEntityKind().equals(SyncEntityKind.DATA_SET.getLabel())) + } else if (entity.getEntityKind().equals(SyncEntityKind.DATA_SET.getLabel())) { DataSetPermId dataSetPermId = new DataSetPermId(permId); if (incomingDataSetCodes.contains(permId) == false) { dataSetsToDelete.put(dataSetPermId, dataSetPermId.getPermId()); - } - else + } else { boolean sameDS = true; IncomingDataSet dsWithConns = data.getDataSetsToProcess().get(permId); @@ -851,8 +841,7 @@ public class EntitySynchronizer if (typeCodeOrNull.equals(ds.getDataSetType().getCode()) == false) { sameDS = false; - } - else + } else { if (dsWithConns.getKind() == DataSetKind.PHYSICAL && dsWithConns.getLastModificationDate().after(lastIncSyncTimestamp)) { @@ -887,13 +876,14 @@ public class EntitySynchronizer operationLog.info("-------Processing deletions-------"); if (config.isVerbose() == true) { - if(dataSetsToDelete.isEmpty() == false - || samplesToDelete.isEmpty() == false + if (dataSetsToDelete.isEmpty() == false + || samplesToDelete.isEmpty() == false || experimentsToDelete.isEmpty() == false || projectsToDelete.isEmpty() == false - || materialsToDelete.isEmpty() == false) { - operationLog.info("!!!!!!!!!!!!!The following will be PERMAMENTLY removed from openbis!!!!!!!!!!!!!"); - } + || materialsToDelete.isEmpty() == false) + { + operationLog.info("!!!!!!!!!!!!!The following will be PERMAMENTLY removed from openbis!!!!!!!!!!!!!"); + } verboseLogDeletions(dataSetsToDelete.values(), "data sets"); verboseLogDeletions(samplesToDelete.values(), "samples"); verboseLogDeletions(experimentsToDelete.values(), "experiments"); @@ -947,7 +937,7 @@ public class EntitySynchronizer { operationLog.warn("One or more materials could not be deleted due to: " + e.getMessage()); } - + // The following summary is not accurate if an error occurs in material deletions StringBuffer summary = new StringBuffer(); if (projectsToDelete.size() > 0) @@ -973,8 +963,7 @@ public class EntitySynchronizer if (summary.length() > 0) { operationLog.info(summary.substring(0, summary.length() - 1) + " have been deleted:"); - } - else + } else { operationLog.info("Nothing has been deleted:"); } @@ -1024,8 +1013,7 @@ public class EntitySynchronizer { // ADD EXPERIMENT builder.experiment(incomingExp); - } - else + } else { // UPDATE EXPERIMENT ExperimentUpdatesDTO expUpdate = createExperimentUpdateDTOs(incomingExp, experiment); @@ -1085,8 +1073,7 @@ public class EntitySynchronizer if (material == null) { builder.material(incomingMaterial); - } - else + } else { List<IEntityProperty> newPropList = prepareUpdatedPropertyList(incomingMaterial.getProperties(), material.getProperties()); @@ -1121,8 +1108,7 @@ public class EntitySynchronizer { // ADD PROJECT builder.project(incomingProject); - } - else + } else { // UPDATE PROJECT builder.projectUpdate(createProjectUpdateDTO(incomingProject, project)); @@ -1155,8 +1141,7 @@ public class EntitySynchronizer newExp.setIdentifier(prj.getProject().getIdentifier() + "/" + expCode); // add new experiment node } - } - else + } else { // This means the XML contains the connection but not the connected entity. // This is an unlikely scenario. @@ -1204,8 +1189,7 @@ public class EntitySynchronizer { // ADD SAMPLE builder.sample(incomingSample); - } - else + } else { // defer creation of sample update objects until all samples have been gone through; samplesToUpdate.put(sampleIdentifier, incomingSample); @@ -1217,8 +1201,7 @@ public class EntitySynchronizer if (childSampleWithConns == null) { // TODO Handle sample delete - } - else + } else { // the childSample will appear in the incoming samples list anyway // but we want to make sure its parent modification is handled @@ -1234,8 +1217,7 @@ public class EntitySynchronizer { NewSample containedSample = samplesToProcess.get(conn.getToPermId()).getSample(); containedSample.setContainerIdentifier(incomingSample.getIdentifier()); - } - else if (conn.getType().equals("Child")) + } else if (conn.getType().equals("Child")) { NewSample childSample = samplesToProcess.get(conn.getToPermId()).getSample(); String[] parents = childSample.getParentsOrNull(); @@ -1243,8 +1225,7 @@ public class EntitySynchronizer if (parents == null) { parentIds = new ArrayList<String>(); - } - else + } else { parentIds = new ArrayList<String>(Arrays.asList(parents)); } @@ -1434,8 +1415,8 @@ public class EntitySynchronizer private DataSetBatchUpdatesDTO createDataSetBatchUpdateDTO(NewExternalData dataSet, AbstractExternalData dsInHarvester) { - ch.systemsx.cisd.etlserver.registrator.api.v1.impl.DataSetUpdatable updateUpdatable = new - ch.systemsx.cisd.etlserver.registrator.api.v1.impl.DataSetUpdatable(dsInHarvester, service); + ch.systemsx.cisd.etlserver.registrator.api.v1.impl.DataSetUpdatable updateUpdatable = + new ch.systemsx.cisd.etlserver.registrator.api.v1.impl.DataSetUpdatable(dsInHarvester, service); DataSetBatchUpdatesDTO dsBatchUpdatesDTO = ConversionUtils.convertToDataSetBatchUpdatesDTO(updateUpdatable); dsBatchUpdatesDTO.setDatasetId(TechId.create(dsInHarvester)); diff --git a/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/ISynchronizerFacade.java b/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/ISynchronizerFacade.java index bdf88ea0038..125f636f539 100644 --- a/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/ISynchronizerFacade.java +++ b/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/ISynchronizerFacade.java @@ -1,3 +1,18 @@ +/* Copyright 2016 ETH Zuerich, SIS + * + * 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.ethz.sis.openbis.generic.server.dss.plugins.sync.harvester.synchronizer; import java.util.List; @@ -19,45 +34,56 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Vocabulary; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.VocabularyTerm; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.VocabularyTermReplacement; -public interface ISynchronizerFacade { - public void updateFileFormatType(AbstractType type); - - public void registerFileFormatType(FileFormatType type); - +/** + * @author Ganime Betul Akin + */ + +public interface ISynchronizerFacade +{ + public void updateFileFormatType(AbstractType type); + + public void registerFileFormatType(FileFormatType type); + public void updatePropertyTypeAssignment(NewETPTAssignment newETPTAssignment); public void assignPropertyType(NewETPTAssignment newETPTAssignment); - + public void unassignPropertyType(EntityKind entityKind, String propertyTypeCode, String entityTypeCode); - + public void updatePropertyType(PropertyType propertyType); + public void registerPropertyType(PropertyType propertyType); + public void updateValidationPlugin(Script script); + public void registerValidationPlugin(Script script); public void registerVocabulary(NewVocabulary vocab); public void updateVocabulary(Vocabulary vocab); - + public void registerSampleType(SampleType sampleType); + public void registerDataSetType(DataSetType dataSetType); + public void registerExperimentType(ExperimentType experimentType); + public void registerMaterialType(MaterialType materialType); - public void updateVocabularyTerm(VocabularyTerm term); + public void updateVocabularyTerm(VocabularyTerm term); + + public void updateSampleType(EntityType incomingEntityType); - public void updateSampleType(EntityType incomingEntityType); + public void updateDataSetType(EntityType incomingEntityType); - public void updateDataSetType(EntityType incomingEntityType); + public void updateExperimentType(EntityType incomingEntityType); - public void updateExperimentType(EntityType incomingEntityType); + public void updateMaterialType(EntityType incomingEntityType); - public void updateMaterialType(EntityType incomingEntityType); + public void addVocabularyTerms(String code, TechId techId, List<VocabularyTerm> termsToBeAdded); - public void addVocabularyTerms(String code, TechId techId, List<VocabularyTerm> termsToBeAdded); + public void deleteVocabularyTerms(TechId vocabularyId, String code, List<VocabularyTerm> list, + List<VocabularyTermReplacement> emptyList); - public void deleteVocabularyTerms(TechId vocabularyId, String code, List<VocabularyTerm> list, - List<VocabularyTermReplacement> emptyList); - - public void printSummary(); + public void printSummary(); } diff --git a/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/MasterDataSynchronizer.java b/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/MasterDataSynchronizer.java index c74251acf88..d1a2e6efd81 100644 --- a/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/MasterDataSynchronizer.java +++ b/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/MasterDataSynchronizer.java @@ -47,18 +47,20 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Vocabulary; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.VocabularyTerm; /** - * - * * @author Ganime Betul Akin */ public class MasterDataSynchronizer { - final ISynchronizerFacade synchronizerFacade; - final ICommonServer commonServer; - final String sessionToken; - final boolean dryRun; + final ISynchronizerFacade synchronizerFacade; + + final ICommonServer commonServer; + + final String sessionToken; + + final boolean dryRun; final Map<TechId, List<VocabularyTerm>> vocabularyTermsToBeDeleted; + final Map<TechId, String> vocabularyTechIdToCode = new HashMap<TechId, String>(); public MasterDataSynchronizer(String harvesterUser, String harvesterPassword, boolean dryRun, Logger operationLog) @@ -70,8 +72,9 @@ public class MasterDataSynchronizer this.sessionToken = ServiceFinderUtils.login(commonServer, harvesterUser, harvesterPassword); vocabularyTermsToBeDeleted = new HashMap<TechId, List<VocabularyTerm>>(); } - - public void synchronizeMasterData(ResourceListParserData.MasterData masterData) { + + public void synchronizeMasterData(ResourceListParserData.MasterData masterData) + { MultiKeyMap<String, List<NewETPTAssignment>> propertyAssignmentsToProcess = masterData.getPropertyAssignmentsToProcess(); processFileFormatTypes(masterData.getFileFormatTypesToProcess()); processValidationPlugins(masterData.getValidationPluginsToProcess()); @@ -83,7 +86,7 @@ public class MasterDataSynchronizer processEntityTypes(masterData.getDataSetTypesToProcess(), propertyAssignmentsToProcess); processEntityTypes(masterData.getExperimentTypesToProcess(), propertyAssignmentsToProcess); processDeferredMaterialTypePropertyAssignments(propertyAssignmentsToProcess); - + synchronizerFacade.printSummary(); } @@ -91,7 +94,8 @@ public class MasterDataSynchronizer { for (TechId vocabularyId : vocabularyTermsToBeDeleted.keySet()) { - synchronizerFacade.deleteVocabularyTerms(vocabularyId, vocabularyTechIdToCode.get(vocabularyId), vocabularyTermsToBeDeleted.get(vocabularyId), + synchronizerFacade.deleteVocabularyTerms(vocabularyId, vocabularyTechIdToCode.get(vocabularyId), + vocabularyTermsToBeDeleted.get(vocabularyId), Collections.<ch.systemsx.cisd.openbis.generic.shared.basic.dto.VocabularyTermReplacement> emptyList()); } } @@ -128,14 +132,13 @@ public class MasterDataSynchronizer existingPluginOrNull.setScript(incomingplugin.getScript()); existingPluginOrNull.setDescription(incomingplugin.getDescription()); synchronizerFacade.updateValidationPlugin(existingPluginOrNull); - } - else + } else { synchronizerFacade.registerValidationPlugin(incomingplugin); } } } - + private void processFileFormatTypes(Map<String, FileFormatType> fileFormatTypesToProcess) { List<FileFormatType> fileFormatTypes = commonServer.listFileFormatTypes(sessionToken); @@ -153,10 +156,9 @@ public class MasterDataSynchronizer { existingTypeOrNull.setDescription(incomingType.getDescription()); synchronizerFacade.updateFileFormatType(existingTypeOrNull); - } - else + } else { - synchronizerFacade.registerFileFormatType(incomingType); + synchronizerFacade.registerFileFormatType(incomingType); } } } @@ -184,8 +186,7 @@ public class MasterDataSynchronizer existingVocabulary.setChosenFromList(newVocabulary.isChosenFromList()); synchronizerFacade.updateVocabulary(existingVocabulary); processVocabularyTerms(sessionToken, commonServer, newVocabulary, existingVocabulary); - } - else + } else { synchronizerFacade.registerVocabulary(newVocabulary); } @@ -200,7 +201,7 @@ public class MasterDataSynchronizer { incomingTermMap.put(term.getCode(), term); } - + List<VocabularyTerm> termsToBeAdded = new ArrayList<VocabularyTerm>(); List<VocabularyTerm> termsToBeUpdated = new ArrayList<VocabularyTerm>(); for (VocabularyTerm incomingTerm : incomingTerms) @@ -210,8 +211,7 @@ public class MasterDataSynchronizer if (existingTerm == null) { termsToBeAdded.add(incomingTerm); - } - else + } else { existingTerm.setLabel(incomingTerm.getLabel()); existingTerm.setDescription(incomingTerm.getDescription()); @@ -253,7 +253,7 @@ public class MasterDataSynchronizer } return null; } - + private void processEntityTypes(Map<String, ? extends EntityType> entityTypesToProcess, MultiKeyMap<String, List<NewETPTAssignment>> propertyAssignmentsToProcess) { @@ -276,15 +276,14 @@ public class MasterDataSynchronizer if (existingEntityType != null) { updateEntityType(entityKind, incomingEntityType); -// existingEntityType.setCode(incomingEntityType.getCode()); -// existingEntityType.setDescription(incomingEntityType.getDescription()); -// existingEntityType.setValidationScript(incomingEntityType.getValidationScript()); + // existingEntityType.setCode(incomingEntityType.getCode()); + // existingEntityType.setDescription(incomingEntityType.getDescription()); + // existingEntityType.setValidationScript(incomingEntityType.getValidationScript()); if (list != null && entityKind != EntityKind.MATERIAL) // defer material property assignments until after property types are processed { processPropertyAssignments(existingEntityType, list); } - } - else + } else { registerEntityType(entityKind, incomingEntityType); if (list != null && entityKind != EntityKind.MATERIAL) // defer material property assignments until after property types are processed @@ -315,8 +314,7 @@ public class MasterDataSynchronizer if (found) { synchronizerFacade.updatePropertyTypeAssignment(newETPTAssignment); - } - else + } else { synchronizerFacade.assignPropertyType(newETPTAssignment); } @@ -367,13 +365,13 @@ public class MasterDataSynchronizer synchronizerFacade.registerSampleType((SampleType) incomingEntityType); break; case DATA_SET: - synchronizerFacade.registerDataSetType((DataSetType) incomingEntityType); + synchronizerFacade.registerDataSetType((DataSetType) incomingEntityType); break; case EXPERIMENT: - synchronizerFacade.registerExperimentType((ExperimentType) incomingEntityType); + synchronizerFacade.registerExperimentType((ExperimentType) incomingEntityType); break; case MATERIAL: - synchronizerFacade.registerMaterialType((MaterialType) incomingEntityType); + synchronizerFacade.registerMaterialType((MaterialType) incomingEntityType); break; default: throw new UserFailureException("register not implemented for entity kind: " + entityKind.name()); @@ -385,16 +383,16 @@ public class MasterDataSynchronizer switch (entityKind) { case SAMPLE: - synchronizerFacade.updateSampleType(incomingEntityType); + synchronizerFacade.updateSampleType(incomingEntityType); break; case DATA_SET: synchronizerFacade.updateDataSetType(incomingEntityType); break; case EXPERIMENT: - synchronizerFacade.updateExperimentType(incomingEntityType); + synchronizerFacade.updateExperimentType(incomingEntityType); break; case MATERIAL: - synchronizerFacade.updateMaterialType(incomingEntityType); + synchronizerFacade.updateMaterialType(incomingEntityType); break; default: throw new UserFailureException("update not implemented for entity kind: " + entityKind.name()); @@ -403,7 +401,8 @@ public class MasterDataSynchronizer private List<? extends EntityType> getExistingEntityTypes(EntityKind entityKind) { - switch (entityKind) { + switch (entityKind) + { case SAMPLE: return commonServer.listSampleTypes(sessionToken); case DATA_SET: @@ -436,10 +435,9 @@ public class MasterDataSynchronizer propertyTypeOrNull.setLabel(incomingPropertyType.getLabel()); propertyTypeOrNull.setDescription(incomingPropertyType.getDescription()); synchronizerFacade.updatePropertyType(propertyTypeOrNull); - } - else + } else { - synchronizerFacade.registerPropertyType(incomingPropertyType); + synchronizerFacade.registerPropertyType(incomingPropertyType); } } } diff --git a/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/SynchronizerFacade.java b/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/SynchronizerFacade.java index 3cbae4059fc..4778bbd0db3 100644 --- a/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/SynchronizerFacade.java +++ b/datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/synchronizer/SynchronizerFacade.java @@ -1,3 +1,17 @@ +/* Copyright 2016 ETH Zuerich, SIS + * + * 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.ethz.sis.openbis.generic.server.dss.plugins.sync.harvester.synchronizer; import java.util.HashMap; @@ -6,7 +20,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.apache.commons.collections4.map.MultiKeyMap; import org.apache.log4j.Logger; import ch.ethz.sis.openbis.generic.server.dss.plugins.sync.common.ServiceFinderUtils; @@ -28,372 +41,445 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Vocabulary; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.VocabularyTerm; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.VocabularyTermReplacement; -public class SynchronizerFacade implements ISynchronizerFacade { - private static final String INFO_MESSAGE = "The following %s will be %s"; +/** + * @author Ganime Betul Akin + */ - private static final Object separatorStr = "---------------------"; +public class SynchronizerFacade implements ISynchronizerFacade +{ + private static final String INFO_MESSAGE = "The following %s will be %s"; - final String sessionToken; + private static final Object separatorStr = "---------------------"; + + final String sessionToken; final ICommonServer commonServer; - + final Logger operationLog; - - Map<String,String> fileformatTypesToUpdate = new HashMap<String, String>(); + + Map<String, String> fileformatTypesToUpdate = new HashMap<String, String>(); + Set<String> fileformatTypesToAdd = new HashSet<String>(); - + Set<NewETPTAssignment> propertyAssignmentsToUpdate = new HashSet<>(); + Set<NewETPTAssignment> propertyAssignmentsToAdd = new HashSet<>(); + Map<String, String> propertyAssignmentsToBreak = new HashMap<String, String>(); Map<String, String> propertyTypesToUpdate = new HashMap<String, String>(); + Set<String> propertyTypesToAdd = new HashSet<String>(); Map<String, String> validationPluginsToUpdate = new HashMap<String, String>(); + Set<String> validationPluginsToAdd = new HashSet<String>(); final boolean dryRun; - Set<String> vocabulariesToAdd = new HashSet<String>(); - Map<String, String> vocabulariesToUpdate = new HashMap<String, String>(); + Set<String> vocabulariesToAdd = new HashSet<String>(); + + Map<String, String> vocabulariesToUpdate = new HashMap<String, String>(); - Map<String, List<VocabularyTerm>> vocabularyTermsToDelete = new HashMap<String, List<VocabularyTerm>>(); - Map<String, String> vocabularyTermsToUpdate = new HashMap<String, String>(); - Map<String, List<VocabularyTerm>> vocabularyTermsToAdd = new HashMap<String, List<VocabularyTerm>>(); + Map<String, List<VocabularyTerm>> vocabularyTermsToDelete = new HashMap<String, List<VocabularyTerm>>(); - Set<String> sampleTypesToAdd = new HashSet<String>(); - Set<String> experimentTypesToAdd = new HashSet<String>(); - Set<String> dataSetTypesToAdd = new HashSet<String>(); - Set<String> materialTypesToAdd = new HashSet<String>(); + Map<String, String> vocabularyTermsToUpdate = new HashMap<String, String>(); - Map<String, String> sampleTypesToUpdate = new HashMap<String, String>(); - Map<String, String> experimentTypesToUpdate = new HashMap<String, String>(); - Map<String, String> dataSetTypesToUpdate = new HashMap<String, String>(); - Map<String, String> materialTypesToUpdate = new HashMap<String, String>(); + Map<String, List<VocabularyTerm>> vocabularyTermsToAdd = new HashMap<String, List<VocabularyTerm>>(); - public SynchronizerFacade(String openBisServerUrl, String harvesterUser, String harvesterPassword, boolean dryRun, Logger operationLog) { + Set<String> sampleTypesToAdd = new HashSet<String>(); + + Set<String> experimentTypesToAdd = new HashSet<String>(); + + Set<String> dataSetTypesToAdd = new HashSet<String>(); + + Set<String> materialTypesToAdd = new HashSet<String>(); + + Map<String, String> sampleTypesToUpdate = new HashMap<String, String>(); + + Map<String, String> experimentTypesToUpdate = new HashMap<String, String>(); + + Map<String, String> dataSetTypesToUpdate = new HashMap<String, String>(); + + Map<String, String> materialTypesToUpdate = new HashMap<String, String>(); + + public SynchronizerFacade(String openBisServerUrl, String harvesterUser, String harvesterPassword, boolean dryRun, Logger operationLog) + { this.commonServer = ServiceFinderUtils.getCommonServer(openBisServerUrl); this.sessionToken = ServiceFinderUtils.login(commonServer, harvesterUser, harvesterPassword); this.dryRun = dryRun; this.operationLog = operationLog; } - @Override - public void updateFileFormatType(AbstractType type) { - if(dryRun) { - String change = "Description :" + type.getDescription(); - fileformatTypesToUpdate.put(type.getCode(), change); - } - else { - commonServer.updateFileFormatType(sessionToken, type); - } - } - - @Override - public void registerFileFormatType(FileFormatType type) { - if(dryRun) { - fileformatTypesToAdd.add(type.getCode()); - } - else { - commonServer.registerFileFormatType(sessionToken, type); - } - } - - @Override - public void updatePropertyTypeAssignment(NewETPTAssignment newETPTAssignment) { - if(dryRun) { - propertyAssignmentsToUpdate.add(newETPTAssignment); - } - else { - commonServer.updatePropertyTypeAssignment(sessionToken, newETPTAssignment); - } - } - - @Override - public void assignPropertyType(NewETPTAssignment newETPTAssignment) { - if(dryRun) { - propertyAssignmentsToAdd.add(newETPTAssignment); - } - else { - commonServer.assignPropertyType(sessionToken, newETPTAssignment); - } - } - - @Override - public void unassignPropertyType(EntityKind entityKind, String propertyTypeCode, String entityTypeCode) { - if(dryRun) { - propertyAssignmentsToBreak.put(entityTypeCode + "(" + entityKind.name() + ")", propertyTypeCode); - } - else { - commonServer.unassignPropertyType(sessionToken, entityKind, propertyTypeCode, entityTypeCode); - } - } - - @Override - public void updatePropertyType(PropertyType propertyType) { - if(dryRun) { - String change = "Label :" + propertyType.getLabel() + " , description :" + propertyType.getDescription(); - propertyTypesToUpdate.put(propertyType.getCode(), change); - } - else { - commonServer.updatePropertyType(sessionToken, propertyType); - } - } - - @Override - public void registerPropertyType(PropertyType propertyType) { - if (dryRun) { - propertyTypesToAdd.add(propertyType.getCode()); - } - else { - commonServer.registerPropertyType(sessionToken, propertyType); - } - } - - @Override - public void updateValidationPlugin(Script script) { - if (dryRun) {//"Name :" + script.getName() + ", - String change = "Description :" + script.getDescription() + ", script :" + script.getScript(); - validationPluginsToUpdate.put(script.getName(), change); - } - else { - commonServer.updateScript(sessionToken, script); - } - } - - @Override - public void registerValidationPlugin(Script script) { - if (dryRun) { - validationPluginsToAdd.add(script.getName()); - } - else { - commonServer.registerScript(sessionToken, script); - } - } - - @Override - public void registerVocabulary(NewVocabulary vocab) { - if(dryRun == true) { - vocabulariesToAdd.add(vocab.getCode()); - } - else { - commonServer.registerVocabulary(sessionToken, vocab); - } - } - - - @Override - public void updateVocabulary(Vocabulary vocab) { - if(dryRun == true) { - String change = "Code : " + vocab.getCode() + ", description :" + vocab.getDescription(); - vocabulariesToUpdate.put(vocab.getCode(), change); - } - else { - commonServer.updateVocabulary(sessionToken, vocab); - } - } - - @Override - public void registerSampleType(SampleType sampleType) { - if(dryRun == true) { - sampleTypesToAdd.add(sampleType.getCode()); - } - else { - commonServer.registerSampleType(sessionToken, sampleType); - } - } - - @Override - public void registerDataSetType(DataSetType dataSetType) { - if(dryRun == true) { - dataSetTypesToAdd.add(dataSetType.getCode()); - } - else { - commonServer.registerDataSetType(sessionToken, dataSetType); - } - } - - @Override - public void registerExperimentType(ExperimentType experimentType) { - if(dryRun == true) { - experimentTypesToAdd.add(experimentType.getCode()); - } - else { - commonServer.registerExperimentType(sessionToken, experimentType); - } - } - - @Override - public void registerMaterialType(MaterialType materialType) { - if(dryRun == true) { - materialTypesToAdd.add(materialType.getCode()); - } - else { - commonServer.registerMaterialType(sessionToken, materialType); - } - } - - @Override - public void deleteVocabularyTerms(TechId vocabularyId, String vocabularyCode, List<VocabularyTerm> termsToBeDeleted, - List<VocabularyTermReplacement> termsToBeReplaced) { - if(dryRun == true) { - vocabularyTermsToDelete.put(vocabularyCode, termsToBeDeleted); - } - else { - commonServer.deleteVocabularyTerms(sessionToken, vocabularyId, termsToBeDeleted, termsToBeReplaced); - } - } - - @Override - public void updateVocabularyTerm(VocabularyTerm term) { - if(dryRun == true) { - String change = "Label :" + term.getLabel() + ", Ordinal :" + term.getOrdinal() + - ", Description :" + term.getDescription(); - vocabulariesToUpdate.put(term.getCode(), change); - } - else { - commonServer.updateVocabularyTerm(sessionToken, term); - } - } - - @Override - public void updateSampleType(EntityType entityType) { - if(dryRun == true) { - String change = "Code" + entityType.getCode() + ", Description :" + entityType.getDescription(); - sampleTypesToUpdate.put(entityType.getCode(), change); - } - else { - commonServer.updateSampleType(sessionToken, entityType); - } - } - - @Override - public void updateDataSetType(EntityType entityType) { - if(dryRun == true) { - String change = "Code" + entityType.getCode() + ", Description :" + entityType.getDescription(); - dataSetTypesToUpdate.put(entityType.getCode(), change); - } - else { - commonServer.updateDataSetType(sessionToken, entityType); - } - } - - @Override - public void updateExperimentType(EntityType entityType) { - if(dryRun == true) { - String change = "Code" + entityType.getCode() + ", Description :" + entityType.getDescription(); - experimentTypesToUpdate.put(entityType.getCode(), change); - } - else { - commonServer.updateExperimentType(sessionToken, entityType); - } - } - - @Override - public void updateMaterialType(EntityType entityType) { - if(dryRun == true) { - String change = "Code" + entityType.getCode() + ", Description :" + entityType.getDescription(); - materialTypesToUpdate.put(entityType.getCode(), change); - } - else { - commonServer.updateMaterialType(sessionToken, entityType); - } - } - - @Override - public void addVocabularyTerms(String vocabularyCode, TechId techId, List<VocabularyTerm> termsToBeAdded) { - if(dryRun == true) { - vocabularyTermsToAdd.put(vocabularyCode, termsToBeAdded); - } - else { - commonServer.addVocabularyTerms(sessionToken, techId, termsToBeAdded, null, true); - } - } - - @Override - public void printSummary() { - printSummary(fileformatTypesToAdd, "file format types", "added"); - printSummary(fileformatTypesToUpdate, "file format types", "updated"); - - printSummary(validationPluginsToAdd, "validation plugins", "added"); - printSummary(validationPluginsToUpdate, "validation plugins", "updated"); - - printSummary(propertyTypesToAdd, "property types"," added"); - printSummary(propertyTypesToUpdate, "property types", "updated"); - - printSummary(vocabulariesToAdd, "vocabularies", " added"); - printSummary(vocabulariesToUpdate, "vocabularies", "updated"); - - printSummaryVocabularyTerm(vocabularyTermsToDelete, "vocabulary terms", "deleted"); - printSummary(vocabularyTermsToUpdate, "vocabulary terms" , "updated"); - printSummary(vocabulariesToAdd, "vocabulary terms", "added"); - - printSummary(sampleTypesToAdd, "sample types", "added"); - printSummary(experimentTypesToAdd, "experiment types", "added"); - printSummary(dataSetTypesToAdd, "data set types", "added"); - printSummary(materialTypesToAdd, "material types", "added"); - - printSummary(sampleTypesToUpdate, "sample types", "updated"); - printSummary(experimentTypesToUpdate, "experiment types", "updated"); - printSummary(dataSetTypesToUpdate, "data set types", "updated"); - printSummary(materialTypesToUpdate, "material types", "updated"); - - printSummaryPropertyAssignments(propertyAssignmentsToAdd, "property assignments", "added"); - printSummaryPropertyAssignments(propertyAssignmentsToUpdate, "property assignments", "updated"); - printSummary(propertyAssignmentsToBreak, "property assignments", "removed"); - } - - private void printSummary(Set<String> set, String type, String operation) { - if (set.isEmpty() == true) - return; + @Override + public void updateFileFormatType(AbstractType type) + { + if (dryRun) + { + String change = "Description :" + type.getDescription(); + fileformatTypesToUpdate.put(type.getCode(), change); + } else + { + commonServer.updateFileFormatType(sessionToken, type); + } + } + + @Override + public void registerFileFormatType(FileFormatType type) + { + if (dryRun) + { + fileformatTypesToAdd.add(type.getCode()); + } else + { + commonServer.registerFileFormatType(sessionToken, type); + } + } + + @Override + public void updatePropertyTypeAssignment(NewETPTAssignment newETPTAssignment) + { + if (dryRun) + { + propertyAssignmentsToUpdate.add(newETPTAssignment); + } else + { + commonServer.updatePropertyTypeAssignment(sessionToken, newETPTAssignment); + } + } + + @Override + public void assignPropertyType(NewETPTAssignment newETPTAssignment) + { + if (dryRun) + { + propertyAssignmentsToAdd.add(newETPTAssignment); + } else + { + commonServer.assignPropertyType(sessionToken, newETPTAssignment); + } + } + + @Override + public void unassignPropertyType(EntityKind entityKind, String propertyTypeCode, String entityTypeCode) + { + if (dryRun) + { + propertyAssignmentsToBreak.put(entityTypeCode + "(" + entityKind.name() + ")", propertyTypeCode); + } else + { + commonServer.unassignPropertyType(sessionToken, entityKind, propertyTypeCode, entityTypeCode); + } + } + + @Override + public void updatePropertyType(PropertyType propertyType) + { + if (dryRun) + { + String change = "Label :" + propertyType.getLabel() + " , description :" + propertyType.getDescription(); + propertyTypesToUpdate.put(propertyType.getCode(), change); + } else + { + commonServer.updatePropertyType(sessionToken, propertyType); + } + } + + @Override + public void registerPropertyType(PropertyType propertyType) + { + if (dryRun) + { + propertyTypesToAdd.add(propertyType.getCode()); + } else + { + commonServer.registerPropertyType(sessionToken, propertyType); + } + } + + @Override + public void updateValidationPlugin(Script script) + { + if (dryRun) + {// "Name :" + script.getName() + ", + String change = "Description :" + script.getDescription() + ", script :" + script.getScript(); + validationPluginsToUpdate.put(script.getName(), change); + } else + { + commonServer.updateScript(sessionToken, script); + } + } + + @Override + public void registerValidationPlugin(Script script) + { + if (dryRun) + { + validationPluginsToAdd.add(script.getName()); + } else + { + commonServer.registerScript(sessionToken, script); + } + } + + @Override + public void registerVocabulary(NewVocabulary vocab) + { + if (dryRun == true) + { + vocabulariesToAdd.add(vocab.getCode()); + } else + { + commonServer.registerVocabulary(sessionToken, vocab); + } + } + + @Override + public void updateVocabulary(Vocabulary vocab) + { + if (dryRun == true) + { + String change = "Code : " + vocab.getCode() + ", description :" + vocab.getDescription(); + vocabulariesToUpdate.put(vocab.getCode(), change); + } else + { + commonServer.updateVocabulary(sessionToken, vocab); + } + } + + @Override + public void registerSampleType(SampleType sampleType) + { + if (dryRun == true) + { + sampleTypesToAdd.add(sampleType.getCode()); + } else + { + commonServer.registerSampleType(sessionToken, sampleType); + } + } + + @Override + public void registerDataSetType(DataSetType dataSetType) + { + if (dryRun == true) + { + dataSetTypesToAdd.add(dataSetType.getCode()); + } else + { + commonServer.registerDataSetType(sessionToken, dataSetType); + } + } + + @Override + public void registerExperimentType(ExperimentType experimentType) + { + if (dryRun == true) + { + experimentTypesToAdd.add(experimentType.getCode()); + } else + { + commonServer.registerExperimentType(sessionToken, experimentType); + } + } + + @Override + public void registerMaterialType(MaterialType materialType) + { + if (dryRun == true) + { + materialTypesToAdd.add(materialType.getCode()); + } else + { + commonServer.registerMaterialType(sessionToken, materialType); + } + } + + @Override + public void deleteVocabularyTerms(TechId vocabularyId, String vocabularyCode, List<VocabularyTerm> termsToBeDeleted, + List<VocabularyTermReplacement> termsToBeReplaced) + { + if (dryRun == true) + { + vocabularyTermsToDelete.put(vocabularyCode, termsToBeDeleted); + } else + { + commonServer.deleteVocabularyTerms(sessionToken, vocabularyId, termsToBeDeleted, termsToBeReplaced); + } + } + + @Override + public void updateVocabularyTerm(VocabularyTerm term) + { + if (dryRun == true) + { + String change = "Label :" + term.getLabel() + ", Ordinal :" + term.getOrdinal() + + ", Description :" + term.getDescription(); + vocabulariesToUpdate.put(term.getCode(), change); + } else + { + commonServer.updateVocabularyTerm(sessionToken, term); + } + } + + @Override + public void updateSampleType(EntityType entityType) + { + if (dryRun == true) + { + String change = "Code" + entityType.getCode() + ", Description :" + entityType.getDescription(); + sampleTypesToUpdate.put(entityType.getCode(), change); + } else + { + commonServer.updateSampleType(sessionToken, entityType); + } + } + + @Override + public void updateDataSetType(EntityType entityType) + { + if (dryRun == true) + { + String change = "Code" + entityType.getCode() + ", Description :" + entityType.getDescription(); + dataSetTypesToUpdate.put(entityType.getCode(), change); + } else + { + commonServer.updateDataSetType(sessionToken, entityType); + } + } + + @Override + public void updateExperimentType(EntityType entityType) + { + if (dryRun == true) + { + String change = "Code" + entityType.getCode() + ", Description :" + entityType.getDescription(); + experimentTypesToUpdate.put(entityType.getCode(), change); + } else + { + commonServer.updateExperimentType(sessionToken, entityType); + } + } + + @Override + public void updateMaterialType(EntityType entityType) + { + if (dryRun == true) + { + String change = "Code" + entityType.getCode() + ", Description :" + entityType.getDescription(); + materialTypesToUpdate.put(entityType.getCode(), change); + } else + { + commonServer.updateMaterialType(sessionToken, entityType); + } + } + + @Override + public void addVocabularyTerms(String vocabularyCode, TechId techId, List<VocabularyTerm> termsToBeAdded) + { + if (dryRun == true) + { + vocabularyTermsToAdd.put(vocabularyCode, termsToBeAdded); + } else + { + commonServer.addVocabularyTerms(sessionToken, techId, termsToBeAdded, null, true); + } + } + + @Override + public void printSummary() + { + printSummary(fileformatTypesToAdd, "file format types", "added"); + printSummary(fileformatTypesToUpdate, "file format types", "updated"); + + printSummary(validationPluginsToAdd, "validation plugins", "added"); + printSummary(validationPluginsToUpdate, "validation plugins", "updated"); + + printSummary(propertyTypesToAdd, "property types", " added"); + printSummary(propertyTypesToUpdate, "property types", "updated"); + + printSummary(vocabulariesToAdd, "vocabularies", " added"); + printSummary(vocabulariesToUpdate, "vocabularies", "updated"); + + printSummaryVocabularyTerm(vocabularyTermsToDelete, "vocabulary terms", "deleted"); + printSummary(vocabularyTermsToUpdate, "vocabulary terms", "updated"); + printSummary(vocabulariesToAdd, "vocabulary terms", "added"); + + printSummary(sampleTypesToAdd, "sample types", "added"); + printSummary(experimentTypesToAdd, "experiment types", "added"); + printSummary(dataSetTypesToAdd, "data set types", "added"); + printSummary(materialTypesToAdd, "material types", "added"); + + printSummary(sampleTypesToUpdate, "sample types", "updated"); + printSummary(experimentTypesToUpdate, "experiment types", "updated"); + printSummary(dataSetTypesToUpdate, "data set types", "updated"); + printSummary(materialTypesToUpdate, "material types", "updated"); + + printSummaryPropertyAssignments(propertyAssignmentsToAdd, "property assignments", "added"); + printSummaryPropertyAssignments(propertyAssignmentsToUpdate, "property assignments", "updated"); + printSummary(propertyAssignmentsToBreak, "property assignments", "removed"); + } + + private void printSummary(Set<String> set, String type, String operation) + { + if (set.isEmpty() == true) + return; operationLog.info(separatorStr); String message = String.format(INFO_MESSAGE, type, operation); - operationLog.info(message); + operationLog.info(message); operationLog.info(separatorStr); - for (String str : set) { - operationLog.info(str); - } - } - - private void printSummary(Map<String, String> map, String type, String operation) { - if (map.isEmpty() == true) - return; + for (String str : set) + { + operationLog.info(str); + } + } + + private void printSummary(Map<String, String> map, String type, String operation) + { + if (map.isEmpty() == true) + return; operationLog.info(separatorStr); String message = String.format(INFO_MESSAGE, type, operation); - operationLog.info(message); + operationLog.info(message); operationLog.info(separatorStr); - for (String key : map.keySet()) { - operationLog.info(key + " - " + map.get(key)); - } - } - - private void printSummaryVocabularyTerm(Map<String, List<VocabularyTerm>> map, String type, String operation) { - if (map.isEmpty() == true) - return; + for (String key : map.keySet()) + { + operationLog.info(key + " - " + map.get(key)); + } + } + + private void printSummaryVocabularyTerm(Map<String, List<VocabularyTerm>> map, String type, String operation) + { + if (map.isEmpty() == true) + return; operationLog.info(separatorStr); String message = String.format(INFO_MESSAGE, type, operation); - operationLog.info(message); + operationLog.info(message); operationLog.info(separatorStr); - for (String key : map.keySet()) { - String termStr = ""; - List<VocabularyTerm> terms = map.get(key); - for (VocabularyTerm vocabularyTerm : terms) { - termStr += vocabularyTerm.getCode(); - termStr += ", "; - } - operationLog.info(key + " - " + map.get(key) + ":" + termStr.substring(0, termStr.length()-1)); - } - } - - private void printSummaryPropertyAssignments(Set<NewETPTAssignment> set, String type, String operation) { - if (set.isEmpty() == true) - return; + for (String key : map.keySet()) + { + String termStr = ""; + List<VocabularyTerm> terms = map.get(key); + for (VocabularyTerm vocabularyTerm : terms) + { + termStr += vocabularyTerm.getCode(); + termStr += ", "; + } + operationLog.info(key + " - " + map.get(key) + ":" + termStr.substring(0, termStr.length() - 1)); + } + } + + private void printSummaryPropertyAssignments(Set<NewETPTAssignment> set, String type, String operation) + { + if (set.isEmpty() == true) + return; operationLog.info(separatorStr); String message = String.format(INFO_MESSAGE, type, operation); - operationLog.info(message); + operationLog.info(message); operationLog.info(separatorStr); - for (NewETPTAssignment assignment : set) { - operationLog.info(assignment.getEntityTypeCode() + "(" + assignment.getEntityKind().name() + ") : " + assignment.getPropertyTypeCode() ); - } - } + for (NewETPTAssignment assignment : set) + { + operationLog.info(assignment.getEntityTypeCode() + "(" + assignment.getEntityKind().name() + ") : " + assignment.getPropertyTypeCode()); + } + } } -- GitLab