/** * replace functions with persistent ones (i.e. those that are at a project and those that are at a mapping) * * @param project */ private void replaceFunctions(final Project project) throws DMPPersistenceException { final Set<Function> existingProjectFunctions = project.getFunctions(); // replace project functions if (existingProjectFunctions != null) { final Set<Function> persistentProjectFunctions = new LinkedHashSet<>(); for (final Function existingProjectFunction : existingProjectFunctions) { final Function persistentProjectFunction = replaceFunction(existingProjectFunction); persistentProjectFunctions.add(persistentProjectFunction); } project.setFunctions(persistentProjectFunctions); } final Set<Mapping> existingProjectMappings = project.getMappings(); // replace mapping functions if (existingProjectMappings != null) { for (final Mapping existingProjectMapping : existingProjectMappings) { final Component existingProjectMappingTransformationComponent = existingProjectMapping.getTransformation(); if (existingProjectMappingTransformationComponent != null) { replaceFunctionsInComponent(existingProjectMappingTransformationComponent); } } } }
/** * replace attribute paths of MAPIs with persistent ones (we also fetch APs from inbuilt schemata from DB) * * @param oldUuidNewPersistentAttributePathMap * @param project * @throws DMPPersistenceException */ private void replaceAttributePathsInMappings(final Map<String, AttributePath> oldUuidNewPersistentAttributePathMap, final Project project) throws DMPPersistenceException, JsonProcessingException { if (project == null) { return; } final Set<Mapping> existingMappings = project.getMappings(); if (existingMappings == null) { return; } for (final Mapping existingMapping : existingMappings) { final Set<MappingAttributePathInstance> existingMappingInputAttributePaths = existingMapping.getInputAttributePaths(); if (existingMappingInputAttributePaths != null) { for (final MappingAttributePathInstance existingMAPI : existingMappingInputAttributePaths) { replaceAttributePathInMAPI(oldUuidNewPersistentAttributePathMap, existingMAPI); } } final MappingAttributePathInstance existingMappingOutputAttributePath = existingMapping.getOutputAttributePath(); replaceAttributePathInMAPI(oldUuidNewPersistentAttributePathMap, existingMappingOutputAttributePath); } }
@Override public boolean completeEquals(final Object obj) { return Project.class.isInstance(obj) && super.completeEquals(obj) && DMPPersistenceUtil.getDataModelUtils().completeEquals(((Project) obj).getInputDataModel(), getInputDataModel()) && DMPPersistenceUtil.getDataModelUtils().completeEquals(((Project) obj).getOutputDataModel(), getOutputDataModel()) && DMPPersistenceUtil.getMappingUtils().completeEquals(((Project) obj).getMappings(), getMappings()) && DMPPersistenceUtil.getFilterUtils().completeEquals(((Project) obj).getSkipFilter(), getSkipFilter()) && DMPPersistenceUtil.getFunctionUtils().completeEquals(((Project) obj).getFunctions(), getFunctions()) && Objects.equal(((Project) obj).getSelectedRecords(), getSelectedRecords()); } }
/** * {@inheritDoc} */ @Override public void updateObjectInternal(final Project object, final Project updateObject) throws DMPPersistenceException { super.updateObjectInternal(object, updateObject); final DataModel inputDataModel = object.getInputDataModel(); final DataModel outputDataModel = object.getOutputDataModel(); final Set<Mapping> mappings = object.getMappings(); final Filter skipFilter = object.getSkipFilter(); final Set<Function> functions = object.getFunctions(); final Set<String> selectedRecords = object.getSelectedRecords(); updateObject.setInputDataModel(inputDataModel); updateObject.setOutputDataModel(outputDataModel); updateObject.setMappings(mappings); updateObject.setSkipFilter(skipFilter); updateObject.setFunctions(functions); updateObject.setSelectedRecords(selectedRecords); }
if (expectedProject.getMappings() == null || expectedProject.getMappings().isEmpty()) { final boolean actualProjectHasNoMappings = (actualProject.getMappings() == null || actualProject.getMappings().isEmpty()); Assert.assertTrue("the actual project '" + actualProject.getUuid() + "' shouldn't have any mappings", actualProjectHasNoMappings); final Set<Mapping> actualMappings = actualProject.getMappings(); mappingServiceTestUtils.compareObjects(expectedProject.getMappings(), actualMappingsMap);
/** * {@inheritDoc}<br/> * Updates the name, description, (sample) input data model, output data model, mappings and functions of the project. */ @Override protected Project prepareObjectForUpdate(final Project objectWithUpdates, final Project object) { super.prepareObjectForUpdate(objectWithUpdates, object); object.setFunctions(objectWithUpdates.getFunctions()); object.setInputDataModel(objectWithUpdates.getInputDataModel()); object.setOutputDataModel(objectWithUpdates.getOutputDataModel()); object.setSkipFilter(objectWithUpdates.getSkipFilter()); object.setMappings(objectWithUpdates.getMappings()); object.setSelectedRecords(objectWithUpdates.getSelectedRecords()); return object; }