comparison src/main/java/org/mpi/openmind/cache/WrapperService.java @ 67:ae732119447f

small fixes.
author casties
date Tue, 31 Jan 2017 18:08:55 +0100
parents 3e4b05a6cb47
children 677492395dc0
comparison
equal deleted inserted replaced
66:3e4b05a6cb47 67:ae732119447f
666 entity = removeEmptyAttributes(entity); 666 entity = removeEmptyAttributes(entity);
667 667
668 txLog.debug("** START save entity: user="+user+" entity="+entity.toSmallString()); 668 txLog.debug("** START save entity: user="+user+" entity="+entity.toSmallString());
669 // check if entity is up to date with cache 669 // check if entity is up to date with cache
670 if (!cache.isEntityCurrent(entity)) { 670 if (!cache.isEntityCurrent(entity)) {
671 logger.error("Possible collision: Entity to save not current!"); 671 logger.warn("Possible collision: Entity to save not current!");
672 // create differences from cache 672 // create differences from cache
673 EntityDiff diff = cache.diffEntityCache(entity, true); 673 EntityDiff diff = cache.diffEntityCache(entity, true);
674 if (diff != null) { 674 if (diff != null) {
675 if (intent != null) { 675 if (intent != null) {
676 /* 676 /*
728 // re-add 728 // re-add
729 entity.addTargetRelation(r); 729 entity.addTargetRelation(r);
730 } 730 }
731 } 731 }
732 } else { 732 } else {
733 logger.warn("save without EditIntent!"); 733 logger.warn("Save with missing EditIntent!");
734 } 734 }
735 } else {
736 logger.warn("but no difference to cache found.");
735 } 737 }
736 } 738 }
737 739
738 // save in database 740 // save in database
739 this.getPS().saveEntity(entity); 741 this.getPS().saveEntity(entity);
950 String relationName, String srcObjClass, int maxResult) { 952 String relationName, String srcObjClass, int maxResult) {
951 List<Entity> rs = new ArrayList<Entity>(); 953 List<Entity> rs = new ArrayList<Entity>();
952 954
953 List<Relation> tarRelList = this.cache.getRelsByTarId(tarId); 955 List<Relation> tarRelList = this.cache.getRelsByTarId(tarId);
954 956
955 long start = System.currentTimeMillis(); 957 //long start = System.currentTimeMillis();
956 int count = 0; 958 int count = 0;
957 for (Relation rel : tarRelList) { 959 for (Relation rel : tarRelList) {
958 if (stringEquals(relationName, rel.getOwnValue()) 960 if (stringEquals(relationName, rel.getOwnValue())
959 && stringEquals(srcObjClass, rel.getSourceObjectClass())) { 961 && stringEquals(srcObjClass, rel.getSourceObjectClass())) {
960 Entity ent = getEntityByIdReadOnly(rel.getSourceId()); 962 Entity ent = getEntityByIdReadOnly(rel.getSourceId());
1033 return rs; 1035 return rs;
1034 } 1036 }
1035 1037
1036 public List<Relation> getTargetRelations(Entity target, 1038 public List<Relation> getTargetRelations(Entity target,
1037 String relationName, String srcObjClass, int maxResult) { 1039 String relationName, String srcObjClass, int maxResult) {
1038 long start = System.currentTimeMillis(); 1040 //long start = System.currentTimeMillis();
1039 List<Relation> list = new ArrayList<Relation>(); 1041 List<Relation> list = new ArrayList<Relation>();
1040 1042
1041 List<Relation> tarRelList = this.cache.getRelsByTarId(target.getId()); 1043 List<Relation> tarRelList = this.cache.getRelsByTarId(target.getId());
1042 /*
1043 * if(coll == null){ coll = this.getPS().getTargetRelations(target,
1044 * null, null, -1, false); cache.setRelsForTar(target.getId(), coll); }
1045 */
1046 1044
1047 int count = 0; 1045 int count = 0;
1048 for (Relation rel : tarRelList) { 1046 for (Relation rel : tarRelList) {
1049 if (stringEquals(relationName, rel.getOwnValue()) 1047 if (stringEquals(relationName, rel.getOwnValue())
1050 && stringEquals(srcObjClass, rel.getSourceObjectClass())) { 1048 && stringEquals(srcObjClass, rel.getSourceObjectClass())) {
1056 count++; 1054 count++;
1057 if (maxResult > 0 && count == maxResult) { 1055 if (maxResult > 0 && count == maxResult) {
1058 break; 1056 break;
1059 } 1057 }
1060 } else { 1058 } else {
1061 logger.error("#########ERROR: Relation without source " 1059 logger.error("Relation without source: "+ rel.toString());
1062 + rel.toString());
1063 } 1060 }
1064 1061
1065 } 1062 }
1066 } 1063 }
1067 Collections.sort(list, new RelationSortBySourceOW()); 1064 Collections.sort(list, new RelationSortBySourceOW());
1080 */ 1077 */
1081 public List<Relation> getSourceRelations(Entity source, 1078 public List<Relation> getSourceRelations(Entity source,
1082 String relationName, String tarObjClass, int maxResult) 1079 String relationName, String tarObjClass, int maxResult)
1083 throws Exception { 1080 throws Exception {
1084 1081
1085 long start = System.currentTimeMillis(); 1082 //long start = System.currentTimeMillis();
1086 List<Relation> list = new ArrayList<Relation>(); 1083 List<Relation> list = new ArrayList<Relation>();
1087 1084
1088 // the collection coll should not be modified 1085 // the collection coll should not be modified
1089 // otherwise java.util.ConcurrentModificationException will be thrown. 1086 // otherwise java.util.ConcurrentModificationException will be thrown.
1090 // be carefully using getEntityContent, cause it changes the cache 1087 // be carefully using getEntityContent, cause it changes the cache