def __workflow(self): # Workflow data WORKFLOW_ID = "packaging" wfChanged = False workflow_security = [] self.message_list = None try: wfPayload = self.object.getPayload("workflow.metadata") wfMeta = self.utils.getJsonObject(wfPayload.open()) wfPayload.close() # Are we indexing because of a workflow progression? targetStep = wfMeta.getString(None, ["targetStep"]) if targetStep is not None and targetStep != wfMeta.getString(None, ["step"]): wfChanged = True # Step change wfMeta.getJsonObject().put("step", targetStep) wfMeta.getJsonObject().remove("targetStep") # This must be a re-index then else: targetStep = wfMeta.getString(None, ["step"]) # Security change stages = self.config.getJsonSimpleList(["stages"]) for stage in stages: if stage.getString(None, ["name"]) == targetStep: wfMeta.getJsonObject().put("label", stage.getString(None, ["label"])) self.item_security = stage.getStringList(["visibility"]) workflow_security = stage.getStringList(["security"]) if wfChanged == True: self.message_list = stage.getStringList(["message"]) # Form processing formData = wfMeta.getObject(["formData"]) if formData is not None: formData = JsonSimple(formData) else: formData = None coreFields = ["title", "creator", "contributor", "description", "format", "creationDate"] if formData is not None: # Core fields title = formData.getStringList(["title"]) if title: self.titleList = title creator = formData.getStringList(["creator"]) if creator: self.creatorList = creator contributor = formData.getStringList(["contributor"]) if contributor: self.contributorList = contributor description = formData.getStringList(["description"]) if description: self.descriptionList = description format = formData.getStringList(["format"]) if format: self.formatList = format creation = formData.getStringList(["creationDate"]) if creation: self.creationDate = creation # Non-core fields data = formData.getJsonObject() for field in data.keySet(): if field not in coreFields: self.customFields[field] = formData.getStringList([field]) except StorageException, e: # No workflow payload, time to create wfChanged = True wfMeta = JsonSimple() wfMetaObj = wfMeta.getJsonObject() wfMetaObj.put("id", WORKFLOW_ID) wfMetaObj.put("step", "pending") wfMetaObj.put("pageTitle", "Uploaded Files - Management") stages = self.config.getJsonSimpleList(["stages"]) for stage in stages: if stage.getString(None, ["name"]) == "pending": wfMetaObj.put("label", stage.getString(None, ["label"])) self.item_security = stage.getStringList(["visibility"]) workflow_security = stage.getStringList(["security"]) self.message_list = stage.getStringList(["message"])
def __workflow(self): # Workflow data WORKFLOW_ID = "usq" wfChanged = False workflow_security = [] try: wfPayload = self.object.getPayload("workflow.metadata") wfMeta = self.utils.getJsonObject(wfPayload.open()) wfPayload.close() # Are we indexing because of a workflow progression? targetStep = wfMeta.getString(None, ["targetStep"]) if targetStep is not None and targetStep != wfMeta.getString(None, ["step"]): wfChanged = True # Step change wfMeta.getJsonObject().put("step", targetStep) wfMeta.getJsonObject().remove("targetStep") # This must be a re-index then else: targetStep = wfMeta.getString(None, ["step"]) # Security change stages = self.config.getJsonSimpleList(["stages"]) for stage in stages: if stage.getString(None, ["name"]) == targetStep: wfMeta.getJsonObject().put("label", stage.getString(None, ["label"])) self.item_security = stage.getStringList(["visibility"]) workflow_security = stage.getStringList(["security"]) if wfChanged == True: self.message_list = stage.getStringList(["message"]) # Form processing formData = wfMeta.getObject(["formData"]) if formData is not None: formData = JsonSimple(formData) else: formData = None coreFields = ["title", "creator", "contributor", "description", "format", "creationDate"] if formData is not None: # Core fields title = formData.getStringList(["title"]) if title: self.titleList = title creator = formData.getStringList(["creator"]) if creator: self.creatorList = creator contributor = formData.getStringList(["contributor"]) if contributor: self.contributorList = contributor description = formData.getStringList(["description"]) if description: self.descriptionList = description format = formData.getStringList(["format"]) if format: self.formatList = format creation = formData.getStringList(["creationDate"]) if creation: self.creationDate = creation # Course security - basic course = formData.getString(None, ["course_code"]) if course: self.item_security.add(course) # Course security - moodle moodle_courses = formData.getString(None, ["moodleSecurity"]) if moodle_courses: moodleList = moodle_courses.split(",") for course in moodleList: if course != "": self.item_security.add(course) # Course facets - Peoplesoft psMoodle_courses = formData.getString(None, ["psMoodle"]) if psMoodle_courses: psMoodleList = psMoodle_courses.split(",") for course in psMoodleList: if course != "": self.__indexCourse(course) # Non-core fields data = formData.getJsonObject() for field in data.keySet(): if field not in coreFields: data = formData.getStringList([field]) if field.startswith("dc_subject."): subjectField = "dc_subject" if self.customFields.has_key(subjectField): subjectList = self.customFields[subjectField] if subjectList: for subject in subjectList: data.add(subject) field = subjectField self.customFields[field] = data except StorageException, e: # No workflow payload, time to create wfChanged = True wfMeta = JsonSimple() wfMetaObj = wfMeta.getJsonObject() wfMetaObj.put("id", WORKFLOW_ID) wfMetaObj.put("step", "pending") wfMetaObj.put("pageTitle", "Uploaded Files - Management") stages = self.config.getJsonSimpleList(["stages"]) for stage in stages: if stage.getString(None, ["name"]) == "pending": wfMetaObj.put("label", stage.getString(None, ["label"])) self.item_security = stage.getStringList(["visibility"]) workflow_security = stage.getStringList(["security"]) self.message_list = stage.getStringList(["message"])