diff --git a/src/main/java/cz/cvut/kbss/analysis/dao/SystemDao.java b/src/main/java/cz/cvut/kbss/analysis/dao/SystemDao.java index 498c66e..2733731 100755 --- a/src/main/java/cz/cvut/kbss/analysis/dao/SystemDao.java +++ b/src/main/java/cz/cvut/kbss/analysis/dao/SystemDao.java @@ -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 { + 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 findComponents(URI systemURI){ + return em.createNativeQuery(""" + SELECT ?uri { + ?systemURI (?hasComponentPartProp)+ ?uri. + } + """) + .setParameter("systemURI", systemURI) + .setParameter("hasComponentPartProp", HAS_COMPONENT_PART) + .getResultList(); + } } diff --git a/src/main/java/cz/cvut/kbss/analysis/model/Item.java b/src/main/java/cz/cvut/kbss/analysis/model/Item.java index 260fa4b..e467730 100644 --- a/src/main/java/cz/cvut/kbss/analysis/model/Item.java +++ b/src/main/java/cz/cvut/kbss/analysis/model/Item.java @@ -19,7 +19,7 @@ public class Item extends DomainEntity { @OWLObjectProperty(iri = Vocabulary.s_p_is_documented_in) private Set 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 components = new HashSet<>(); public void addComponent(Component component) { diff --git a/src/main/java/cz/cvut/kbss/analysis/service/SystemRepositoryService.java b/src/main/java/cz/cvut/kbss/analysis/service/SystemRepositoryService.java index a8a4ba5..29c16b9 100755 --- a/src/main/java/cz/cvut/kbss/analysis/service/SystemRepositoryService.java +++ b/src/main/java/cz/cvut/kbss/analysis/service/SystemRepositoryService.java @@ -51,6 +51,17 @@ protected GenericDao 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);