/** * {@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); }
/** * {@inheritDoc}<br/> * Clears the relationship to the input data model, output data model, mappings and functions. */ @Override protected void prepareObjectForRemoval(final Project object) { // should clear the relationship to the input data model, output data model, mappings and functions object.setInputDataModel(null); object.setOutputDataModel(null); object.setMappings(null); object.setSkipFilter(null); object.setFunctions(null); }
/** * replaces input and output data models with persistent ones (or inbuilt ones) * * @param persistentDataModels * @param project * @throws DMPPersistenceException */ private void replaceDataModels(final Map<String, DataModel> persistentDataModels, final Project project) throws DMPPersistenceException { final DataModel existingInputDataModel = project.getInputDataModel(); final DataModel persistentInputDataModel = replaceDataModel(persistentDataModels, existingInputDataModel); project.setInputDataModel(persistentInputDataModel); final DataModel existingOutputDataModel = project.getOutputDataModel(); final DataModel persistentOutputDataModel = replaceDataModel(persistentDataModels, existingOutputDataModel); project.setOutputDataModel(persistentOutputDataModel); }
@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()); } }
public Project createProject(final String name, final String description, final Set<Mapping> mappings, final DataModel inputDataModel, final DataModel outputDataModel, final Set<Function> functions) { final String uuid = UUIDService.getUUID(Project.class.getSimpleName()); final Project project = new Project(uuid); project.setName(name); project.setDescription(description); project.setMappings(mappings); project.setInputDataModel(inputDataModel); project.setOutputDataModel(outputDataModel); project.setFunctions(functions); return project; }
/** * 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); } }
if (expectedProject.getInputDataModel() == null) { Assert.assertNull("the actual project '" + actualProject.getUuid() + "' should not have an input data model", actualProject.getInputDataModel()); dataModelServiceTestUtils.compareObjects(expectedProject.getInputDataModel(), actualProject.getInputDataModel()); if (expectedProject.getOutputDataModel() == null) { Assert.assertNull("the actual project '" + actualProject.getUuid() + "' should not have an output data model", actualProject.getOutputDataModel()); dataModelServiceTestUtils.compareObjects(expectedProject.getOutputDataModel(), actualProject.getOutputDataModel()); if (expectedProject.getSkipFilter() == null) { Assert.assertNull("the actual project '" + actualProject.getUuid() + "' should not have a skip filter", actualProject.getSkipFilter()); filterServiceTestUtils.compareObjects(expectedProject.getSkipFilter(), actualProject.getSkipFilter()); 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(); Assert.assertNotNull("mappings of project '" + actualProject.getUuid() + "' shouldn't be null", actualMappings);
final Project project = new Project(projectUUID); project.setName("my project"); project.setDescription("my description"); project.setMappings(mappings); project.setInputDataModel(inputDataModel); project.setOutputDataModel(outputDataModel); project.setFunctions(functions);
/** * {@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; }