Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into UdatingCICDForCLI
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeByDrescher committed Sep 6, 2024
2 parents 0bb4d23 + ab40a71 commit d575fb2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 31 deletions.
52 changes: 22 additions & 30 deletions vcell-cli/src/main/java/org/vcell/cli/run/OmexHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
import java.net.URI;
import java.nio.file.*;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.*;

public class OmexHandler {
String tempPath;
Expand Down Expand Up @@ -111,40 +108,35 @@ public static void rename(String zipFileName, String entryOldName, String entryN
}
}

public ArrayList<String> getSedmlLocationsRelative(){
ArrayList<String> sedmlList = new ArrayList<>();

public List<String> getSedmlLocationsRelative(){
Collection<ArchiveEntry> entries = this.archive.getEntries();

int MASTER = 1;
int REGULAR = 2;
int masterCount = 0;
Map<Integer, ArrayList<ArchiveEntry>> sedmlMap = new HashMap<>();
sedmlMap.put(MASTER, new ArrayList<>());
sedmlMap.put(REGULAR, new ArrayList<>());


for (ArchiveEntry entry : entries) {
if (entry.isMainEntry()) {
if (isSedmlFormat(entry)) {
masterCount++;
} else {
throw new RuntimeException("No SED-ML's are intended to be executed (non SED-ML file is set to be master)");
}
}
boolean isMaster = entry.isMainEntry();
if (isMaster) masterCount++;
if (!this.isSedmlFormat(entry)) continue;
sedmlMap.get(isMaster ? MASTER : REGULAR).add(entry);
}

if( masterCount > 1) {
throw new RuntimeException("More than two master SED-ML's found");
}
// Test corner cases
if (sedmlMap.get(MASTER).isEmpty()){
if (masterCount > 0)
throw new RuntimeException("No SED-MLs are intended to be executed (non SED-ML file is set to be master)");
if (sedmlMap.get(REGULAR).isEmpty())
throw new RuntimeException("There are no SED-MLs in the archive to execute");

for (ArchiveEntry entry : entries) {
if(masterCount == 0 ) {
if (isSedmlFormat(entry)) {
sedmlList.add(entry.getFilePath());
}
} else {
if (isSedmlFormat(entry) && entry.isMainEntry()) {
sedmlList.add(entry.getFilePath());
}
}
return sedmlMap.get(REGULAR).stream().map(ArchiveEntry::getFilePath).toList();
}

return sedmlList;
return sedmlMap.get(MASTER).stream().map(ArchiveEntry::getFilePath).toList();
}

private boolean isSedmlFormat(ArchiveEntry entry) {
Expand All @@ -155,7 +147,7 @@ private boolean isSedmlFormat(ArchiveEntry entry) {

public ArrayList<String> getSedmlLocationsAbsolute(){
ArrayList<String> sedmlListAbsolute = new ArrayList<>();
ArrayList<String> sedmlListRelative = this.getSedmlLocationsRelative();
List<String> sedmlListRelative = this.getSedmlLocationsRelative();

for (String sedmlFileRelative : sedmlListRelative) {
sedmlListAbsolute.add(Paths.get(this.tempPath, sedmlFileRelative).normalize().toString());
Expand All @@ -166,7 +158,7 @@ public ArrayList<String> getSedmlLocationsAbsolute(){
public String getOutputPathFromSedml(String absoluteSedmlPath) {
String outputPath = "";
//String sedmlName = absoluteSedmlPath.substring(absoluteSedmlPath.lastIndexOf(File.separator) + 1);
ArrayList<String> sedmlListRelative = this.getSedmlLocationsRelative();
List<String> sedmlListRelative = this.getSedmlLocationsRelative();
for (String sedmlFileRelative : sedmlListRelative) {
boolean check = absoluteSedmlPath.contains(Paths.get(sedmlFileRelative).normalize().toString());
if (check) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ public String getModelString(Model m) {
try {
String modelRef = baseModelRef;
do {
srcURI = sedml.getModelWithId(modelRef).getSourceURI();
org.jlibsedml.Model mod = sedml.getModelWithId(modelRef);
URI testURI = new URI("test%20model.xml");
String roundTrip = testURI.toASCIIString();
roundTrip = testURI.toString();
srcURI = mod.getSourceURI();
// If we need to recurse to the next level:
modelRef = sedml.getModelWithId(modelRef.startsWith("#") ?
modelRef.substring(1): modelRef).getSourcePathOrURIString();
Expand Down

0 comments on commit d575fb2

Please sign in to comment.