コード例 #1
0
ファイル: Importer.java プロジェクト: eonum/eonum-server
 /** Considering name and address as combined inverse functional property */
 public void smush() {
   final Map<String, Set<GraphNode>> equalityMap = new HashMap<String, Set<GraphNode>>();
   final LockableMGraph dataGraph = getDataGraph();
   Lock l = dataGraph.getLock().writeLock();
   l.lock();
   try {
     final Iterator<Triple> triples = dataGraph.filter(null, RDF.type, ADDRESSES.Address);
     while (triples.hasNext()) {
       final GraphNode gn = new GraphNode(triples.next().getSubject(), dataGraph);
       final String name = gn.getLiterals(ADDRESSES.name).next().getLexicalForm();
       final String address = gn.getLiterals(ADDRESSES.address).next().getLexicalForm();
       final String key = name + address;
       final Set<GraphNode> set =
           equalityMap.containsKey(key) ? equalityMap.get(key) : new HashSet<GraphNode>();
       set.add(gn);
       equalityMap.put(key, set);
     }
   } finally {
     l.unlock();
   }
   for (Set<GraphNode> equalitySet : equalityMap.values()) {
     final Iterator<GraphNode> iter = equalitySet.iterator();
     final GraphNode first = iter.next();
     while (iter.hasNext()) {
       iter.next().replaceWith((NonLiteral) first.getNode());
     }
   }
 }
コード例 #2
0
ファイル: Importer.java プロジェクト: eonum/eonum-server
 public void addType() {
   final LockableMGraph dataGraph = getDataGraph();
   Lock l = dataGraph.getLock().writeLock();
   l.lock();
   try {
     final Iterator<Triple> triples = dataGraph.filter(null, ADDRESSES.name, null);
     final Collection<NonLiteral> addresses = new HashSet<NonLiteral>();
     while (triples.hasNext()) {
       NonLiteral address = triples.next().getSubject();
       addresses.add(address);
     }
     for (NonLiteral address : addresses) {
       dataGraph.add(new TripleImpl(address, RDF.type, ADDRESSES.Address));
     }
   } finally {
     l.unlock();
   }
 }