def store(self, _xsDataISPyBScreeningObject): # Create DNA compatible XML from xsDataScreeningObject: pyStrXML = EDUtilsXML.dnaMarshal(_xsDataISPyBScreeningObject) # Send the XML to the dbserver: pyStrResponse = self.httpPost(self.getDbserverHost(), self.getDbserverPort(), "/store_object_request", pyStrXML) if pyStrResponse != None: # Handle response: self.DEBUG(pyStrResponse) xsDatadbstatus = XSDatadbstatus.parseString(pyStrResponse) self.DEBUG("dbserver returns code: " + xsDatadbstatus.getCode()) self.DEBUG("dbserver returns message: " + xsDatadbstatus.getMessage()) if xsDatadbstatus.getCode() == "error": pyStrErrorMessage = EDMessage.ERROR_EXECUTION_03 % ("EDPluginISPyBv1_1", "process", xsDatadbstatus.getMessage()) self.error(xsDatadbstatus.getMessage()) self.addErrorMessage(xsDatadbstatus.getMessage()) return - 1 else: xsDataResultStatus = XSDataResultStatus() xsDataResultStatus.setCode(XSDataString(xsDatadbstatus.getCode())) xsDataResultStatus.setMessage(XSDataString(xsDatadbstatus.getMessage())) iIndex = -1 pyStrClassName = _xsDataISPyBScreeningObject.__class__.__name__ if pyStrClassName == "XSDataISPyBScreening": iIndex = xsDatadbstatus.getScreeningId() self.m_xsDataResultISPyB.setScreeningStatus(xsDataResultStatus) elif pyStrClassName == "XSDataISPyBScreeningInput": iIndex = xsDatadbstatus.getScreeningInputId() self.m_xsDataResultISPyB.getScreeningInputStatus().append(xsDataResultStatus) elif pyStrClassName == "XSDataISPyBScreeningOutput": iIndex = xsDatadbstatus.getScreeningOutputId() self.m_xsDataResultISPyB.getScreeningOutputStatus().append(xsDataResultStatus) elif pyStrClassName == "XSDataISPyBScreeningOutputLattice": iIndex = xsDatadbstatus.getScreeningOutputLatticeId() self.m_xsDataResultISPyB.getScreeningOutputLatticeStatus().append(xsDataResultStatus) elif pyStrClassName == "XSDataISPyBScreeningStrategy": iIndex = xsDatadbstatus.getScreeningStrategyId() self.m_xsDataResultISPyB.getScreeningStrategyStatus().append(xsDataResultStatus) elif pyStrClassName == "XSDataISPyBScreeningRank": iIndex = xsDatadbstatus.getScreeningRankId() self.m_xsDataResultISPyB.getScreeningRankStatus().append(xsDataResultStatus) elif pyStrClassName == "XSDataISPyBScreeningRankSet": iIndex = xsDatadbstatus.getScreeningRankSetId() self.m_xsDataResultISPyB.setScreeningRankSetStatus(xsDataResultStatus) else: pyStrErrorMessage = EDMessage.ERROR_EXECUTION_03 % ("EDPluginISPyBv1_1", "store", \ "Class type not found.") self.error(pyStrErrorMessage) self.addErrorMessage(pyStrErrorMessage) raise RuntimeError, pyStrErrorMessage xsDataResultStatus.setId(XSDataInteger(iIndex)) return XSDataInteger(iIndex)
def process(self, _edObject=None): """ Sends a store request and the screening object to the dbserver. Returns success or failure. Note that: * Any objects referred to by the object returned by self.getDataInput() will be stored. * Primary key attributes should not be set. * If a foreign key attribute is not set, this method will attempt to find the foreign object among those referred to by the self.getDataInput() object, and use the primary key attribute of this object when it has been stored. If such an object is not found, the method fails. * The method will not attempt to store any more objects once an error is encountered """ EDPluginExec.process(self) EDVerbose.DEBUG("*** EDPluginISPyBv1_1.process") xsDataInputISPyB = self.getDataInput() self.m_xsDataResultISPyB = XSDataResultISPyB() xsDataISPyBScreening = xsDataInputISPyB.getScreening() if xsDataISPyBScreening == None: xsDataISPyBScreening = XSDataISPyBScreening() xsDataISPyBImage = xsDataInputISPyB.getImage() if xsDataISPyBScreening.getDataCollectionId() == None: if ( (xsDataISPyBImage == None) or (xsDataISPyBImage.getFileName() == None) or (xsDataISPyBImage.getFileLocation() == None) ): pyStrErrorMessage = EDMessage.ERROR_EXECUTION_03 % ( "EDPluginISPyBv1_1", "process", "Neither a dataCollectionId nor a image filename + path are provided.", ) EDVerbose.error(pyStrErrorMessage) self.addErrorMessage(pyStrErrorMessage) return pyStrXML = EDUtilsXML.dnaMarshal(xsDataISPyBImage) # Send the XML to request the dataCollectionId from the dbserver: pyStrResponse = self.httpPost( self.getDbserverHost(), self.getDbserverPort(), "/get_datacollectionid", pyStrXML ) if pyStrResponse != None: # Handle response: xsDatadbstatus = XSDatadbstatus.parseString(pyStrResponse) pyStrCode = xsDatadbstatus.getCode() pyStrMessage = xsDatadbstatus.getMessage() EDVerbose.DEBUG("dbserver returns code: " + pyStrCode) EDVerbose.DEBUG("dbserver returns message: " + pyStrMessage) if (pyStrCode == "error") or (xsDatadbstatus.getDataCollectionId() == -1): if xsDatadbstatus.getDataCollectionId() == -1: pyStrMessage = "An image corresponding to the given fileName and fileLocation was not found." pyStrErrorMessage = EDMessage.ERROR_EXECUTION_03 % ("EDPluginISPyBv1_1", "process", pyStrMessage) EDVerbose.error(pyStrErrorMessage) self.addErrorMessage(pyStrErrorMessage) return if xsDatadbstatus.getDataCollectionId() != -1: xsDataISPyBScreening.setDataCollectionId(XSDataInteger(xsDatadbstatus.getDataCollectionId())) self.m_xsDataResultISPyB.setDataCollectionId(XSDataInteger(xsDatadbstatus.getDataCollectionId())) xsDataISPyBScreeningInputs = xsDataInputISPyB.getScreeningInput() xsDataISPyBScreeningOutputContainers = xsDataInputISPyB.getScreeningOutputContainer() xsDataISPyBScreeningRanks = xsDataInputISPyB.getScreeningRank() xsDataISPyBScreeningRankSet = xsDataInputISPyB.getScreeningRankSet() xsDataIntegerScreeningId = self.store(xsDataISPyBScreening) if xsDataISPyBScreeningInputs != None: for xsDataISPyBScreeningInput in xsDataISPyBScreeningInputs: xml = xsDataISPyBScreeningInput.marshal() xsDataISPyBScreeningInput.setScreeningId(xsDataIntegerScreeningId) self.store(xsDataISPyBScreeningInput) if xsDataISPyBScreeningRankSet != None: xsDataIntegerScreeningRankSetId = self.store(xsDataISPyBScreeningRankSet) for xsDataISPyBScreeningRank in xsDataISPyBScreeningRanks: xsDataISPyBScreeningRank.setScreeningId(xsDataIntegerScreeningId) xsDataISPyBScreeningRank.setScreeningRankSetId(xsDataIntegerScreeningRankSetId) self.store(xsDataISPyBScreeningRank) if xsDataISPyBScreeningOutputContainers != None: for xsDataISPyBScreeningOutputContainer in xsDataISPyBScreeningOutputContainers: xsDataISPyBScreeningOutput = xsDataISPyBScreeningOutputContainer.getScreeningOutput() xsDataISPyBScreeningOutput.setScreeningId(xsDataIntegerScreeningId) xsDataIntegerScreeningOutputId = self.store(xsDataISPyBScreeningOutput) xsDataISPyBScreeningOutputLattices = xsDataISPyBScreeningOutputContainer.getScreeningOutputLattice() if xsDataISPyBScreeningOutputLattices != None: for xsDataISPyBScreeningOutputLattice in xsDataISPyBScreeningOutputLattices: xsDataISPyBScreeningOutputLattice.setScreeningOutputId(xsDataIntegerScreeningOutputId) self.store(xsDataISPyBScreeningOutputLattice) xsDataISPyBScreeningStrategies = xsDataISPyBScreeningOutputContainer.getScreeningStrategy() if xsDataISPyBScreeningStrategies != None: for xsDataISPyBScreeningStrategy in xsDataISPyBScreeningStrategies: xsDataISPyBScreeningStrategy.setScreeningOutputId(xsDataIntegerScreeningOutputId) self.store(xsDataISPyBScreeningStrategy)