Changeset 6698
- Timestamp:
- 10/26/15 14:02:22 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/trunk/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/ResourceStructureGraph.java
r6213 r6698 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.