@Test void createMetaWithNonNullParameters() { MappingTarget mappingTarget = mock(MappingTarget.class); when(mappingTarget.getTarget()).thenReturn(hopMetaData); Package targetPackage = mock(Package.class); when(metaDataService.getPackage("targetPackage")).thenReturn(Optional.of(targetPackage)); EntityType targetMetadata = mappingService.createTargetMetadata( mappingTarget, "test", "targetPackage", "target label", true); assertEquals("test", targetMetadata.getId()); assertEquals("target label", targetMetadata.getLabel()); assertEquals(targetPackage, targetMetadata.getPackage()); assertNotNull(targetMetadata.getAttribute(SOURCE)); }
EntityType createTargetMetadata( MappingTarget mappingTarget, String entityTypeId, String packageId, String label, Boolean addSourceAttribute) { EntityType targetMetadata = EntityType.newInstance(mappingTarget.getTarget(), DEEP_COPY_ATTRS, attrMetaFactory); targetMetadata.setId(entityTypeId); if (label != null) { targetMetadata.setLabel(label); } else { targetMetadata.setLabel(entityTypeId); } if (TRUE.equals(addSourceAttribute)) { targetMetadata.addAttribute(attrMetaFactory.create().setName(SOURCE)); } if (dataService.hasRepository(entityTypeId)) { EntityType entityType = dataService .getMeta() .getEntityType(entityTypeId) .orElseThrow(() -> new UnknownEntityTypeException(entityTypeId)); targetMetadata.setPackage(entityType.getPackage()); } else if (packageId != null) { Package aPackage = dataService .getMeta() .getPackage(packageId) .orElseThrow(() -> new UnknownEntityException(PACKAGE, packageId)); targetMetadata.setPackage(aPackage); } else { throw new MolgenisDataException("Package can't be null"); } return targetMetadata; }
MappingServiceImpl implements MappingService { EntityType createTargetMetadata( MappingTarget mappingTarget, String entityTypeId, String packageId, String label, Boolean addSourceAttribute) { EntityType targetMetadata = EntityType.newInstance(mappingTarget.getTarget(), DEEP_COPY_ATTRS, attrMetaFactory); targetMetadata.setId(entityTypeId); if (label != null) { targetMetadata.setLabel(label); } else { targetMetadata.setLabel(entityTypeId); } if (TRUE.equals(addSourceAttribute)) { targetMetadata.addAttribute(attrMetaFactory.create().setName(SOURCE)); } if (dataService.hasRepository(entityTypeId)) { EntityType entityType = dataService .getMeta() .getEntityType(entityTypeId) .orElseThrow(() -> new UnknownEntityTypeException(entityTypeId)); targetMetadata.setPackage(entityType.getPackage()); } else if (packageId != null) { Package aPackage = dataService .getMeta() .getPackage(packageId) .orElseThrow(() -> new UnknownEntityException(PACKAGE, packageId)); targetMetadata.setPackage(aPackage); } else { throw new MolgenisDataException("Package can't be null"); } return targetMetadata; } }
MappingServiceImpl implements MappingService { EntityType createTargetMetadata( MappingTarget mappingTarget, String entityTypeId, String packageId, String label, Boolean addSourceAttribute) { EntityType targetMetadata = EntityType.newInstance(mappingTarget.getTarget(), DEEP_COPY_ATTRS, attrMetaFactory); targetMetadata.setId(entityTypeId); if (label != null) { targetMetadata.setLabel(label); } else { targetMetadata.setLabel(entityTypeId); } if (TRUE.equals(addSourceAttribute)) { targetMetadata.addAttribute(attrMetaFactory.create().setName(SOURCE)); } if (dataService.hasRepository(entityTypeId)) { EntityType entityType = dataService .getMeta() .getEntityType(entityTypeId) .orElseThrow(() -> new UnknownEntityTypeException(entityTypeId)); targetMetadata.setPackage(entityType.getPackage()); } else if (packageId != null) { Package aPackage = dataService .getMeta() .getPackage(packageId) .orElseThrow(() -> new UnknownEntityException(PACKAGE, packageId)); targetMetadata.setPackage(aPackage); } else { throw new MolgenisDataException("Package can't be null"); } return targetMetadata; } MappingServiceImpl(
      DataService dataService,
      AlgorithmService algorithmService,
      MappingProjectRepository mappingProjectRepository,
      PermissionSystemService permissionSystemService,
      AttributeFactory attrMetaFactory,
      EntityManager entityManager); }
MappingServiceImpl implements MappingService { EntityType createTargetMetadata( MappingTarget mappingTarget, String entityTypeId, String packageId, String label, Boolean addSourceAttribute) { EntityType targetMetadata = EntityType.newInstance(mappingTarget.getTarget(), DEEP_COPY_ATTRS, attrMetaFactory); targetMetadata.setId(entityTypeId); if (label != null) { targetMetadata.setLabel(label); } else { targetMetadata.setLabel(entityTypeId); } if (TRUE.equals(addSourceAttribute)) { targetMetadata.addAttribute(attrMetaFactory.create().setName(SOURCE)); } if (dataService.hasRepository(entityTypeId)) { EntityType entityType = dataService .getMeta() .getEntityType(entityTypeId) .orElseThrow(() -> new UnknownEntityTypeException(entityTypeId)); targetMetadata.setPackage(entityType.getPackage()); } else if (packageId != null) { Package aPackage = dataService .getMeta() .getPackage(packageId) .orElseThrow(() -> new UnknownEntityException(PACKAGE, packageId)); targetMetadata.setPackage(aPackage); } else { throw new MolgenisDataException("Package can't be null"); } return targetMetadata; } MappingServiceImpl(
      DataService dataService,
      AlgorithmService algorithmService,
      MappingProjectRepository mappingProjectRepository,
      PermissionSystemService permissionSystemService,
      AttributeFactory attrMetaFactory,
      EntityManager entityManager); @Override @Transactional MappingProject addMappingProject(String projectName, String target, int depth); @Override @Transactional void deleteMappingProject(String mappingProjectId); @Override @Transactional MappingProject cloneMappingProject(String mappingProjectId); @Override @Transactional MappingProject cloneMappingProject(
      String mappingProjectId, String clonedMappingProjectName); @Override List<MappingProject> getAllMappingProjects(); @Override @Transactional void updateMappingProject(MappingProject mappingProject); @Override MappingProject getMappingProject(String identifier); @Override @Transactional long applyMappings(
      String mappingProjectId,
      String entityTypeId,
      Boolean addSourceAttribute,
      String packageId,
      String label,
      Progress progress); Stream<EntityType> getCompatibleEntityTypes(EntityType target); }
MappingServiceImpl implements MappingService { EntityType createTargetMetadata( MappingTarget mappingTarget, String entityTypeId, String packageId, String label, Boolean addSourceAttribute) { EntityType targetMetadata = EntityType.newInstance(mappingTarget.getTarget(), DEEP_COPY_ATTRS, attrMetaFactory); targetMetadata.setId(entityTypeId); if (label != null) { targetMetadata.setLabel(label); } else { targetMetadata.setLabel(entityTypeId); } if (TRUE.equals(addSourceAttribute)) { targetMetadata.addAttribute(attrMetaFactory.create().setName(SOURCE)); } if (dataService.hasRepository(entityTypeId)) { EntityType entityType = dataService .getMeta() .getEntityType(entityTypeId) .orElseThrow(() -> new UnknownEntityTypeException(entityTypeId)); targetMetadata.setPackage(entityType.getPackage()); } else if (packageId != null) { Package aPackage = dataService .getMeta() .getPackage(packageId) .orElseThrow(() -> new UnknownEntityException(PACKAGE, packageId)); targetMetadata.setPackage(aPackage); } else { throw new MolgenisDataException("Package can't be null"); } return targetMetadata; } MappingServiceImpl(
      DataService dataService,
      AlgorithmService algorithmService,
      MappingProjectRepository mappingProjectRepository,
      PermissionSystemService permissionSystemService,
      AttributeFactory attrMetaFactory,
      EntityManager entityManager); @Override @Transactional MappingProject addMappingProject(String projectName, String target, int depth); @Override @Transactional void deleteMappingProject(String mappingProjectId); @Override @Transactional MappingProject cloneMappingProject(String mappingProjectId); @Override @Transactional MappingProject cloneMappingProject(
      String mappingProjectId, String clonedMappingProjectName); @Override List<MappingProject> getAllMappingProjects(); @Override @Transactional void updateMappingProject(MappingProject mappingProject); @Override MappingProject getMappingProject(String identifier); @Override @Transactional long applyMappings(
      String mappingProjectId,
      String entityTypeId,
      Boolean addSourceAttribute,
      String packageId,
      String label,
      Progress progress); Stream<EntityType> getCompatibleEntityTypes(EntityType target); static final int MAPPING_BATCH_SIZE; }