public Collection<EntityMetaData> loadOMX(RepositoryCollection omx) { // extract attribute metadata Map<String, AttributeMetaData> attributes = new LinkedHashMap<String, AttributeMetaData>(); for (Entity e : omx.getRepositoryByEntityName("observablefeature")) { logger.debug("found observablefeature: " + e); DefaultAttributeMetaData att = new DefaultAttributeMetaData(e.getString("name")); if (e.get("dataType") != null) att.setDataType(MolgenisFieldTypes.getType(e.getString("dataType"))); attributes.put(e.getString("identifier"), att); if (e.get("description") != null) att.setDescription(e.getString("description")); // TODO unit! if(e.get("unit") != null) if ("xref".equals(e.get("dataType")) || "mref".equals(e.get("dataType"))) { // TODO: cannot solve!!! att.setRefEntity(omxEntities.get("Characteristic")); } if ("categorical".equals(e.get("dataType"))) { att.setRefEntity(omxEntities.get("Category")); } } // TODO: fix categorical! // extract protocols as entities(abstract=true) Map<String, EntityMetaData> entities = new LinkedHashMap<String, EntityMetaData>(); for (Entity e : omx.getRepositoryByEntityName("protocol")) { // skip all null entities if (hasValues(e)) { logger.debug("found protocol: " + e); DefaultEntityMetaData ent = new DefaultEntityMetaData(e.getString("identifier")); // alas ent.setLabel(e.getString("name")); ent.setAbstract(true); // add attributes if (e.get("features_identifier") != null) for (String attIdentifier : e.getList("features_identifier")) { if (attributes.get(attIdentifier) == null) throw new RuntimeException("attribute '" + attIdentifier + "' unknown"); ent.addAttributeMetaData(attributes.get(attIdentifier)); } entities.put(e.getString("identifier"), ent); } } for (Entity e : omx.getRepositoryByEntityName("protocol")) { // add subprotocols as compound if (e.get("subprotocols_identifier") != null) { for (String subProtocol : e.getList("subprotocols_identifier")) { DefaultAttributeMetaData att = new DefaultAttributeMetaData(subProtocol); att.setDataType(MolgenisFieldTypes.COMPOUND); att.setRefEntity(entities.get(subProtocol)); ((DefaultEntityMetaData) entities.get(e.get("identifier"))).addAttributeMetaData(att); } } } // create dataset as entities for (Entity e : omx.getRepositoryByEntityName("dataset")) { logger.debug("found dataset: " + e); DefaultEntityMetaData ent = new DefaultEntityMetaData(e.getString("identifier")); ent.setLabel(e.getString("name")); // dataset 'extends' protocol ent.setExtends(entities.get(e.getString("protocolused_identifier"))); entities.put(e.getString("identifier"), ent); } return entities.values(); }