Skip to content

Commit

Permalink
Merge pull request #123 from kbss-cvut/optimize-loading-time-of-fault…
Browse files Browse the repository at this point in the history
…-tree-with-details

Optimize loading time of fault tree with details
  • Loading branch information
kostobog authored Jun 19, 2024
2 parents 53e8280 + d7bca36 commit c0bda91
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/main/java/cz/cvut/kbss/analysis/dao/SystemDao.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
package cz.cvut.kbss.analysis.dao;

import cz.cvut.kbss.analysis.config.conf.PersistenceConf;
import cz.cvut.kbss.analysis.model.Component;
import cz.cvut.kbss.analysis.model.System;
import cz.cvut.kbss.analysis.service.IdentifierService;
import cz.cvut.kbss.analysis.service.security.SecurityUtils;
import cz.cvut.kbss.analysis.util.Vocabulary;
import cz.cvut.kbss.jopa.model.EntityManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.net.URI;
import java.util.List;

@Repository
public class SystemDao extends ManagedEntityDao<System> {

protected static final URI HAS_COMPONENT_PART = URI.create(Vocabulary.s_p_has_part_component);

@Autowired
protected SystemDao(EntityManager em, PersistenceConf config, IdentifierService identifierService, SecurityUtils securityUtils) {
super(System.class, em, config, identifierService, securityUtils);
}

public List<Component> findComponents(URI systemURI){
return em.createNativeQuery("""
SELECT ?uri {
?systemURI (?hasComponentPartProp)+ ?uri.
}
""")
.setParameter("systemURI", systemURI)
.setParameter("hasComponentPartProp", HAS_COMPONENT_PART)
.getResultList();
}
}
2 changes: 1 addition & 1 deletion src/main/java/cz/cvut/kbss/analysis/model/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Item extends DomainEntity<Item> {
@OWLObjectProperty(iri = Vocabulary.s_p_is_documented_in)
private Set<Document> documents;

@OWLObjectProperty(iri = Vocabulary.s_p_has_part_component, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@OWLObjectProperty(iri = Vocabulary.s_p_has_part_component, cascade = CascadeType.ALL)
private Set<Component> components = new HashSet<>();

public void addComponent(Component component) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ protected GenericDao<System> getPrimaryDao() {
return systemDao;
}

// TODO check if this works for lazy loading
@Transactional
@Override
public System findRequired(URI id) {
System system = super.findRequired(id);
// fetch partonomy
systemDao.findComponents(id);

return system;
}

@Transactional
public System rename(System systemRename) {
log.info("> rename - {}", systemRename);
Expand Down

0 comments on commit c0bda91

Please sign in to comment.