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 testProcess(self): username = "******" password = "******" lmClient = LifemapperClient(username, password) scenarioLayerIDs = [] scenarioLayerIDs.append(str(1846)) scenarioLayerIDs.append(str(1847)) scenarioLayerIDs.append(str(1848)) scenarioLayerIDs.append(str(1849)) scenarioLayerIDs.append(str(1850)) print "scenarioLayerIDs %s" % scenarioLayerIDs # Post scenario and save ID scenarioID = lmClient.postScenario(scenarioLayerIDs) print "scenarioID %s" % scenarioID