From 0b53a52a0b37f8906721086710a050b2370396bc Mon Sep 17 00:00:00 2001 From: Patrick Lanzinger Date: Wed, 4 Mar 2020 12:28:17 +0100 Subject: [PATCH] Fixed problem where relationships would not get loaded in the frontend. --- freebim-parent/freebim-data-neo4j/pom.xml | 2 +- .../db/service/impl/RelationServiceImpl.java | 116 +++++++++++++++++- freebim-parent/freebim-webapp/pom.xml | 2 +- freebim-parent/pom.xml | 4 +- 4 files changed, 118 insertions(+), 6 deletions(-) diff --git a/freebim-parent/freebim-data-neo4j/pom.xml b/freebim-parent/freebim-data-neo4j/pom.xml index 313367a..7ddf5d5 100644 --- a/freebim-parent/freebim-data-neo4j/pom.xml +++ b/freebim-parent/freebim-data-neo4j/pom.xml @@ -23,7 +23,7 @@ at.freebim db - 1.5.3 + 1.5.4 ../pom.xml diff --git a/freebim-parent/freebim-data-neo4j/src/main/java/at/freebim/db/service/impl/RelationServiceImpl.java b/freebim-parent/freebim-data-neo4j/src/main/java/at/freebim/db/service/impl/RelationServiceImpl.java index a46b8a1..5df63c3 100644 --- a/freebim-parent/freebim-data-neo4j/src/main/java/at/freebim/db/service/impl/RelationServiceImpl.java +++ b/freebim-parent/freebim-data-neo4j/src/main/java/at/freebim/db/service/impl/RelationServiceImpl.java @@ -50,7 +50,29 @@ import at.freebim.db.domain.base.rel.RelationTypeEnum; import at.freebim.db.domain.rel.HasParameter; import at.freebim.db.dto.Relations; +import at.freebim.db.repository.BaseNodeRepository; +import at.freebim.db.repository.BigBangNodeRepository; +import at.freebim.db.repository.BsddNodeRepository; +import at.freebim.db.repository.CompanyRepository; +import at.freebim.db.repository.ComponentRepository; +import at.freebim.db.repository.ContributorRepository; +import at.freebim.db.repository.DataTypeRepository; +import at.freebim.db.repository.DisciplineRepository; +import at.freebim.db.repository.DocumentRepository; +import at.freebim.db.repository.FreebimUserRepository; +import at.freebim.db.repository.LibraryRepository; +import at.freebim.db.repository.LifetimeBaseNodeRepository; +import at.freebim.db.repository.MeasureRepository; +import at.freebim.db.repository.MessageNodeRepository; +import at.freebim.db.repository.ParameterRepository; +import at.freebim.db.repository.ParameterSetRepository; +import at.freebim.db.repository.PhaseRepository; +import at.freebim.db.repository.SimpleNamedNodeRepository; +import at.freebim.db.repository.UnitRepository; +import at.freebim.db.repository.ValueListEntryRepository; +import at.freebim.db.repository.ValueListRepository; import at.freebim.db.service.BigBangNodeService; +import at.freebim.db.service.BsddNodeService; import at.freebim.db.service.DateService; import at.freebim.db.service.FreebimUserService; import at.freebim.db.service.LifetimeBaseNodeService; @@ -258,6 +280,96 @@ public List getAllPaths(Long nodeId, boolean onlyValid, Long m } return res; } + + @Autowired + private BaseNodeRepository baseNodeRepository; + @Autowired + private BigBangNodeRepository bigBangNodeRepository; + @Autowired + private BsddNodeRepository bsddNodeRepository; + @Autowired + private CompanyRepository companyRepository; + @Autowired + private ComponentRepository componentRepository; + @Autowired + private ContributorRepository contributorRepository; + @Autowired + private DataTypeRepository dataTypeRepository; + @Autowired + private DisciplineRepository disciplineRepository; + @Autowired + private DocumentRepository documentRepository; + @Autowired + private FreebimUserRepository freebimUserRepository; + @Autowired + private LibraryRepository libraryRepository; + @Autowired + private LifetimeBaseNodeRepository lifetimeBaseNodeRepository; + @Autowired + private MeasureRepository measureRepository; + @Autowired + private MessageNodeRepository messageNodeRepository; + @Autowired + private ParameterRepository parameterRepository; + @Autowired + private ParameterSetRepository parameterSetRepository; + @Autowired + private PhaseRepository phaseRepository; + @Autowired + private SimpleNamedNodeRepository simpleNamedNodeRepository; + @Autowired + private UnitRepository unitRepository; + @Autowired + private ValueListEntryRepository valueListEntryRepository; + @Autowired + private ValueListRepository valueListRepository; + + private BaseNode loadNode(Long nodeId, Class clazz) { + switch (clazz.getSimpleName()) { + case "BaseNode": + return baseNodeRepository.findById(nodeId).get(); + case "BigBangNode": + return bigBangNodeRepository.findById(nodeId).get(); + case "BsddNode": + return bsddNodeRepository.findById(nodeId).get(); + case "Company": + return companyRepository.findById(nodeId).get(); + case "Component": + return componentRepository.findById(nodeId).get(); + case "Contributor": + return contributorRepository.findById(nodeId).get(); + case "DataType": + return dataTypeRepository.findById(nodeId).get(); + case "Discipline": + return disciplineRepository.findById(nodeId).get(); + case "Document": + return documentRepository.findById(nodeId).get(); + case "FreebimUser": + return freebimUserRepository.findById(nodeId).get(); + case "Library": + return libraryRepository.findById(nodeId).get(); + case "Measure": + return measureRepository.findById(nodeId).get(); + case "MessageNode": + return messageNodeRepository.findById(nodeId).get(); + case "Parameter": + return parameterRepository.findById(nodeId).get(); + case "ParameterSet": + return parameterSetRepository.findById(nodeId).get(); + case "Phase": + return phaseRepository.findById(nodeId).get(); + case "SimpleNamedNode": + return simpleNamedNodeRepository.findById(nodeId).get(); + case "Unit": + return unitRepository.findById(nodeId).get(); + case "ValueList": + return valueListRepository.findById(nodeId).get(); + case "ValueListEntry": + return valueListEntryRepository.findById(nodeId).get(); + default: + return getTemplate().load(BaseNode.class, nodeId); + } + } /* * (non-Javadoc) @@ -393,7 +505,7 @@ public ArrayList getAllRelatedInOut(Long nodeId) { if (r != null && !this.isInResult(res, r)) { RelationResult rr = new RelationResult(); rr.className = r.getClass().getSimpleName(); - rr.node = r; + rr.node = loadNode(r.getNodeId(), r.getClass()); rr.relation = relTypeIn; rr.dir = "IN"; rr.ts = ts; @@ -412,7 +524,7 @@ public ArrayList getAllRelatedInOut(Long nodeId) { if (r != null && !this.isInResult(res, r)) { RelationResult rr = new RelationResult(); rr.className = r.getClass().getSimpleName(); - rr.node = r; + rr.node = loadNode(r.getNodeId(), r.getClass()); rr.relation = relTypeOut; rr.dir = "OUT"; rr.ts = ts; diff --git a/freebim-parent/freebim-webapp/pom.xml b/freebim-parent/freebim-webapp/pom.xml index 5c05ff0..27f1e97 100644 --- a/freebim-parent/freebim-webapp/pom.xml +++ b/freebim-parent/freebim-webapp/pom.xml @@ -11,7 +11,7 @@ at.freebim db - 1.5.3 + 1.5.4 ../pom.xml diff --git a/freebim-parent/pom.xml b/freebim-parent/pom.xml index 00ab31a..b727d0b 100644 --- a/freebim-parent/pom.xml +++ b/freebim-parent/pom.xml @@ -4,13 +4,13 @@ 4.0.0 at.freebim db - 1.5.3 + 1.5.4 pom freebim-parent freebim-parent - 1.5.3 + 1.5.4 UTF-8 2.1.4.RELEASE