From 41c9ae921d6fa4bb71e521f138a22f09df57fd18 Mon Sep 17 00:00:00 2001
From: Philipp Spohr <spohr.philipp@web.de>
Date: Thu, 17 Aug 2017 21:53:08 +0200
Subject: [PATCH] Missing sanity check

---
 .../ba/yoshikoWrapper/core/NetworkParser.java | 22 +++++++++----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/NetworkParser.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/NetworkParser.java
index 683e86d..3ee5497 100644
--- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/NetworkParser.java
+++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/NetworkParser.java
@@ -39,14 +39,18 @@ public class NetworkParser {
 			//Loop over edges
 			for (CyEdge e : edges) {
 				
-				CyRow edgeEntry = net.getRow(e);
-				
 				//Parse editing costs
 				double weight = deletionCostDefault;
+				
+				//Fetch entry and check if it exists
+				CyRow edgeEntry = net.getRow(e);
+				
+				//Check if there is a weight column defined, else skip
 				if (weightColumn != null){
-					System.out.println("Using column: "+weightColumn.getName());
-					try {
-						//Find out if the weights are double or int
+					//Check if the column contains an entry for the respective edge
+					//It is possible, that there are missing entries
+					if (edgeEntry.getAllValues().containsKey(weightColumn.getName())){
+						//Find out if the weights are double or integer and cast accordingly
 						Class<?> weightType = weightColumn.getType();
 						if (weightType == Integer.class) {
 							weight = (int)edgeEntry.get(weightColumn.getName(), weightType);
@@ -54,14 +58,10 @@ public class NetworkParser {
 						else if(weightType == Double.class) {
 							weight = (double)edgeEntry.get(weightColumn.getName(), weightType);
 						}
-					}
-					catch(Exception ex) {
-						ex.printStackTrace();
-						//Invalid entry (no entry)
-						logger.info("No valid edit costs defined for: "+edgeEntry.get("name", String.class)+", falling back to default value!");
+		
 					}
 				}
-				
+
 				//Parse Forbidden/Permanent markers
 				boolean forbidden = false;
 				boolean permanent = false;
-- 
GitLab