Changeset 6700
- Timestamp:
- 10/26/15 14:14:48 (9 years ago)
- Location:
- vlo/branches/vlo-3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/branches/vlo-3.3
- Property svn:mergeinfo changed
/vlo/trunk merged: 6698-6699
- Property svn:mergeinfo changed
-
vlo/branches/vlo-3.3/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/MetadataImporter.java
r6658 r6700 48 48 * and so on. 49 49 */ 50 @SuppressWarnings({"serial"})51 50 public class MetadataImporter { 52 51 … … 229 228 * list of existing data roots will be filtered with the list from user 230 229 * 231 * @return 230 * @param dataRoots complete list of DataRoots 231 * @return list of DataRoots without DataRoots excluded by the user 232 232 */ 233 233 protected List<DataRoot> filterDataRootsWithCLArgs(List<DataRoot> dataRoots){ … … 366 366 // are usually not very interesting (think imdi corpus files) and will not be included. 367 367 updateDocument(solrDocument, cmdiData, file, dataOrigin); 368 if(ResourceStructureGraph.getVertex(cmdiData.getId()) != null) 369 ResourceStructureGraph.getVertex(cmdiData.getId()).setWasImported(true); 368 370 } else { 369 371 nrOfIgnoredFiles++; … … 549 551 } 550 552 553 // remove vertices that were not imported 554 Iterator<String> incomingVertexIter = incomingVertexNames.iterator(); 555 while(incomingVertexIter.hasNext()) { 556 String vertexId = incomingVertexIter.next(); 557 if(ResourceStructureGraph.getVertex(vertexId) == null || !ResourceStructureGraph.getVertex(vertexId).getWasImported()) 558 incomingVertexIter.remove(); 559 } 560 Iterator<String> outgoingVertexIter = outgoingVertexNames.iterator(); 561 while(outgoingVertexIter.hasNext()) { 562 String vertexId = outgoingVertexIter.next(); 563 if(ResourceStructureGraph.getVertex(vertexId) == null || !ResourceStructureGraph.getVertex(vertexId).getWasImported()) 564 outgoingVertexIter.remove(); 565 } 566 551 567 if(!incomingVertexNames.isEmpty()) { 552 568 doc.setField(FacetConstants.FIELD_HAS_PART, incomingVertexNames); -
vlo/branches/vlo-3.3/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/ResourceStructureGraph.java
r6213 r6700 53 53 */ 54 54 public static void addResource(String mdSelfLink) { 55 if (!vertexIdMap.containsKey(mdSelfLink)) { 56 CmdiVertex newVertex = new CmdiVertex(StringUtils.normalizeIdString(mdSelfLink)); 57 vertexIdMap.put(mdSelfLink, newVertex); 58 } 59 60 if (!foundVerticesSet.contains(vertexIdMap.get(mdSelfLink))) { 61 graph.addVertex(vertexIdMap.get(mdSelfLink)); 62 foundVerticesSet.add(vertexIdMap.get(mdSelfLink)); 55 String normalizedMdSelfLink = StringUtils.normalizeIdString(mdSelfLink); 56 if (!vertexIdMap.containsKey(normalizedMdSelfLink)) { 57 CmdiVertex newVertex = new CmdiVertex(normalizedMdSelfLink); 58 vertexIdMap.put(normalizedMdSelfLink, newVertex); 59 } 60 61 if (!foundVerticesSet.contains(vertexIdMap.get(normalizedMdSelfLink))) { 62 graph.addVertex(vertexIdMap.get(normalizedMdSelfLink)); 63 foundVerticesSet.add(vertexIdMap.get(normalizedMdSelfLink)); 63 64 } else { 64 65 LOG.debug("Duplicate resource vertex mdSelfLink: " + mdSelfLink); … … 73 74 */ 74 75 public static void addEdge(String sourceVertexId, String targetVertexId) { 76 String normalizedSourceVertexId = StringUtils.normalizeIdString(sourceVertexId); 77 String normalizedTargetVertexId = StringUtils.normalizeIdString(targetVertexId); 78 75 79 // add vertices 76 if (!vertexIdMap.containsKey( sourceVertexId)) {77 CmdiVertex sourceVertex = new CmdiVertex( StringUtils.normalizeIdString(sourceVertexId));78 vertexIdMap.put( sourceVertexId, sourceVertex);80 if (!vertexIdMap.containsKey(normalizedSourceVertexId)) { 81 CmdiVertex sourceVertex = new CmdiVertex(normalizedSourceVertexId); 82 vertexIdMap.put(normalizedSourceVertexId, sourceVertex); 79 83 graph.addVertex(sourceVertex); 80 84 } 81 85 82 if (!vertexIdMap.containsKey( targetVertexId)) {83 CmdiVertex targetVertex = new CmdiVertex( StringUtils.normalizeIdString(targetVertexId));84 vertexIdMap.put( targetVertexId, targetVertex);86 if (!vertexIdMap.containsKey(normalizedTargetVertexId)) { 87 CmdiVertex targetVertex = new CmdiVertex(normalizedTargetVertexId); 88 vertexIdMap.put(normalizedTargetVertexId, targetVertex); 85 89 graph.addVertex(targetVertex); 86 90 } … … 88 92 // add edge 89 93 try { 90 graph.addEdge(vertexIdMap.get( sourceVertexId), vertexIdMap.get(targetVertexId));91 updateDepthValues(vertexIdMap.get( sourceVertexId), new HashSet<CmdiVertex>());94 graph.addEdge(vertexIdMap.get(normalizedSourceVertexId), vertexIdMap.get(normalizedTargetVertexId)); 95 updateDepthValues(vertexIdMap.get(normalizedSourceVertexId), new HashSet<CmdiVertex>()); 92 96 } catch (IllegalArgumentException cfe) { 93 97 // was a cycle -> ignore … … 162 166 return foundVerticesSet; 163 167 } 168 169 public static CmdiVertex getVertex(String vertexId) { 170 return vertexIdMap.get(vertexId); 171 } 172 173 public static Map<String, CmdiVertex> getVertexIdMap() { 174 return vertexIdMap; 175 } 164 176 165 177 /** 166 178 * Get all vertices that are source of an edge where targetVertex is target. 167 * In other words get all vertices that are part oftargetVertex.179 * In other words get all resource vertices that are part of resource targetVertex. 168 180 * 169 181 * @param targetVertex … … 187 199 /** 188 200 * Get all vertices that are target of an edge where sourceVertex is source. 189 * In other words get all vertices of whichsourceVertex is part of.201 * In other words get all resource vertices of which resource sourceVertex is part of. 190 202 * 191 203 * @param sourceVertex … … 273 285 private final String id; 274 286 private int hierarchyWeight = 0; 287 private boolean wasImported = false; 275 288 276 289 public CmdiVertex(String id) { … … 288 301 public int getHierarchyWeight() { 289 302 return hierarchyWeight; 303 } 304 305 public void setWasImported(boolean wasImported) { 306 this.wasImported = wasImported; 307 } 308 309 public boolean getWasImported() { 310 return wasImported; 290 311 } 291 312
Note: See TracChangeset
for help on using the changeset viewer.