Mercurial > hg > openmind
view src/main/java/org/mpi/openmind/scripts/recovery/RecoveryCache.java @ 112:933d17f95016
new script MigratePrimeAliases to migrate is_prime_alias_X_of.
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Wed, 14 Aug 2019 20:48:02 +0200 |
parents | 615d27dce9b3 |
children |
line wrap: on
line source
package org.mpi.openmind.scripts.recovery; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import org.mpi.openmind.repository.bo.Entity; import org.mpi.openmind.repository.bo.Relation; import cl.maps.triple.TripleKey; import cl.maps.triple.TripleMap; public class RecoveryCache { private TripleMap<Relation, Long, Long, Long> relMap = new TripleMap<Relation, Long, Long, Long>(); private Map<Long, Entity> entMap = new HashMap<Long, Entity>(); public Collection<Entity> getEnts(){ return entMap.values(); } public Collection<Relation> getRels(){ return relMap.values(); } public void addEnt(Entity ent){ if(!entMap.containsKey(ent.getId())){ entMap.put(ent.getId(), ent); } } public void addRel(Relation rel){ TripleKey<Long, Long, Long> key = new TripleKey<Long, Long, Long>(rel.getSourceId(), rel.getTargetId(), rel.getId()); relMap.put(key, rel); } public List<Relation> getRelBySrc(Long srcId){ return this.relMap.getValuesByAKey(srcId); } public List<Relation> getRelByTar(Long tarId){ return this.relMap.getValuesByBKey(tarId); } public boolean existEnt(Long id){ return entMap.containsKey(id); } }