Skip to content

Commit

Permalink
Fixed problem where relationships would not get loaded in the frontend.
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklanzinger committed Mar 4, 2020
1 parent b3de67d commit 0b53a52
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 6 deletions.
2 changes: 1 addition & 1 deletion freebim-parent/freebim-data-neo4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>at.freebim</groupId>
<artifactId>db</artifactId>
<version>1.5.3</version>
<version>1.5.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -258,6 +280,96 @@ public List<SimplePathResult> 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<? extends BaseNode> 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)
Expand Down Expand Up @@ -393,7 +505,7 @@ public ArrayList<RelationResult> 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;
Expand All @@ -412,7 +524,7 @@ public ArrayList<RelationResult> 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;
Expand Down
2 changes: 1 addition & 1 deletion freebim-parent/freebim-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>at.freebim</groupId>
<artifactId>db</artifactId>
<version>1.5.3</version>
<version>1.5.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions freebim-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<modelVersion>4.0.0</modelVersion>
<groupId>at.freebim</groupId>
<artifactId>db</artifactId>
<version>1.5.3</version>
<version>1.5.4</version>
<packaging>pom</packaging>
<name>freebim-parent</name>
<description>freebim-parent</description>

<properties>
<freebim.version>1.5.3</freebim.version>
<freebim.version>1.5.4</freebim.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-boot-version>2.1.4.RELEASE</spring-boot-version>
<!--<spring.version>4.0.6.RELEASE</spring.version> <spring-sec.version>3.2.4.RELEASE</spring-sec.version>
Expand Down

0 comments on commit 0b53a52

Please sign in to comment.