use of org.molgenis.data.meta.model.Attribute in project molgenis by molgenis.
the class EntityModelWriterTest method testCreateRfdModelNullValuePlusHyperlink.
@Test
public void testCreateRfdModelNullValuePlusHyperlink() {
// public Model createRdfModel(String subjectIRI, Entity objectEntity)
Entity objectEntity = mock(Entity.class);
EntityType entityType = mock(EntityType.class);
Attribute attribute1 = mock(Attribute.class);
Attribute attribute2 = mock(Attribute.class);
List<Attribute> attributeList = Arrays.asList(attribute1, attribute2);
when(objectEntity.getEntityType()).thenReturn(entityType);
when(objectEntity.get("attribute1Name")).thenReturn(null);
String value = "http://molgenis.org/index.html";
doReturn(value).when(objectEntity).get("attribute2Name");
when(objectEntity.getString("attribute2Name")).thenReturn(value);
when(entityType.getAtomicAttributes()).thenReturn(attributeList);
when(attribute1.getName()).thenReturn("attribute1Name");
when(attribute2.getName()).thenReturn("attribute2Name");
when(attribute2.getDataType()).thenReturn(AttributeType.HYPERLINK);
LabeledResource tag2 = new LabeledResource("http://IRI1.nl", "tag1 label");
Multimap<Relation, LabeledResource> tags2 = ImmutableMultimap.of(Relation.isAssociatedWith, tag2);
doReturn(tags2).when(tagService).getTagsForAttribute(entityType, attribute2);
Model result = writer.createRdfModel("http://molgenis01.gcc.rug.nl/fdp/catolog/test/this", objectEntity);
assertEquals(result.size(), 1);
Iterator results = result.iterator();
assertEquals(results.next().toString(), "(http://molgenis01.gcc.rug.nl/fdp/catolog/test/this, http://IRI1.nl, http://molgenis.org/index.html) [null]");
}
use of org.molgenis.data.meta.model.Attribute in project molgenis by molgenis.
the class DataExplorerDownloadHandler method filterAttributes.
private List<Attribute> filterAttributes(DataRequest dataRequest) {
EntityType entityType = dataService.getEntityType(dataRequest.getEntityName());
final Set<String> attributeNames = newHashSet(dataRequest.getAttributeNames());
return Streams.stream(entityType.getAtomicAttributes()).filter(attribute -> attributeNames.contains(attribute.getName())).collect(toList());
}
use of org.molgenis.data.meta.model.Attribute in project molgenis by molgenis.
the class DataExplorerDownloadHandler method writeToExcel.
public void writeToExcel(DataRequest dataRequest, OutputStream outputStream) throws IOException {
String entityTypeId = dataRequest.getEntityName();
List<Attribute> attributes = filterAttributes(dataRequest);
checkNumberOfCells(dataRequest, entityTypeId, attributes.size());
AttributeWriteMode attributeWriteMode = getAttributeWriteMode(dataRequest.getColNames());
try (ExcelWriter excelWriter = new ExcelWriter(outputStream, attrMetaFactory, FileFormat.XLSX);
ExcelSheetWriter excelSheetWriter = excelWriter.createWritable(entityTypeId, attributes, attributeWriteMode)) {
excelSheetWriter.setEntityWriteMode(getEntityWriteMode(dataRequest.getEntityValues()));
excelSheetWriter.add(dataService.findAll(entityTypeId, dataRequest.getQuery()));
}
}
use of org.molgenis.data.meta.model.Attribute in project molgenis by molgenis.
the class PersonMetaData3 method init.
@Override
public void init() {
setLabel("Person");
addAttribute(ID, ROLE_ID).setLabel("Identifier");
addAttribute(LABEL, ROLE_LABEL).setNillable(false).setLabel("Label");
Attribute parentAttr = addAttribute(ATTR_PARENT).setDataType(XREF).setRefEntity(this);
addAttribute(ATTR_CHILDREN).setDataType(ONE_TO_MANY).setRefEntity(this).setMappedBy(parentAttr).setOrderBy(new Sort(ID, ASC));
}
use of org.molgenis.data.meta.model.Attribute in project molgenis by molgenis.
the class PersonMetaData4 method init.
@Override
public void init() {
setLabel("Person");
addAttribute(ID, ROLE_ID).setLabel("Identifier");
addAttribute(LABEL, ROLE_LABEL).setNillable(false).setLabel("Label");
Attribute parentAttr = addAttribute(ATTR_PARENT).setDataType(XREF).setRefEntity(this);
addAttribute(ATTR_CHILDREN).setDataType(ONE_TO_MANY).setRefEntity(this).setMappedBy(parentAttr).setOrderBy(new Sort(ID, DESC));
}
Aggregations