Skip to content

Commit

Permalink
Removed unused methods. Removed empty categories.
Browse files Browse the repository at this point in the history
  • Loading branch information
kvb2univpitt committed Feb 12, 2016
1 parent 5affb87 commit 867a6a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public String showPlot(
model.addAttribute("link", url);

String username = appUser.getUsername();
List<String> categoryNames = Arrays.asList("Data File", "Dataset Read In", "Runtime Parameters", "Algorithm Parameters");
List<String> categoryNames = Arrays.asList("Data File", "Dataset Read In", "Runtime Parameters", "Algorithm Parameters", "Datasets", "Graph Parameters");
model.addAttribute("categories", algorithmResultService.extractDataCategories(fileName, username, categoryNames));

return PLOT_VIEW;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -196,61 +196,20 @@ public Map<String, Map<String, String>> extractDataCategories(final String fileN
LOGGER.error(String.format("Unable to read file '%s'.", fileName), exception);
}

return info;
}

public List<String> extractDatasetNames(final String fileName, final String username) {
List<String> datasets = new LinkedList<>();

Path file = Paths.get(workspace, username, resultFolder, algorithmResultFolder, fileName);
try (BufferedReader reader = Files.newBufferedReader(file, Charset.defaultCharset())) {
boolean isDatasets = false;
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
line = line.trim();

if (isDatasets) {
if (line.isEmpty()) {
break;
} else {
datasets.add(line);
}
} else if ("Datasets:".equals(line)) {
isDatasets = true;
}
}
} catch (IOException exception) {
LOGGER.error(String.format("Unable to read file '%s'.", fileName), exception);
}

return datasets;
}

public Map<String, String> extractPlotParameters(final String fileName, final String username) {
Map<String, String> parameters = new TreeMap<>();

Path file = Paths.get(workspace, username, resultFolder, algorithmResultFolder, fileName);
try (BufferedReader reader = Files.newBufferedReader(file, Charset.defaultCharset())) {
Pattern equalDelim = Pattern.compile("=");
boolean isParamters = false;
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
line = line.trim();

if (isParamters) {
String[] data = equalDelim.split(line);
if (data.length == 2) {
parameters.put(data[0].trim(), data[1].trim());
} else {
break;
}
} else if ("Graph Parameters:".equals(line)) {
isParamters = true;
}
// clean up
List<String> trash = new LinkedList<>();
Set<String> keySet = info.keySet();
keySet.forEach(key -> {
Map<String, String> map = info.get(key);
if (map.isEmpty()) {
trash.add(key);
}
} catch (IOException exception) {
LOGGER.error(String.format("Unable to read file '%s'.", fileName), exception);
}
});
trash.forEach(key -> {
info.remove(key);
});

return parameters;
return info;
}

public List<Node> extractGraphNodes(final String fileName, final String username) {
Expand Down

0 comments on commit 867a6a2

Please sign in to comment.