use of org.molgenis.data.meta.model.EntityType in project molgenis by molgenis.
the class DataExplorerController method viewEntityDetailsById.
/**
* Builds a model containing one entity and returns standalone report ftl view
*
* @return standalone report view
* @throws Exception if an entity name or id is not found
* @throws MolgenisDataAccessException if an EntityType does not exist
*/
@GetMapping("/details/{entityTypeId}/{entityId}")
public String viewEntityDetailsById(@PathVariable(value = "entityTypeId") String entityTypeId, @PathVariable(value = "entityId") String entityId, Model model) throws Exception {
EntityType entityType = dataService.getEntityType(entityTypeId);
if (entityType == null) {
throw new MolgenisDataAccessException("EntityType with id [" + entityTypeId + "] does not exist. Did you use the correct URL?");
}
Object id = getTypedValue(entityId, entityType.getIdAttribute());
model.addAttribute("entity", dataService.getRepository(entityTypeId).findOneById(id));
model.addAttribute("entityType", entityType);
model.addAttribute("entityTypeId", entityTypeId);
model.addAttribute("viewName", getStandaloneReportViewName(entityTypeId));
return "view-standalone-report";
}
use of org.molgenis.data.meta.model.EntityType in project molgenis by molgenis.
the class DataExplorerController method getModule.
@GetMapping("/module/{moduleId}")
public String getModule(@PathVariable("moduleId") String moduleId, @RequestParam("entity") String entityTypeId, Model model) {
EntityType selectedEntityType;
Map<String, GenomeBrowserTrack> entityTracks;
switch(moduleId) {
case MOD_DATA:
selectedEntityType = dataService.getMeta().getEntityTypeById(entityTypeId);
entityTracks = genomeBrowserService.getGenomeBrowserTracks(selectedEntityType);
model.addAttribute("genomeTracks", getTracksJson(entityTracks));
// if multiple tracks are available we assume chrom and pos attribute are the same
if (!entityTracks.isEmpty()) {
// FIXME: how to do this cleaner
GenomeBrowserTrack track = entityTracks.entrySet().iterator().next().getValue();
model.addAttribute("pos_attr", track.getGenomeBrowserAttrs().getPos());
model.addAttribute("chrom_attr", track.getGenomeBrowserAttrs().getChrom());
}
model.addAttribute("showDirectoryButton", directoryController.showDirectoryButton(entityTypeId));
model.addAttribute("NegotiatorEnabled", directoryController.showDirectoryButton(entityTypeId));
break;
case MOD_ENTITIESREPORT:
// TODO: figure out if we need to know pos and chrom attrs here
selectedEntityType = dataService.getMeta().getEntityTypeById(entityTypeId);
entityTracks = genomeBrowserService.getGenomeBrowserTracks(selectedEntityType);
model.addAttribute("genomeTracks", getTracksJson(entityTracks));
model.addAttribute("showDirectoryButton", directoryController.showDirectoryButton(entityTypeId));
model.addAttribute("NegotiatorEnabled", directoryController.showDirectoryButton(entityTypeId));
model.addAttribute("datasetRepository", dataService.getRepository(entityTypeId));
model.addAttribute("viewName", dataExplorerSettings.getEntityReport(entityTypeId));
break;
case MOD_ANNOTATORS:
// self-explanatory
if (!permissionService.hasPermission(new EntityTypeIdentity(entityTypeId), EntityTypePermission.WRITEMETA)) {
throw new MolgenisDataAccessException("No " + Permission.WRITEMETA + " permission on entity [" + entityTypeId + "], this permission is necessary run the annotators.");
}
Entity annotationRun = dataService.findOne(ANNOTATION_JOB_EXECUTION, new QueryImpl<>().eq(AnnotationJobExecutionMetaData.TARGET_NAME, entityTypeId).sort(new Sort(JobExecutionMetaData.START_DATE, Sort.Direction.DESC)));
model.addAttribute("annotationRun", annotationRun);
model.addAttribute("entityTypeId", entityTypeId);
break;
}
// TODO bad request in case of invalid module id
return "view-dataexplorer-mod-" + moduleId;
}
use of org.molgenis.data.meta.model.EntityType 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.EntityType in project molgenis by molgenis.
the class EntityTypeUtilsTest method isSystemEntityNotASystemEntityIfNotInPackage.
@Test
public void isSystemEntityNotASystemEntityIfNotInPackage() {
EntityType entity = mock(EntityType.class);
when(entity.getPackage()).thenReturn(null);
assertFalse(EntityTypeUtils.isSystemEntity(entity));
}
use of org.molgenis.data.meta.model.EntityType in project molgenis by molgenis.
the class EntityTypeUtilsTest method testCreateFetchForReindexingIndexingDepth1.
@Test
public void testCreateFetchForReindexingIndexingDepth1() {
EntityType entityType = createMockEntityType();
when(entityType.getIndexingDepth()).thenReturn(1);
Fetch expectedFetch = new Fetch().field("MyEntityTypeAttr").field("MyEntityTypeRefAttr", new Fetch().field("MyRefEntityTypeAttr").field("MyRefEntityTypeRefAttr"));
assertEquals(EntityTypeUtils.createFetchForReindexing(entityType), expectedFetch);
}
Aggregations