Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added WorkbenchProject/Cache/hostname.encrypted
Binary file not shown.
Binary file added WorkbenchProject/Cache/username.encrypted
Binary file not shown.
Binary file added WorkbenchProject/Key
Binary file not shown.
Binary file added WorkbenchProject/LastSimulation/message
Binary file not shown.
108 changes: 108 additions & 0 deletions WorkbenchProject/LastSimulation/model.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2000/10/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix remote: <otachi.uwb.edu#> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix local: <DESKTOP-3N8B16A@205.175.118.10#> .

<local:~/WorkbenchSimulations/trial404/configfilestrial404.xml>
a prov:Entity ;
rdfs:label "simulationConfigurationFile" ;
prov:wasDerivedFrom <local:C:/Users/Administrator/WorkbenchProjects/Default/trial404/configfiles/trial404.xml> ;
prov:wasGeneratedBy <local:upload_SimConfig> .

<local:~/WorkbenchSimulations/trial404/configfiles/NListActiveNList.xml>
a prov:Entity ;
rdfs:label "nlist" ;
prov:wasDerivedFrom <local:C:/Users/Administrator/WorkbenchProjects/Default/trial404/configfiles/NList/ActiveNList.xml> ;
prov:wasGeneratedBy <local:upload_ACTIVE_NList> .

<local:upload_SimConfig>
a prov:Activity ;
rdfs:label "upload" ;
prov:endedAtTime "2023-03-01T00:04:26.626Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
prov:generated <local:~/WorkbenchSimulations/trial404/configfilestrial404.xml> ;
prov:startedAtTime "2023-03-01T00:04:26.298Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
prov:used <local:C:/Users/Administrator/WorkbenchProjects/Default/trial404/configfiles/trial404.xml> ;
prov:wasAssociatedWith <local:workbench> .

<local:C:/Users/Administrator/WorkbenchProjects/Default/trial404/configfiles/NList/ActiveNList.xml>
a prov:Entity ;
rdfs:label "nlist" .

<local:~/WorkbenchSimulations/trial404/configfiles/NListprobedNList.xml>
a prov:Entity ;
rdfs:label "nlist" ;
prov:wasDerivedFrom <local:C:/Users/Administrator/WorkbenchProjects/Default/trial404/configfiles/NList/probedNList.xml> ;
prov:wasGeneratedBy <local:upload_PROBED_NList> .

<local:C:/Users/Administrator/WorkbenchProjects/Default/trial404/configfiles/NList/probedNList.xml>
a prov:Entity ;
rdfs:label "nlist" .

<local:uploadScript> a prov:Activity ;
rdfs:label "upload" ;
prov:endedAtTime "2023-03-01T00:04:25.333Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
prov:generated <local:~/WorkbenchSimulations/trial404/trial404_script.sh> ;
prov:startedAtTime "2023-03-01T00:04:25.026Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
prov:used <local:C:/Users/Administrator/WorkbenchProjects/Default/trial404/script/trial404_script.sh> ;
prov:wasAssociatedWith <local:workbench> .

<local:workbench> a prov:SoftwareAgent .

<local:upload_INHIBITORY_NList>
a prov:Activity ;
rdfs:label "upload" ;
prov:endedAtTime "2023-03-01T00:04:25.99Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
prov:generated <local:~/WorkbenchSimulations/trial404/configfiles/NListInhibitoryNList.xml> ;
prov:startedAtTime "2023-03-01T00:04:25.682Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
prov:used <local:C:/Users/Administrator/WorkbenchProjects/Default/trial404/configfiles/NList/InhibitoryNList.xml> ;
prov:wasAssociatedWith <local:workbench> .

<local:upload_PROBED_NList>
a prov:Activity ;
rdfs:label "upload" ;
prov:endedAtTime "2023-03-01T00:04:26.298Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
prov:generated <local:~/WorkbenchSimulations/trial404/configfiles/NListprobedNList.xml> ;
prov:startedAtTime "2023-03-01T00:04:25.991Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
prov:used <local:C:/Users/Administrator/WorkbenchProjects/Default/trial404/configfiles/NList/probedNList.xml> ;
prov:wasAssociatedWith <local:workbench> .

<local:C:/Users/Administrator/WorkbenchProjects/Default/trial404/configfiles/NList/InhibitoryNList.xml>
a prov:Entity ;
rdfs:label "nlist" .

<local:upload_ACTIVE_NList>
a prov:Activity ;
rdfs:label "upload" ;
prov:endedAtTime "2023-03-01T00:04:25.682Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
prov:generated <local:~/WorkbenchSimulations/trial404/configfiles/NListActiveNList.xml> ;
prov:startedAtTime "2023-03-01T00:04:25.333Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
prov:used <local:C:/Users/Administrator/WorkbenchProjects/Default/trial404/configfiles/NList/ActiveNList.xml> ;
prov:wasAssociatedWith <local:workbench> .

<local:simulation_input_file_generation>
a prov:Activity ;
prov:generated <local:C:/Users/Administrator/WorkbenchProjects/Default/trial404/configfiles/trial404.xml> ;
prov:wasAssociatedWith <local:workbench> .

<local:C:/Users/Administrator/WorkbenchProjects/Default/trial404/configfiles/trial404.xml>
a prov:Entity ;
rdfs:label "simulationConfigurationFile" ;
prov:wasGeneratedBy <local:simulation_input_file_generation> .

<local:~/WorkbenchSimulations/trial404/configfiles/NListInhibitoryNList.xml>
a prov:Entity ;
rdfs:label "nlist" ;
prov:wasDerivedFrom <local:C:/Users/Administrator/WorkbenchProjects/Default/trial404/configfiles/NList/InhibitoryNList.xml> ;
prov:wasGeneratedBy <local:upload_INHIBITORY_NList> .

<local:C:/Users/Administrator/WorkbenchProjects/Default/trial404/script/trial404_script.sh>
a prov:Entity ;
rdfs:label "script" .

<local:~/WorkbenchSimulations/trial404/trial404_script.sh>
a prov:Entity ;
rdfs:label "script" ;
prov:wasDerivedFrom <local:C:/Users/Administrator/WorkbenchProjects/Default/trial404/script/trial404_script.sh> ;
prov:wasGeneratedBy <local:uploadScript> .
Binary file added WorkbenchProject/LastSimulation/simName
Binary file not shown.
Binary file added WorkbenchProject/LastSimulation/simdir
Binary file not shown.
Binary file added WorkbenchProject/LastSimulation/simulation
Binary file not shown.
3 changes: 3 additions & 0 deletions WorkbenchProject/LastSimulation/uri
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
C:\Users\Administrator\WorkbenchProjects\Default\trial404\provenance\trial404.ttl
DESKTOP-3N8B16A@205.175.118.10#
null
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.Serializable;
import java.net.InetAddress;
import java.net.URL;
import java.net.URLConnection;
Expand Down Expand Up @@ -50,7 +51,7 @@
* @author Del Davis, Extended by Joseph Conquest
* @version 1.2
*/
public class ProvMgr {
public class ProvMgr implements Serializable {

// <editor-fold defaultstate="collapsed" desc="Members">
private static final Logger LOG = Logger.getLogger(ProvMgr.class.getName());
Expand All @@ -63,14 +64,58 @@ public class ProvMgr {
public static final String LOCAL_NS_PREFIX = "local";

/* URIs used to describe the provenance */
private String provOutputFileURI;
private String localNameSpaceURI;
private String remoteNameSpaceURI;
private String provOutputFileUri;
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
private String localNameSpaceUri;
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
private String remoteNameSpaceUri;
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated

/* RDF in-memory representation of the provenance */
private Model model;
// </editor-fold>

/**
* The getter for provURI.
*
* @return return the provURI.
*
*/
public String getProvUri() {
return provOutputFileUri;
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
}

/**
* The getter for LocalURI.
*
* @return return the LocalURI.
*
*/
public String getLocalUri() {
return localNameSpaceUri;
}

/**
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
* The getter for RemoteURI.
*
* @return return the RemoteURI.
*
*/
public String getRemoteUri() {
return remoteNameSpaceUri;
}
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
/**
* The constructor used by resume Lastsimulation.
*
* @param provURI the provURI
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
* @param localURI the localURI
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
* @param remoteURI the remoteURI
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
* @param model the model
*/
public ProvMgr(String provURI, String localURI, String remoteURI, Model model) {
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
this.provOutputFileUri = provURI;
this.localNameSpaceUri = localURI;
this.remoteNameSpaceUri = remoteURI;
this.model = model;
}
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated

// <editor-fold defaultstate="collapsed" desc="Construction">
/**
* Constructs the Provenance Constructor object from a previously recorded provenance file.
Expand All @@ -97,7 +142,7 @@ public ProvMgr(Simulation simulation, boolean load) throws IOException, RiotNotF
private void init(Simulation simulation) {
// create RDF model
model = ModelFactory.createDefaultModel();
provOutputFileURI = simulation.getProvLocation()
provOutputFileUri = simulation.getProvLocation()
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
.resolve(simulation.getName() + ".ttl").toString();
// set prefixes for...
// RDF syntax
Expand All @@ -108,9 +153,9 @@ private void init(Simulation simulation) {
model.setNsPrefix("prov", ProvOntology.getPROVNameSpaceURI());
// XML schema
model.setNsPrefix("xsd", ProvOntology.getXSDNameSpaceURI());
localNameSpaceURI = getLocalNameSpaceURI();
localNameSpaceUri = getLocalNameSpaceURI();
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
// Graphitti Prov
model.setNsPrefix(LOCAL_NS_PREFIX, localNameSpaceURI);
model.setNsPrefix(LOCAL_NS_PREFIX, localNameSpaceUri);
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
}

/**
Expand All @@ -120,10 +165,10 @@ private void init(Simulation simulation) {
*/
private void load(Simulation simulation) throws RiotNotFoundException {
String name = simulation.getName();
provOutputFileURI = simulation.getProvLocation().resolve(name + ".ttl").toString();
model = RDFDataMgr.loadModel(provOutputFileURI);
localNameSpaceURI = getLocalNameSpaceURI();
model.setNsPrefix(LOCAL_NS_PREFIX, localNameSpaceURI);
provOutputFileUri = simulation.getProvLocation().resolve(name + ".ttl").toString();
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
model = RDFDataMgr.loadModel(provOutputFileUri);
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
localNameSpaceUri = getLocalNameSpaceURI();
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
model.setNsPrefix(LOCAL_NS_PREFIX, localNameSpaceUri);
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
trimRemoteNS();
}

Expand All @@ -137,8 +182,8 @@ private void trimRemoteNS() {
String nameSpace = entry.getKey();
String uri = entry.getValue();
if (nameSpace.startsWith(REMOTE_NS_PREFIX)) {
remoteNameSpaceURI = uri.substring(uri.lastIndexOf('/') + 1);
model.setNsPrefix(nameSpace, remoteNameSpaceURI);
remoteNameSpaceUri = uri.substring(uri.lastIndexOf('/') + 1);
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
model.setNsPrefix(nameSpace, remoteNameSpaceUri);
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
}
}
}
Expand Down Expand Up @@ -166,8 +211,8 @@ public void setNsPrefix(String prefix, String uri) {
*
* @return The URI of the provenance output file
*/
public String getProvFileURI() {
return provOutputFileURI;
public String getProvFileUri() {
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
return provOutputFileUri;
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,23 @@ public static Path getCurrentProjectDirectory() {
return getProjectsDirectory().resolve(WorkbenchManager.getInstance().getProjectName());
}

private static String workingDir() {
String dir = System.getProperty("user.dir");
String target = "\\target";
if (dir.endsWith(target)) {
dir = dir.substring(0, dir.length() - target.length());
}
return dir;
}

/**
* Provides the working directory of the current user.
*
* @return The working directory of the current user
*/
public static Path getUserDir() {
return Paths.get(System.getProperty("user.dir"));
}
public static Path getUserDir() {
return Paths.get(workingDir());
}

/**
* Provides the home directory of the current user.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.SftpException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
Expand Down Expand Up @@ -56,6 +59,14 @@ public final class WorkbenchManager {
private Project project;
private Simulation simulation;
private ProvMgr prov;

public void simulationSetter(Simulation inputSimulation) {
this.simulation = inputSimulation;
}

public void provMgrSetter(ProvMgr inputProv) {
this.prov = inputProv;
}
// </editor-fold>

// <editor-fold defaultstate="collapsed" desc="Construction">
Expand Down Expand Up @@ -516,26 +527,44 @@ public boolean generateScript() {
* @return True if all files were uploaded/copied successfully and the script was started,
* otherwise false
*/
public boolean runScript() {
boolean success = false;
ScriptManager sm = new ScriptManager();
try {
String simulationName = simulation.getName();
String scriptPath = simulation.getScriptFilePath();
String[] neuronLists = FileManager.getNeuronListFilenames(simulationName);
success = sm.runScript(prov, simulation.getSimSpec(), simulationName, scriptPath,
neuronLists, simulation.getSimConfigFilename());
simulation.setScriptRan(success);
simulation.setScriptStartedAt();
messageAccumulator += sm.getOutstandingMessages();
} catch (JSchException | SftpException | IOException | NullPointerException e) {
messageAccumulator += "\n" + "Script did not run do to "
+ e.getClass() + "...\n";
messageAccumulator += "Exception message: " + e.getMessage();
}

return success;
}
public boolean runScript() {
boolean success = false;
ScriptManager sm = new ScriptManager();
try {
String simulationName = simulation.getName();
String scriptPath = simulation.getScriptFilePath();
String[] neuronLists = FileManager.getNeuronListFilenames(simulationName);
success = sm.runScript(prov, simulation.getSimSpec(), simulationName, scriptPath,
neuronLists, simulation.getSimConfigFilename());
simulation.setScriptRan(success);
simulation.setScriptStartedAt();
if (success) {
File simulationFile = new File(workingDir() + "\\LastSimulation\\simulation");
FileOutputStream simOut = new FileOutputStream(simulationFile);
ObjectOutputStream simObjOut = new ObjectOutputStream(simOut);
simObjOut.writeObject(simulation);
}

//save the simulation here
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
messageAccumulator += sm.getOutstandingMessages();
} catch (JSchException | SftpException | IOException | NullPointerException e) {
e.printStackTrace();
messageAccumulator += "\n" + "Script did not run do to "
+ e.getClass() + "...\n";
messageAccumulator += "Exception message: " + e.getMessage();
}

return success;
}

private static String workingDir() {
String dir = System.getProperty("user.dir");
String target = "\\target";
if (dir.endsWith(target)) {
dir = dir.substring(0, dir.length() - target.length());
}
return dir;
}

/**
* Analyzes the redirected provenance output from an executed script.
Expand Down Expand Up @@ -611,7 +640,7 @@ private void persistProvenance() {
prov.persist(simulation);
messageAccumulator += "\n"
+ "Provenance persisted to: "
+ prov.getProvFileURI() + "\n";
+ prov.getProvFileUri() + "\n";
} catch (IOException e) {
messageAccumulator += "\n"
+ "Unable to persist provenance\n"
Expand Down Expand Up @@ -735,6 +764,15 @@ public String getMessages() {
return messageAccumulator;
}

/**
Comment thread
BenYang2002 marked this conversation as resolved.
Outdated
* Set the message for message Accumulator, used for remember last simulation.
*
* @param msg msg to set
*/
public void setMessages(String msg) {
messageAccumulator = msg;
}

/**
* Clears the accumulated messages for this manager.
*/
Expand Down
Loading