def generateXSDataISPyBScreening(_xsDataInputControlISPyB,
                                     _strShortComments=None,
                                     _strComments=None):
        """
        """
        EDFactoryPluginStatic.loadModule("XSDataISPyBv1_2")
        from XSDataISPyBv1_2 import XSDataString
        from XSDataISPyBv1_2 import XSDataISPyBScreening

        xsDataIntegerDataCollectionId = _xsDataInputControlISPyB.getDataCollectionId(
        )

        # General information
        xsDataISPyBScreening = XSDataISPyBScreening()
        xsDataISPyBScreening.setProgramVersion(XSDataString("EDNA MXv1"))
        pyStrTimeStamp = time.strftime("%Y-%m-%d %H:%M:%S")
        xsDataISPyBScreening.setTimeStamp(XSDataString(pyStrTimeStamp))
        if (not _strShortComments is None):
            xsDataISPyBScreening.setShortComments(
                XSDataString(_strShortComments))
        if (not _strComments is None):
            xsDataISPyBScreening.setComments(XSDataString(_strComments))

        # Use dataCollectionId if provided in the input
        if (xsDataIntegerDataCollectionId is not None):
            xsDataISPyBScreening.setDataCollectionId(
                xsDataIntegerDataCollectionId)

        return xsDataISPyBScreening
    def generateXSDataISPyBScreening(_xsDataInputControlISPyB, _strShortComments=None, _strComments=None):
        """
        """
        EDFactoryPluginStatic.loadModule("XSDataISPyBv1_2")
        from XSDataISPyBv1_2 import XSDataString
        from XSDataISPyBv1_2 import XSDataISPyBScreening

        xsDataIntegerDataCollectionId = _xsDataInputControlISPyB.getDataCollectionId()

        # General information
        xsDataISPyBScreening = XSDataISPyBScreening()
        xsDataISPyBScreening.setProgramVersion(XSDataString("EDNA MXv1"))
        pyStrTimeStamp = time.strftime("%Y-%m-%d %H:%M:%S")
        xsDataISPyBScreening.setTimeStamp(XSDataString(pyStrTimeStamp))
        if (not _strShortComments is None):
            xsDataISPyBScreening.setShortComments(XSDataString(_strShortComments))
        if (not _strComments is None):
            xsDataISPyBScreening.setComments(XSDataString(_strComments))

        # Use dataCollectionId if provided in the input
        if (xsDataIntegerDataCollectionId is not None):
            xsDataISPyBScreening.setDataCollectionId(xsDataIntegerDataCollectionId)

        return xsDataISPyBScreening
    def process(self, _edObject=None):
        """
        Sends store requests with the screening objects to the dbserver. Returns success or failure.
        
        Note that:
        * Any objects referred to by the object returned by self.getDataInput("inputISPyB")[0] 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 the 
        input objects, and then use the primary key attribute of this object when it has been stored. If such 
        an object is not found, the method fails.
        * If an error is encountered, the method will immediately fail and will not attempt to store any more 
        objects. 
        """

        EDPluginExec.process(self)
        EDVerbose.DEBUG("*** EDPluginISPyBv1_2.process")

        # Basic sanity check of inputs:
        if (self.hasDataInput("screening")):
            if (len(self.getDataInput("screening")) > 1):
                strErrorMessage = EDMessage.ERROR_EXECUTION_03 % ("EDPluginISPyBv1_2", "process", "There should only be one input 'screening'.")
                EDVerbose.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                raise RuntimeError, strErrorMessage

        if (self.hasDataInput("screeningRankSet")):
            if (len(self.getDataInput("screeningRankSet")) > 1):
                strErrorMessage = EDMessage.ERROR_EXECUTION_03 % ("EDPluginISPyBv1_2", "process", "There should only be one input 'screeningRankSet'.")
                EDVerbose.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                raise RuntimeError, strErrorMessage

        # Get the inputs
        xsDataISPyBScreenings = None
        xsDataISPyBScreeningInputs = None
        xsDataISPyBScreeningOutputContainers = None
        xsDataISPyBScreeningRanks = None
        xsDataISPyBScreeningRankSets = None
        xsDataISPyBImages = None
        xsDataISPyBScreeningFiles = None

        if self.hasDataInput("screening"):
            xsDataISPyBScreenings = self.getDataInput("screening")
        if self.hasDataInput("screeningInput"):
            xsDataISPyBScreeningInputs = self.getDataInput("screeningInput")
        if self.hasDataInput("screeningOutputContainer"):
            xsDataISPyBScreeningOutputContainers = self.getDataInput("screeningOutputContainer")
        if self.hasDataInput("screeningRank"):
            xsDataISPyBScreeningRanks = self.getDataInput("screeningRank")
        if self.hasDataInput("screeningRankSet"):
            xsDataISPyBScreeningRankSets = self.getDataInput("screeningRankSet")
        if self.hasDataInput("image"):
            xsDataISPyBImages = self.getDataInput("image")
        if self.hasDataInput("screeningFile"):
            xsDataISPyBScreeningFiles = self.getDataInput("screeningFile")

        self.__xsDataResultISPyB = XSDataResultISPyB()

        if (xsDataISPyBScreenings is None):
            xsDataISPyBScreening = XSDataISPyBScreening()
        else:
            xsDataISPyBScreening = xsDataISPyBScreenings[0]

        if (xsDataISPyBImages is None):
            xsDataISPyBImage = None
        else:
            xsDataISPyBImage = xsDataISPyBImages[0]

        # Another sanity check:
        if xsDataISPyBScreening.getDataCollectionId() == None:
            if ((xsDataISPyBImage == None) or (xsDataISPyBImage.getFileName() == None) or (xsDataISPyBImage.getFileLocation() == None)):
                strErrorMessage = EDMessage.ERROR_EXECUTION_03 % ("EDPluginISPyBv1_2", "process", \
                                                                     "Neither a dataCollectionId nor an image filename + path are provided.")
                EDVerbose.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                return

            strXML = EDUtilsXML.dnaMarshal(xsDataISPyBImage)

            # Send the XML to request the dataCollectionId from the dbserver:
            strResponse = self.httpPost(self.getDbserverHost(), self.getDbserverPort(), "/get_datacollectionid", strXML)

            if strResponse != None:
                # Handle response:
                xsDatadbstatus = XSDatadbstatus.parseString(strResponse)
                strCode = xsDatadbstatus.getCode()
                strMessage = xsDatadbstatus.getMessage()
                EDVerbose.DEBUG("dbserver returns code: " + strCode)
                EDVerbose.DEBUG("dbserver returns message: " + strMessage)

                if (strCode == "error") or (xsDatadbstatus.getDataCollectionId() == -1):
                    if xsDatadbstatus.getDataCollectionId() == -1:
                        strMessage = "An image corresponding to the given fileName and fileLocation was not found."
                    strErrorMessage = EDMessage.ERROR_EXECUTION_03 % ("EDPluginISPyBv1_2", "process", strMessage)
                    EDVerbose.error(strErrorMessage)
                    self.addErrorMessage(strErrorMessage)
                    return

                if xsDatadbstatus.getDataCollectionId() != -1:
                    xsDataISPyBScreening.setDataCollectionId(XSDataInteger(xsDatadbstatus.getDataCollectionId()))
                    self.__xsDataResultISPyB.setDataCollectionId(XSDataInteger(xsDatadbstatus.getDataCollectionId()))

        if (xsDataISPyBScreeningRankSets is None):
            xsDataISPyBScreeningRankSet = None
        else:
            xsDataISPyBScreeningRankSet = xsDataISPyBScreeningRankSets[0]

        # Store all the different screening* objects:
        xsDataIntegerScreeningId = self.store(xsDataISPyBScreening)

        if xsDataISPyBScreeningInputs != None:
            for xsDataISPyBScreeningInput in xsDataISPyBScreeningInputs:
                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)

            xsDataISPyBScreeningStrategyContainers = xsDataISPyBScreeningOutputContainer.getScreeningStrategyContainer()
            if xsDataISPyBScreeningStrategyContainers != None:
                for xsDataISPyBScreeningStrategyContainer in xsDataISPyBScreeningStrategyContainers:
                    xsDataISPyBScreeningStrategy = xsDataISPyBScreeningStrategyContainer.getScreeningStrategy()
                    if xsDataISPyBScreeningStrategy != None:
                        xsDataISPyBScreeningStrategy.setScreeningOutputId(xsDataIntegerScreeningOutputId)
                        xsDataIntegerScreeningStrategyId = self.store(xsDataISPyBScreeningStrategy)

                        xsDataISPyBScreeningStrategyWedgeContainers = xsDataISPyBScreeningStrategyContainer.getScreeningStrategyWedgeContainer()
                        if xsDataISPyBScreeningStrategyWedgeContainers != None:
                            for xsDataISPyBScreeningStrategyWedgeContainer in xsDataISPyBScreeningStrategyWedgeContainers:
                                xsDataISPyBScreeningStrategyWedge = xsDataISPyBScreeningStrategyWedgeContainer.getScreeningStrategyWedge()
                                xsDataISPyBScreeningStrategyWedge.setScreeningStrategyId(xsDataIntegerScreeningStrategyId)
                                xsDataIntegerScreeningStrategyWedgeId = self.store(xsDataISPyBScreeningStrategyWedge)

                                xsDataISPyBScreeningStrategySubWedges = xsDataISPyBScreeningStrategyWedgeContainer.getScreeningStrategySubWedge()
                                if xsDataISPyBScreeningStrategySubWedges != None:
                                    for xsDataISPyBScreeningStrategySubWedge in xsDataISPyBScreeningStrategySubWedges:
                                        xsDataISPyBScreeningStrategySubWedge.setScreeningStrategyWedgeId(xsDataIntegerScreeningStrategyWedgeId)
                                        self.store(xsDataISPyBScreeningStrategySubWedge)
Esempio n. 4
0
    def process(self, _edObject=None):
        """
        Sends store requests with the screening objects to the dbserver. Returns success or failure.
        
        Note that:
        * Any objects referred to by the object returned by self.getDataInput("inputISPyB")[0] 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 the 
        input objects, and then use the primary key attribute of this object when it has been stored. If such 
        an object is not found, the method fails.
        * If an error is encountered, the method will immediately fail and will not attempt to store any more 
        objects. 
        """

        EDPluginExec.process(self)
        self.DEBUG("*** EDPluginISPyBv1_2.process")

        # Basic sanity check of inputs:
        if (self.hasDataInput("screening")):
            if (len(self.getDataInput("screening")) > 1):
                strErrorMessage = EDMessage.ERROR_EXECUTION_03 % (
                    "EDPluginISPyBv1_2", "process",
                    "There should only be one input 'screening'.")
                self.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                raise RuntimeError, strErrorMessage

        if (self.hasDataInput("screeningRankSet")):
            if (len(self.getDataInput("screeningRankSet")) > 1):
                strErrorMessage = EDMessage.ERROR_EXECUTION_03 % (
                    "EDPluginISPyBv1_2", "process",
                    "There should only be one input 'screeningRankSet'.")
                self.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                raise RuntimeError, strErrorMessage

        # Get the inputs
        xsDataISPyBScreenings = None
        xsDataISPyBScreeningInputs = None
        xsDataISPyBScreeningOutputContainers = None
        xsDataISPyBScreeningRanks = None
        xsDataISPyBScreeningRankSets = None
        xsDataISPyBImages = None
        xsDataISPyBScreeningFiles = None

        if self.hasDataInput("screening"):
            xsDataISPyBScreenings = self.getDataInput("screening")
        if self.hasDataInput("screeningInput"):
            xsDataISPyBScreeningInputs = self.getDataInput("screeningInput")
        if self.hasDataInput("screeningOutputContainer"):
            xsDataISPyBScreeningOutputContainers = self.getDataInput(
                "screeningOutputContainer")
        if self.hasDataInput("screeningRank"):
            xsDataISPyBScreeningRanks = self.getDataInput("screeningRank")
        if self.hasDataInput("screeningRankSet"):
            xsDataISPyBScreeningRankSets = self.getDataInput(
                "screeningRankSet")
        if self.hasDataInput("image"):
            xsDataISPyBImages = self.getDataInput("image")
        if self.hasDataInput("screeningFile"):
            xsDataISPyBScreeningFiles = self.getDataInput("screeningFile")

        self.__xsDataResultISPyB = XSDataResultISPyB()

        if (xsDataISPyBScreenings is None):
            xsDataISPyBScreening = XSDataISPyBScreening()
        else:
            xsDataISPyBScreening = xsDataISPyBScreenings[0]

        if (xsDataISPyBImages is None):
            xsDataISPyBImage = None
        else:
            xsDataISPyBImage = xsDataISPyBImages[0]

        # Another sanity check:
        if xsDataISPyBScreening.getDataCollectionId() == None:
            if ((xsDataISPyBImage == None)
                    or (xsDataISPyBImage.getFileName() == None)
                    or (xsDataISPyBImage.getFileLocation() == None)):
                strErrorMessage = EDMessage.ERROR_EXECUTION_03 % ("EDPluginISPyBv1_2", "process", \
                                                                     "Neither a dataCollectionId nor an image filename + path are provided.")
                self.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                return

            strXML = EDUtilsXML.dnaMarshal(xsDataISPyBImage)

            # Send the XML to request the dataCollectionId from the dbserver:
            strResponse = self.httpPost(self.getDbserverHost(),
                                        self.getDbserverPort(),
                                        "/get_datacollectionid", strXML)

            if strResponse != None:
                # Handle response:
                xsDatadbstatus = XSDatadbstatus.parseString(strResponse)
                strCode = xsDatadbstatus.getCode()
                strMessage = xsDatadbstatus.getMessage()
                self.DEBUG("dbserver returns code: " + strCode)
                self.DEBUG("dbserver returns message: " + strMessage)

                if (strCode
                        == "error") or (xsDatadbstatus.getDataCollectionId()
                                        == -1):
                    if xsDatadbstatus.getDataCollectionId() == -1:
                        strMessage = "An image corresponding to the given fileName and fileLocation was not found."
                    strErrorMessage = EDMessage.ERROR_EXECUTION_03 % (
                        "EDPluginISPyBv1_2", "process", strMessage)
                    self.error(strErrorMessage)
                    self.addErrorMessage(strErrorMessage)
                    return

                if xsDatadbstatus.getDataCollectionId() != -1:
                    xsDataISPyBScreening.setDataCollectionId(
                        XSDataInteger(xsDatadbstatus.getDataCollectionId()))
                    self.__xsDataResultISPyB.setDataCollectionId(
                        XSDataInteger(xsDatadbstatus.getDataCollectionId()))

        if (xsDataISPyBScreeningRankSets is None):
            xsDataISPyBScreeningRankSet = None
        else:
            xsDataISPyBScreeningRankSet = xsDataISPyBScreeningRankSets[0]

        # Store all the different screening* objects:
        xsDataIntegerScreeningId = self.store(xsDataISPyBScreening)

        if xsDataISPyBScreeningInputs != None:
            for xsDataISPyBScreeningInput in xsDataISPyBScreeningInputs:
                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)

            xsDataISPyBScreeningStrategyContainers = xsDataISPyBScreeningOutputContainer.getScreeningStrategyContainer(
            )
            if xsDataISPyBScreeningStrategyContainers != None:
                for xsDataISPyBScreeningStrategyContainer in xsDataISPyBScreeningStrategyContainers:
                    xsDataISPyBScreeningStrategy = xsDataISPyBScreeningStrategyContainer.getScreeningStrategy(
                    )
                    if xsDataISPyBScreeningStrategy != None:
                        xsDataISPyBScreeningStrategy.setScreeningOutputId(
                            xsDataIntegerScreeningOutputId)
                        xsDataIntegerScreeningStrategyId = self.store(
                            xsDataISPyBScreeningStrategy)

                        xsDataISPyBScreeningStrategyWedgeContainers = xsDataISPyBScreeningStrategyContainer.getScreeningStrategyWedgeContainer(
                        )
                        if xsDataISPyBScreeningStrategyWedgeContainers != None:
                            for xsDataISPyBScreeningStrategyWedgeContainer in xsDataISPyBScreeningStrategyWedgeContainers:
                                xsDataISPyBScreeningStrategyWedge = xsDataISPyBScreeningStrategyWedgeContainer.getScreeningStrategyWedge(
                                )
                                xsDataISPyBScreeningStrategyWedge.setScreeningStrategyId(
                                    xsDataIntegerScreeningStrategyId)
                                xsDataIntegerScreeningStrategyWedgeId = self.store(
                                    xsDataISPyBScreeningStrategyWedge)

                                xsDataISPyBScreeningStrategySubWedges = xsDataISPyBScreeningStrategyWedgeContainer.getScreeningStrategySubWedge(
                                )
                                if xsDataISPyBScreeningStrategySubWedges != None:
                                    for xsDataISPyBScreeningStrategySubWedge in xsDataISPyBScreeningStrategySubWedges:
                                        xsDataISPyBScreeningStrategySubWedge.setScreeningStrategyWedgeId(
                                            xsDataIntegerScreeningStrategyWedgeId
                                        )
                                        self.store(
                                            xsDataISPyBScreeningStrategySubWedge
                                        )