Mercurial > hg > openmind
diff src/main/java/org/mpi/openmind/cache/WrapperService.java @ 38:cb25e343e317
more comments and refactorings.
author | casties |
---|---|
date | Wed, 12 Oct 2016 20:51:35 +0200 |
parents | 3485498af8c3 |
children | 86c343109257 |
line wrap: on
line diff
--- a/src/main/java/org/mpi/openmind/cache/WrapperService.java Wed Oct 12 15:33:56 2016 +0200 +++ b/src/main/java/org/mpi/openmind/cache/WrapperService.java Wed Oct 12 20:51:35 2016 +0200 @@ -123,18 +123,16 @@ // Print Maximum available memory logger.info("Max Memory:" + runtime.maxMemory() / mb + "\n"); } catch (Exception e) { - e.printStackTrace(); + logger.error(e); } if (!this.cache.areDefsLoaded()) { - // List<Entity> list = this.searchServ.getEntities(null, - // Node.SYS_STATUS_CURRENT_VERSION, Node.TYPE_TBOX, null); - // this.cache.initDefs(list); try { - this.cache.initDefinitions(getPS().getLWDefinitions(), getPS() - .getDefAttributes(), getPS().getDefRelations()); + this.cache.initDefinitions(getPS().getLWDefinitions(), + getPS().getDefAttributes(), + getPS().getDefRelations()); } catch (Exception e) { - e.printStackTrace(); + logger.error(e); } } } @@ -730,41 +728,58 @@ public List<Attribute> getDefRelationAttributes(Long id) { return this.cache.getDefAttributesById(id); } - - public List<Attribute> getDefAttributes(String ow) { - return this.cache.getDefAttributes(ow); + + /** + * Returns the attributes of the definition of the given type. + * + * @param objectClass + * @return + */ + public List<Attribute> getDefAttributes(String objectClass) { + return this.cache.getDefAttributes(objectClass); } - public List<Relation> getDefSourceRelations(String ow) { - return this.cache.getDefSourceRelations(ow); + /** + * Returns the source relations of the definition of the given type. + * + * @param objectClass + * @return + */ + public List<Relation> getDefSourceRelations(String objectClass) { + return this.cache.getDefSourceRelations(objectClass); } - public List<Relation> getDefTargetRelations(String ow) { - return this.cache.getDefTargetRelations(ow); + /** + * Returns the target relations of the definition of the given type. + * + * @param objectClass + * @return + */ + public List<Relation> getDefTargetRelations(String objectClass) { + return this.cache.getDefTargetRelations(objectClass); } public Entity getDefinitionById(Long id) { return this.cache.getLWDefinitionById(id); - /* - * Entity def = cache.getDefinitionById(id); if(def == null){ - * List<Entity> list = this.searchServ.getEntities(id, - * Node.SYS_STATUS_CURRENT_VERSION, Node.TYPE_TBOX, null); if - * (list.size() > 0) { def = list.get(0); cache.saveDefinition(def); } } - * return def; - */ } + /** + * Returns all (lightweight) definition entities. + * + * @return + */ public List<Entity> getLWDefinitions() { return this.cache.getLWDefinitions(); - /* - * List<Entity> defs = this.cache.getDefinitions(); - * Collections.sort(defs, new EntitySortByNormalizedOwnValue()); return - * defs; - */ } - public Entity getDefinition(String ownValue) { - return this.cache.getLWDefinition(ownValue); + /** + * Returns the (lightweight) definition entity for the given type. + * + * @param objectClass + * @return + */ + public Entity getDefinition(String objectClass) { + return this.cache.getLWDefinition(objectClass); } public List<Relation> getRelation(String name, String srcOC, String tarOC) @@ -1048,6 +1063,13 @@ null, Node.TYPE_ABOX, objectClass, ownValue, true, maxResult); } + /** + * Save the entity. Calls {@link #saveEntity(String, String)}. + * + * @param entity + * @param user + * @throws Exception + */ public void saveAssertion(Entity entity, String user) throws Exception { this.saveEntity(entity, user); }