use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class EmxMetaDataParser method buildValidationReport.
private EntitiesValidationReport buildValidationReport(RepositoryCollection source, MyEntitiesValidationReport report, Map<String, EntityType> metaDataMap) {
metaDataMap.values().forEach(entityTypeValidator::validate);
metaDataMap.values().stream().map(EntityType::getAllAttributes).forEach(attributes -> attributes.forEach(attr -> {
attributeValidator.validate(attr, ValidationMode.ADD_SKIP_ENTITY_VALIDATION);
}));
// validate package/entity/attribute tags
metaDataMap.values().stream().map(EntityType::getPackage).filter(Objects::nonNull).forEach(package_ -> package_.getTags().forEach(tagValidator::validate));
metaDataMap.values().forEach(entityType -> entityType.getTags().forEach(tagValidator::validate));
metaDataMap.values().stream().map(EntityType::getAllAttributes).forEach(attributes -> attributes.forEach(attr -> {
attr.getTags().forEach(tagValidator::validate);
}));
report = generateEntityValidationReport(source, report, metaDataMap);
// Add entities without data
for (String entityTypeId : metaDataMap.keySet()) {
if (!report.getSheetsImportable().containsKey(entityTypeId))
report.addEntity(entityTypeId, true);
}
return report;
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class EmxMetaDataParser method parsePackagesSheet.
/**
* Parses the packages sheet
*
* @param repo {@link Repository} for the packages
* @param intermediateResults {@link IntermediateParseResults} containing the parsed tag entities
*/
private void parsePackagesSheet(Repository<Entity> repo, IntermediateParseResults intermediateResults) {
if (repo == null)
return;
// Collect packages
int rowIndex = 1;
for (Entity packageEntity : resolvePackages(repo)) {
rowIndex++;
// Package name is required
String name = packageEntity.getString(EMX_PACKAGE_NAME);
if (name == null)
throw new IllegalArgumentException("package.name is missing on line " + rowIndex);
Package package_ = packageFactory.create(name);
package_.setDescription(packageEntity.getString(EMX_PACKAGE_DESCRIPTION));
String label = packageEntity.getString(EMX_PACKAGE_LABEL);
if (label == null) {
label = name;
}
package_.setLabel(label);
// Set parent package
String parentName = packageEntity.getString(EMX_PACKAGE_PARENT);
if (parentName != null) {
if (!name.toLowerCase().startsWith(parentName.toLowerCase()))
throw new MolgenisDataException("Inconsistent package structure. Package: '" + name + "', parent: '" + parentName + '\'');
package_.setParent(intermediateResults.getPackage(parentName));
}
// Set package tags
List<String> tagIdentifiers = toList(packageEntity.getString(EMX_PACKAGE_TAGS));
if (tagIdentifiers != null && !tagIdentifiers.isEmpty()) {
List<Tag> tags = toTags(intermediateResults, tagIdentifiers);
package_.setTags(tags);
}
// Add the complete package to the parse results
intermediateResults.addPackage(name, package_);
}
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class IntermediateParseResults method addEntityType.
public EntityType addEntityType(String fullyQualifiedName) {
String entityTypeLabel = fullyQualifiedName;
Package pack = null;
for (Package p : packages.values()) {
String packageName = p.getId();
if (fullyQualifiedName.toLowerCase().startsWith(packageName.toLowerCase())) {
// package_entity
entityTypeLabel = fullyQualifiedName.substring(packageName.length() + 1);
pack = p;
}
}
String entityTypeId;
if (pack == null) {
pack = this.defaultPackage;
entityTypeId = DefaultPackage.PACKAGE_DEFAULT + Package.PACKAGE_SEPARATOR + fullyQualifiedName;
} else {
entityTypeId = fullyQualifiedName;
}
EntityType emd = entityTypeFactory.create(entityTypeId).setLabel(entityTypeLabel).setPackage(pack);
entities.put(fullyQualifiedName, emd);
return emd;
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class EntityTypeUtilsTest method isSystemEntityNotASystemIfNotInSystemPackage.
@Test
public void isSystemEntityNotASystemIfNotInSystemPackage() {
EntityType entity = mock(EntityType.class);
Package entityPackage = mock(Package.class);
when(entity.getPackage()).thenReturn(entityPackage);
when(entityPackage.getId()).thenReturn("not-system");
when(entity.getId()).thenReturn("foo_bar_Entity");
assertFalse(EntityTypeUtils.isSystemEntity(entity));
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class EntityTypeUtilsTest method buildFullNamePackage.
@Test
public void buildFullNamePackage() {
Package package_ = when(mock(Package.class).getId()).thenReturn("my_first_package").getMock();
assertEquals(EntityTypeUtils.buildFullName(package_, "simpleName"), "my_first_package_simpleName");
}
Aggregations