Source:
public EntityType createEntityType(DataCollection dataCollection, String packageName) { String entityTypeId = idGenerator.generateId(); EntityType entityType = entityTypeFactory.create(); org.molgenis.data.meta.model.Package package_ = metaDataService.getPackage(packageName); if (package_ == null) { package_ = packageFactory.create(packageName); package_.setLabel(packageName); metaDataService.addPackage(package_); } entityType.setPackage(package_); entityType.setId(entityTypeId); entityType.setLabel(createNonDuplicateLabel(dataCollection.getName())); List<Column> columns = dataCollection.getColumns(); Column firstColumn = columns.get(0); final boolean isFirstColumnUnique = oneClickImporterService.hasUniqueValues(firstColumn); AttributeType type = attributeTypeService.guessAttributeType(firstColumn.getDataValues()); final boolean isValidAttributeType = AttributeUtils.getValidIdAttributeTypes().contains(type); final boolean useAutoId = !isFirstColumnUnique || !isValidAttributeType; if (useAutoId) { entityType.addAttribute(createIdAttribute(), ROLE_ID); } else { entityType.addAttribute(createAttribute(firstColumn), ROLE_ID); } columns.forEach(column -> { if (useAutoId || column != firstColumn) { Attribute attribute = createAttribute(column); entityType.addAttribute(attribute); } }); metaDataService.addEntityType(entityType); AtomicInteger rowIndex = new AtomicInteger(0); List<Entity> rows = newArrayList(); while (rowIndex.get() < dataCollection.getColumns().get(0).getDataValues().size()) { Entity row = entityManager.create(entityType, NO_POPULATE); if (useAutoId) { row.setIdValue(idGenerator.generateId()); } final int index = rowIndex.getAndIncrement(); columns.forEach(column -> setRowValueForAttribute(row, index, column)); rows.add(row); } dataService.add(entityType.getId(), rows.stream()); return entityType; }

Target:
public EntityType createEntityType(DataCollection dataCollection, String packageName) { String entityTypeId = idGenerator.generateId(); EntityType entityType = entityTypeFactory.create(); org.molgenis.data.meta.model.Package package_ = metaDataService.getPackage(packageName); if (package_ == null) { package_ = packageFactory.create(packageName); package_.setLabel(packageName); metaDataService.addPackage(package_); } entityType.setPackage(package_); entityType.setId(entityTypeId); entityType.setLabel(oneClickImporterNamingService.getLabelWithPostFix(dataCollection.getName())); List<Column> columns = dataCollection.getColumns(); Column firstColumn = columns.get(0); final boolean isFirstColumnUnique = oneClickImporterService.hasUniqueValues(firstColumn); AttributeType type = attributeTypeService.guessAttributeType(firstColumn.getDataValues()); final boolean isValidAttributeType = AttributeUtils.getValidIdAttributeTypes().contains(type); final boolean useAutoId = !isFirstColumnUnique || !isValidAttributeType; if (useAutoId) { entityType.addAttribute(createIdAttribute(), ROLE_ID); } else { entityType.addAttribute(createAttribute(firstColumn), ROLE_ID); } columns.forEach(column -> { if (useAutoId || column != firstColumn) { Attribute attribute = createAttribute(column); entityType.addAttribute(attribute); } }); metaDataService.addEntityType(entityType); AtomicInteger rowIndex = new AtomicInteger(0); List<Entity> rows = newArrayList(); while (rowIndex.get() < dataCollection.getColumns().get(0).getDataValues().size()) { Entity row = entityManager.create(entityType, NO_POPULATE); if (useAutoId) { row.setIdValue(idGenerator.generateId()); } final int index = rowIndex.getAndIncrement(); columns.forEach(column -> setRowValueForAttribute(row, index, column)); rows.add(row); } dataService.add(entityType.getId(), rows.stream()); return entityType; }