def process(self, input, output): username = "******" password = "******" lmClient = LifemapperClient(username, password) # Get the JSON spec jsonSpecification = input.value(LM.hasJSONExperimentSpecificationURL) # Get published scenario layers scenarioLayerIDs = [] for layer in input[LM.hasScenarioLayer]: layerID = layer.value(LM.hasLayerID) scenarioLayerIDs.append(str(layerID)) # Post scenario and save ID lmClient.postScenario(scenarioLayerIDs) #scenarioID = str(234) scenarioID = lmClient.getScenarioID() scenarioURL = lmClient.getScenarioURL() # The URI generator resourceURI = ResourceURI() # Create the published scenario scenario = RDFLibResource(output.graph, resourceURI.getURI("scenario")) ScenarioClass = RDFLibResource(output.graph, LM.Scenario) scenario.set(RDF.type, ScenarioClass) scenario.set(LM.hasScenarioID, Literal(scenarioID)) scenario.set(LM.hasScenarioURL, Literal(scenarioURL)) scenario.set(LM.hasJSONExperimentSpecificationURL, jsonSpecification) # Add scenarioID to output output.set(LM.hasPublishedScenario, scenario)
def process(self, input, output): username = "******" password = "******" lmClient = LifemapperClient(username, password) # Get scenario id scenario = input.value(LM.specifiesModellingScenario) scenarioID = scenario.value(LM.hasScenarioID) # Extract Algorithm algorithm = input.value(LM.specifiesModellingAlgorithm) algorithmCode = algorithm.value(LM.hasAlgorithmCode) # Extract Parameter Bindings params = algorithm.value(MD.behaviorControlledBy) bindings = [] for param in params[MD.hasParameterMember]: name = param.value(MD.hasParameterName) value = param.value(MD.boundToValue) bindings[name] = value # Extract OccurrenceSetID occurrenceSet = input.value(LM.specifiesOccurrenceSet) occurrenceSetID = occurrenceSet.value(LM.hasOccurrenceSetID) lmClient.postExperiment(algorithmCode, bindings, occurrenceSetID, scenarioID) #resultURL = "http://somedomain.com/testURL" #get experimentURL and id experimentURL = lmClient.getExperimentURL() experimentID = lmClient.getExperimentID() print "experiment result URL %s " % experimentURL # The URI generator resourceURI = ResourceURI() # Create the experiment result experimentResult = RDFLibResource(output.graph, resourceURI.getURI("experimentResult")) experimentResultClass = RDFLibResource(output.graph, LM.ExperimentResult) experimentResult.set(RDF.type, experimentResultClass) experimentResult.set(LM.hasExperimentResultURL, Literal(experimentURL)) experimentResult.set(LM.hasExperimentResultID, Literal(experimentID)) # Add the experiment result to the executed specification output.set(LM.hasExperimentResult, experimentResult)
def process(self, input, output): username = "******" password = "******" lmClient = LifemapperClient(username, password) # Get file download URL of the TIFF layer manif = input.value(DATA.hasManifestation) tiffFileDownloadURL = manif.value(DATA.hasFileDownloadURL) # Get the typeCode and layerUnits typeCode = input.value(LM.hasTypeCode) layerUnits = input.value(LM.hasLayerUnits) # Get the JSON spec jsonSpecification = input.value(LM.hasJSONExperimentSpecificationURL) lmClient.postLayer(tiffFileDownloadURL, layerUnits, typeCode) #layerID = str(12) layerID = lmClient.getLayerID() layerURL = lmClient.getLayerURL() print "posted layer ID %s " % layerID # The URI generator resourceURI = ResourceURI() # Create new manifestation fileManifestation = RDFLibResource(output.graph, resourceURI.getURI("manifestation")) FileManifestationClass = RDFLibResource(output.graph, DATA.FileManifestation) fileManifestation.set(RDF.type, FileManifestationClass) fileManifestation.set(DATA.hasLandingPageURL, Literal(layerURL)) # Create the ScenarioLayer layer = RDFLibResource(output.graph, resourceURI.getURI("layer")) ScenarioLayerClass = RDFLibResource(output.graph, LM.ScenarioLayer) layer.set(RDF.type, ScenarioLayerClass) layer.set(DATA.hasManifestation, fileManifestation) layer.set(LM.hasLayerID, Literal(layerID)) layer.set(LM.hasLayerURL, Literal(layerURL)) layer.set(LM.hasJSONExperimentSpecificationURL, jsonSpecification) output.set(LM.hasPublishedLayer, layer)