def get_premis_copyright_information(rights): premis_data = () for copyright_section in rights.rightsstatementcopyright_set.all(): copyright_jurisdiction_code = (getCodeForCountry( str(copyright_section.copyrightjurisdiction).upper()) or "") determination_date = clean_date( copyright_section.copyrightstatusdeterminationdate) copyright_info = ( "copyright_information", ("copyright_status", copyright_section.copyrightstatus), ("copyright_jurisdiction", copyright_jurisdiction_code), ("copyright_status_determination_date", determination_date), ) for note in copyright_section.rightsstatementcopyrightnote_set.all(): copyright_info += (("copyright_note", note.copyrightnote), ) copyright_info += get_premis_rights_documentation_identifiers( "copyright", copyright_section. rightsstatementcopyrightdocumentationidentifier_set.all(), ) copyright_info += (get_premis_rights_applicable_dates( "copyright", copyright_section), ) premis_data += copyright_info return premis_data
def archivematicaGetRights(metadataAppliesToList, fileUUID): """[(fileUUID, fileUUIDTYPE), (sipUUID, sipUUIDTYPE), (transferUUID, transferUUIDType)]""" ret = [] rightsBasisActuallyOther = ["Policy", "Donor"] for metadataAppliesToidentifier, metadataAppliesToType in metadataAppliesToList: list = "RightsStatement.pk, rightsStatementIdentifierType, rightsStatementIdentifierType, rightsStatementIdentifierValue, rightsBasis, copyrightStatus, copyrightJurisdiction, copyrightStatusDeterminationDate, licenseTerms, copyrightApplicableStartDate, copyrightApplicableEndDate, licenseApplicableStartDate, licenseApplicableEndDate" key = list.split(", ") sql = """SELECT %s FROM RightsStatement LEFT JOIN RightsStatementCopyright ON RightsStatementCopyright.fkRightsStatement = RightsStatement.pk LEFT JOIN RightsStatementLicense ON RightsStatementLicense.fkRightsStatement = RightsStatement.pk WHERE metadataAppliesToidentifier = '%s' AND metadataAppliesToType = '%s';""" % ( list, metadataAppliesToidentifier, metadataAppliesToType) rows = databaseInterface.queryAllSQL(sql) if not rows: continue else: for row in rows: valueDic = {} rightsStatement = etree.Element("rightsStatement", nsmap={None: premisNS}) rightsStatement.set( xsiBNS + "schemaLocation", premisNS + " http://www.loc.gov/standards/premis/v2/premis-v2-2.xsd") #rightsStatement.set("version", "2.1") #cvc-complex-type.3.2.2: Attribute 'version' is not allowed to appear in element 'rightsStatement'. ret.append(rightsStatement) for i in range(len(key)): valueDic[key[i]] = row[i] rightsStatementIdentifier = etree.SubElement( rightsStatement, "rightsStatementIdentifier") if valueDic["rightsStatementIdentifierValue"]: etree.SubElement( rightsStatementIdentifier, "rightsStatementIdentifierType" ).text = valueDic["rightsStatementIdentifierType"] etree.SubElement( rightsStatementIdentifier, "rightsStatementIdentifierValue" ).text = valueDic["rightsStatementIdentifierValue"] else: etree.SubElement( rightsStatementIdentifier, "rightsStatementIdentifierType").text = "UUID" etree.SubElement(rightsStatementIdentifier, "rightsStatementIdentifierValue" ).text = uuid.uuid4().__str__() if valueDic["rightsBasis"] in rightsBasisActuallyOther: etree.SubElement(rightsStatement, "rightsBasis").text = "Other" else: etree.SubElement( rightsStatement, "rightsBasis").text = valueDic["rightsBasis"] #copright information if valueDic["rightsBasis"].lower() in ["copyright"]: sql = """SELECT pk, copyrightStatus, copyrightJurisdiction, copyrightStatusDeterminationDate, copyrightApplicableStartDate, copyrightApplicableEndDate, copyrightApplicableEndDateOpen FROM RightsStatementCopyright WHERE fkRightsStatement = %d""" % ( valueDic["RightsStatement.pk"]) rows2 = databaseInterface.queryAllSQL(sql) for row2 in rows2: copyrightInformation = etree.SubElement( rightsStatement, "copyrightInformation") etree.SubElement(copyrightInformation, "copyrightStatus" ).text = valueDic["copyrightStatus"] copyrightJurisdiction = valueDic[ "copyrightJurisdiction"] copyrightJurisdictionCode = getCodeForCountry( copyrightJurisdiction.__str__().upper()) if copyrightJurisdictionCode != None: copyrightJurisdiction = copyrightJurisdictionCode etree.SubElement(copyrightInformation, "copyrightJurisdiction" ).text = copyrightJurisdiction etree.SubElement( copyrightInformation, "copyrightStatusDeterminationDate" ).text = formatDate( valueDic["copyrightStatusDeterminationDate"]) #copyrightNote Repeatable sql = "SELECT copyrightNote FROM RightsStatementCopyrightNote WHERE fkRightsStatementCopyrightInformation = %d;" % ( row2[0]) rows3 = databaseInterface.queryAllSQL(sql) for row3 in rows3: etree.SubElement(copyrightInformation, "copyrightNote").text = row3[0] #RightsStatementCopyrightDocumentationIdentifier getDocumentationIdentifier( valueDic["RightsStatement.pk"], copyrightInformation) copyrightApplicableDates = etree.SubElement( copyrightInformation, "copyrightApplicableDates") if valueDic["copyrightApplicableStartDate"]: etree.SubElement( copyrightApplicableDates, "startDate").text = formatDate( valueDic["copyrightApplicableStartDate"]) if row2[6]: #, copyrightApplicableEndDateOpen etree.SubElement(copyrightApplicableDates, "endDate").text = "OPEN" elif valueDic["copyrightApplicableEndDate"]: etree.SubElement( copyrightApplicableDates, "endDate").text = formatDate( valueDic["copyrightApplicableEndDate"]) elif valueDic["rightsBasis"].lower() in ["license"]: sql = """SELECT licenseTerms, licenseApplicableStartDate, licenseApplicableEndDate, licenseDocumentationIdentifierType, licenseDocumentationIdentifierValue, RightsStatementLicense.pk, licenseDocumentationIdentifierRole, licenseApplicableEndDateOpen FROM RightsStatementLicense JOIN RightsStatementLicenseDocumentationIdentifier ON RightsStatementLicenseDocumentationIdentifier.fkRightsStatementLicense = RightsStatementLicense.pk WHERE RightsStatementLicense.fkRightsStatement = %d;""" % ( valueDic["RightsStatement.pk"]) rows2 = databaseInterface.queryAllSQL(sql) for row2 in rows2: licenseInformation = etree.SubElement( rightsStatement, "licenseInformation") licenseDocumentIdentifier = etree.SubElement( licenseInformation, "licenseDocumentationIdentifier") etree.SubElement(licenseDocumentIdentifier, "licenseDocumentationIdentifierType" ).text = row2[3] etree.SubElement( licenseDocumentIdentifier, "licenseDocumentationIdentifierValue" ).text = row2[4] etree.SubElement( licenseDocumentIdentifier, "licenseDocumentationRole").text = row2[6] etree.SubElement( licenseInformation, "licenseTerms").text = valueDic["licenseTerms"] sql = "SELECT licenseNote FROM RightsStatementLicenseNote WHERE fkRightsStatementLicense = %d;" % ( row2[5]) rows3 = databaseInterface.queryAllSQL(sql) for row3 in rows3: etree.SubElement(licenseInformation, "licenseNote").text = row3[0] licenseApplicableDates = etree.SubElement( licenseInformation, "licenseApplicableDates") if valueDic["licenseApplicableStartDate"]: etree.SubElement( licenseApplicableDates, "startDate").text = formatDate( valueDic["licenseApplicableStartDate"]) if row2[7]: #licenseApplicableEndDateOpen etree.SubElement(licenseApplicableDates, "endDate").text = "OPEN" elif valueDic["licenseApplicableEndDate"]: etree.SubElement( licenseApplicableDates, "endDate").text = formatDate( valueDic["licenseApplicableEndDate"]) elif valueDic["rightsBasis"].lower() in ["statute"]: #4.1.5 statuteInformation (O, R) getstatuteInformation(valueDic["RightsStatement.pk"], rightsStatement) elif valueDic["rightsBasis"].lower() in [ "donor", "policy", "other" ]: otherRightsInformation = etree.SubElement( rightsStatement, "otherRightsInformation") sql = """SELECT pk, otherRightsBasis, otherRightsApplicableStartDate, otherRightsApplicableEndDate, otherRightsApplicableEndDateOpen FROM RightsStatementOtherRightsInformation WHERE RightsStatementOtherRightsInformation.fkRightsStatement = %d;""" % ( valueDic["RightsStatement.pk"]) rows2 = databaseInterface.queryAllSQL(sql) for row2 in rows2: #otherRightsDocumentationIdentifier sql = """SELECT otherRightsDocumentationIdentifierType, otherRightsDocumentationIdentifierValue, otherRightsDocumentationIdentifierRole FROM RightsStatementOtherRightsDocumentationIdentifier WHERE fkRightsStatementotherRightsInformation = %s """ % ( row2[0]) rows3 = databaseInterface.queryAllSQL(sql) for row3 in rows3: otherRightsDocumentationIdentifier = etree.SubElement( otherRightsInformation, "otherRightsDocumentationIdentifier") etree.SubElement( otherRightsDocumentationIdentifier, "otherRightsDocumentationIdentifierType" ).text = row3[0] etree.SubElement( otherRightsDocumentationIdentifier, "otherRightsDocumentationIdentifierValue" ).text = row3[1] etree.SubElement( otherRightsDocumentationIdentifier, "otherRightsDocumentationRole").text = row3[2] otherRightsBasis = row2[1] if not otherRightsBasis or valueDic[ "rightsBasis"] in rightsBasisActuallyOther: #not 100% otherRightsBasis = valueDic["rightsBasis"] etree.SubElement( otherRightsInformation, "otherRightsBasis").text = otherRightsBasis otherRightsApplicableStartDate = row2[2] otherRightsApplicableEndDate = row2[3] otherRightsApplicableEndDateOpen = row2[4] if otherRightsApplicableStartDate or otherRightsApplicableEndDate: otherRightsApplicableDates = etree.SubElement( otherRightsInformation, "otherRightsApplicableDates") if otherRightsApplicableStartDate: etree.SubElement( otherRightsApplicableDates, "startDate").text = formatDate( otherRightsApplicableStartDate) if otherRightsApplicableEndDateOpen: etree.SubElement(otherRightsApplicableDates, "endDate").text = "OPEN" elif otherRightsApplicableEndDate: etree.SubElement( otherRightsApplicableDates, "endDate").text = formatDate( otherRightsApplicableEndDate) #otherRightsNote Repeatable sql = "SELECT otherRightsNote FROM RightsStatementOtherRightsNote WHERE fkRightsStatementOtherRightsInformation = %d;" % ( row2[0]) rows3 = databaseInterface.queryAllSQL(sql) for row3 in rows3: etree.SubElement(otherRightsInformation, "otherRightsNote").text = row3[0] #4.1.6 rightsGranted (O, R) getrightsGranted(valueDic["RightsStatement.pk"], rightsStatement) #4.1.7 linkingObjectIdentifier (O, R) linkingObjectIdentifier = etree.SubElement( rightsStatement, "linkingObjectIdentifier") etree.SubElement(linkingObjectIdentifier, "linkingObjectIdentifierType").text = "UUID" etree.SubElement( linkingObjectIdentifier, "linkingObjectIdentifierValue").text = fileUUID return ret
def archivematicaGetRights(metadataAppliesToList, fileUUID): """[(fileUUID, fileUUIDTYPE), (sipUUID, sipUUIDTYPE), (transferUUID, transferUUIDType)]""" ret = [] rightsBasisActuallyOther = ["Policy", "Donor"] for metadataAppliesToidentifier, metadataAppliesToType in metadataAppliesToList: list = "RightsStatement.pk, rightsStatementIdentifierType, rightsStatementIdentifierType, rightsStatementIdentifierValue, rightsBasis, copyrightStatus, copyrightJurisdiction, copyrightStatusDeterminationDate, licenseTerms, copyrightApplicableStartDate, copyrightApplicableEndDate, licenseApplicableStartDate, licenseApplicableEndDate" key = list.split(", ") sql = """SELECT %s FROM RightsStatement LEFT JOIN RightsStatementCopyright ON RightsStatementCopyright.fkRightsStatement = RightsStatement.pk LEFT JOIN RightsStatementLicense ON RightsStatementLicense.fkRightsStatement = RightsStatement.pk WHERE metadataAppliesToidentifier = '%s' AND metadataAppliesToType = '%s';""" % (list, metadataAppliesToidentifier, metadataAppliesToType) rows = databaseInterface.queryAllSQL(sql) if not rows: continue else: for row in rows: valueDic= {} rightsStatement = etree.Element("rightsStatement", nsmap={None: premisNS}) rightsStatement.set(xsiBNS+"schemaLocation", premisNS + " http://www.loc.gov/standards/premis/v2/premis-v2-2.xsd") #rightsStatement.set("version", "2.1") #cvc-complex-type.3.2.2: Attribute 'version' is not allowed to appear in element 'rightsStatement'. ret.append(rightsStatement) for i in range(len(key)): valueDic[key[i]] = row[i] rightsStatementIdentifier = etree.SubElement(rightsStatement, "rightsStatementIdentifier") if valueDic["rightsStatementIdentifierValue"]: etree.SubElement(rightsStatementIdentifier, "rightsStatementIdentifierType").text = valueDic["rightsStatementIdentifierType"] etree.SubElement(rightsStatementIdentifier, "rightsStatementIdentifierValue").text = valueDic["rightsStatementIdentifierValue"] else: etree.SubElement(rightsStatementIdentifier, "rightsStatementIdentifierType").text = "UUID" etree.SubElement(rightsStatementIdentifier, "rightsStatementIdentifierValue").text = uuid.uuid4().__str__() if valueDic["rightsBasis"] in rightsBasisActuallyOther: etree.SubElement(rightsStatement, "rightsBasis").text = "Other" else: etree.SubElement(rightsStatement, "rightsBasis").text = valueDic["rightsBasis"] #copright information if valueDic["rightsBasis"].lower() in ["copyright"]: sql = """SELECT pk, copyrightStatus, copyrightJurisdiction, copyrightStatusDeterminationDate, copyrightApplicableStartDate, copyrightApplicableEndDate, copyrightApplicableEndDateOpen FROM RightsStatementCopyright WHERE fkRightsStatement = %d""" % (valueDic["RightsStatement.pk"]) rows2 = databaseInterface.queryAllSQL(sql) for row2 in rows2: copyrightInformation = etree.SubElement(rightsStatement, "copyrightInformation") etree.SubElement(copyrightInformation, "copyrightStatus").text = valueDic["copyrightStatus"] copyrightJurisdiction = valueDic["copyrightJurisdiction"] copyrightJurisdictionCode = getCodeForCountry(copyrightJurisdiction.__str__().upper()) if copyrightJurisdictionCode != None: copyrightJurisdiction = copyrightJurisdictionCode etree.SubElement(copyrightInformation, "copyrightJurisdiction").text = copyrightJurisdiction etree.SubElement(copyrightInformation, "copyrightStatusDeterminationDate").text = formatDate(valueDic["copyrightStatusDeterminationDate"]) #copyrightNote Repeatable sql = "SELECT copyrightNote FROM RightsStatementCopyrightNote WHERE fkRightsStatementCopyrightInformation = %d;" % (row2[0]) rows3 = databaseInterface.queryAllSQL(sql) for row3 in rows3: etree.SubElement(copyrightInformation, "copyrightNote").text = row3[0] #RightsStatementCopyrightDocumentationIdentifier getDocumentationIdentifier(valueDic["RightsStatement.pk"], copyrightInformation) copyrightApplicableDates = etree.SubElement(copyrightInformation, "copyrightApplicableDates") if valueDic["copyrightApplicableStartDate"]: etree.SubElement(copyrightApplicableDates, "startDate").text = formatDate(valueDic["copyrightApplicableStartDate"]) if row2[6]: #, copyrightApplicableEndDateOpen etree.SubElement(copyrightApplicableDates, "endDate").text = "OPEN" elif valueDic["copyrightApplicableEndDate"]: etree.SubElement(copyrightApplicableDates, "endDate").text = formatDate(valueDic["copyrightApplicableEndDate"]) elif valueDic["rightsBasis"].lower() in ["license"]: sql = """SELECT licenseTerms, licenseApplicableStartDate, licenseApplicableEndDate, licenseDocumentationIdentifierType, licenseDocumentationIdentifierValue, RightsStatementLicense.pk, licenseDocumentationIdentifierRole, licenseApplicableEndDateOpen FROM RightsStatementLicense JOIN RightsStatementLicenseDocumentationIdentifier ON RightsStatementLicenseDocumentationIdentifier.fkRightsStatementLicense = RightsStatementLicense.pk WHERE RightsStatementLicense.fkRightsStatement = %d;""" % (valueDic["RightsStatement.pk"]) rows2 = databaseInterface.queryAllSQL(sql) for row2 in rows2: licenseInformation = etree.SubElement(rightsStatement, "licenseInformation") licenseDocumentIdentifier = etree.SubElement(licenseInformation, "licenseDocumentationIdentifier") etree.SubElement(licenseDocumentIdentifier, "licenseDocumentationIdentifierType").text = row2[3] etree.SubElement(licenseDocumentIdentifier, "licenseDocumentationIdentifierValue").text = row2[4] etree.SubElement(licenseDocumentIdentifier, "licenseDocumentationRole").text = row2[6] etree.SubElement(licenseInformation, "licenseTerms").text = valueDic["licenseTerms"] sql = "SELECT licenseNote FROM RightsStatementLicenseNote WHERE fkRightsStatementLicense = %d;" % (row2[5]) rows3 = databaseInterface.queryAllSQL(sql) for row3 in rows3: etree.SubElement(licenseInformation, "licenseNote").text = row3[0] licenseApplicableDates = etree.SubElement(licenseInformation, "licenseApplicableDates") if valueDic["licenseApplicableStartDate"]: etree.SubElement(licenseApplicableDates, "startDate").text = formatDate(valueDic["licenseApplicableStartDate"]) if row2[7]: #licenseApplicableEndDateOpen etree.SubElement(licenseApplicableDates, "endDate").text = "OPEN" elif valueDic["licenseApplicableEndDate"]: etree.SubElement(licenseApplicableDates, "endDate").text = formatDate(valueDic["licenseApplicableEndDate"]) elif valueDic["rightsBasis"].lower() in ["statute"]: #4.1.5 statuteInformation (O, R) getstatuteInformation(valueDic["RightsStatement.pk"], rightsStatement) elif valueDic["rightsBasis"].lower() in ["donor", "policy", "other"]: otherRightsInformation = etree.SubElement(rightsStatement, "otherRightsInformation") sql = """SELECT pk, otherRightsBasis, otherRightsApplicableStartDate, otherRightsApplicableEndDate, otherRightsApplicableEndDateOpen FROM RightsStatementOtherRightsInformation WHERE RightsStatementOtherRightsInformation.fkRightsStatement = %d;""" % (valueDic["RightsStatement.pk"]) rows2 = databaseInterface.queryAllSQL(sql) for row2 in rows2: #otherRightsDocumentationIdentifier sql = """SELECT otherRightsDocumentationIdentifierType, otherRightsDocumentationIdentifierValue, otherRightsDocumentationIdentifierRole FROM RightsStatementOtherRightsDocumentationIdentifier WHERE fkRightsStatementotherRightsInformation = %s """ % (row2[0]) rows3 = databaseInterface.queryAllSQL(sql) for row3 in rows3: otherRightsDocumentationIdentifier = etree.SubElement(otherRightsInformation, "otherRightsDocumentationIdentifier") etree.SubElement(otherRightsDocumentationIdentifier, "otherRightsDocumentationIdentifierType").text = row3[0] etree.SubElement(otherRightsDocumentationIdentifier, "otherRightsDocumentationIdentifierValue").text = row3[1] etree.SubElement(otherRightsDocumentationIdentifier, "otherRightsDocumentationRole").text = row3[2] otherRightsBasis = row2[1] if not otherRightsBasis or valueDic["rightsBasis"] in rightsBasisActuallyOther: #not 100% otherRightsBasis = valueDic["rightsBasis"] etree.SubElement(otherRightsInformation, "otherRightsBasis").text = otherRightsBasis otherRightsApplicableStartDate = row2[2] otherRightsApplicableEndDate = row2[3] otherRightsApplicableEndDateOpen = row2[4] if otherRightsApplicableStartDate or otherRightsApplicableEndDate: otherRightsApplicableDates = etree.SubElement(otherRightsInformation, "otherRightsApplicableDates") if otherRightsApplicableStartDate: etree.SubElement(otherRightsApplicableDates, "startDate").text = formatDate(otherRightsApplicableStartDate) if otherRightsApplicableEndDateOpen: etree.SubElement(otherRightsApplicableDates, "endDate").text = "OPEN" elif otherRightsApplicableEndDate: etree.SubElement(otherRightsApplicableDates, "endDate").text = formatDate(otherRightsApplicableEndDate) #otherRightsNote Repeatable sql = "SELECT otherRightsNote FROM RightsStatementOtherRightsNote WHERE fkRightsStatementOtherRightsInformation = %d;" % (row2[0]) rows3 = databaseInterface.queryAllSQL(sql) for row3 in rows3: etree.SubElement(otherRightsInformation, "otherRightsNote").text = row3[0] #4.1.6 rightsGranted (O, R) getrightsGranted(valueDic["RightsStatement.pk"], rightsStatement) #4.1.7 linkingObjectIdentifier (O, R) linkingObjectIdentifier = etree.SubElement(rightsStatement, "linkingObjectIdentifier") etree.SubElement(linkingObjectIdentifier, "linkingObjectIdentifierType").text = "UUID" etree.SubElement(linkingObjectIdentifier, "linkingObjectIdentifierValue").text = fileUUID return ret
def createRightsStatement(job, statement, fileUUID, state): rightsStatement = etree.Element(ns.premisBNS + "rightsStatement", nsmap={'premis': ns.premisNS}) rightsStatement.set( ns.xsiBNS + "schemaLocation", ns.premisNS + " http://www.loc.gov/standards/premis/v2/premis-v2-2.xsd") # rightsStatement.set("version", "2.1") # cvc-complex-type.3.2.2: Attribute 'version' is not allowed to appear in element 'rightsStatement'. rightsStatementIdentifier = etree.SubElement( rightsStatement, ns.premisBNS + "rightsStatementIdentifier") if statement.rightsstatementidentifiervalue: etree.SubElement(rightsStatementIdentifier, ns.premisBNS + "rightsStatementIdentifierType" ).text = statement.rightsstatementidentifiertype etree.SubElement(rightsStatementIdentifier, ns.premisBNS + "rightsStatementIdentifierValue" ).text = statement.rightsstatementidentifiervalue else: etree.SubElement(rightsStatementIdentifier, ns.premisBNS + "rightsStatementIdentifierType").text = "UUID" etree.SubElement( rightsStatementIdentifier, ns.premisBNS + "rightsStatementIdentifierValue").text = uuid.uuid4().__str__() if statement.rightsbasis in RIGHTS_BASIS_OTHER: etree.SubElement(rightsStatement, ns.premisBNS + "rightsBasis").text = "Other" else: etree.SubElement(rightsStatement, ns.premisBNS + "rightsBasis").text = statement.rightsbasis # Copyright information if statement.rightsbasis.lower() in ["copyright"]: for copyright in statement.rightsstatementcopyright_set.all(): copyrightInformation = etree.SubElement( rightsStatement, ns.premisBNS + "copyrightInformation") etree.SubElement( copyrightInformation, ns.premisBNS + "copyrightStatus").text = copyright.copyrightstatus copyrightJurisdiction = copyright.copyrightjurisdiction copyrightJurisdictionCode = getCodeForCountry( copyrightJurisdiction.__str__().upper()) if copyrightJurisdictionCode is not None: copyrightJurisdiction = copyrightJurisdictionCode etree.SubElement( copyrightInformation, ns.premisBNS + "copyrightJurisdiction").text = copyrightJurisdiction etree.SubElement( copyrightInformation, ns.premisBNS + "copyrightStatusDeterminationDate").text = formatDate( copyright.copyrightstatusdeterminationdate) # copyrightNote Repeatable for note in copyright.rightsstatementcopyrightnote_set.all(): etree.SubElement(copyrightInformation, ns.premisBNS + "copyrightNote").text = note.copyrightnote # RightsStatementCopyrightDocumentationIdentifier getDocumentationIdentifier(copyright, copyrightInformation) copyrightApplicableDates = etree.SubElement( copyrightInformation, ns.premisBNS + "copyrightApplicableDates") if copyright.copyrightapplicablestartdate: etree.SubElement(copyrightApplicableDates, ns.premisBNS + "startDate").text = formatDate( copyright.copyrightapplicablestartdate) if copyright.copyrightenddateopen: etree.SubElement(copyrightApplicableDates, ns.premisBNS + "endDate").text = "OPEN" elif copyright.copyrightapplicableenddate: etree.SubElement(copyrightApplicableDates, ns.premisBNS + "endDate").text = formatDate( copyright.copyrightapplicableenddate) elif statement.rightsbasis.lower() in ["license"]: for license in statement.rightsstatementlicense_set.all(): licenseInformation = etree.SubElement( rightsStatement, ns.premisBNS + "licenseInformation") for identifier in license.rightsstatementlicensedocumentationidentifier_set.all( ): licenseDocumentIdentifier = etree.SubElement( licenseInformation, ns.premisBNS + "licenseDocumentationIdentifier") etree.SubElement( licenseDocumentIdentifier, ns.premisBNS + "licenseDocumentationIdentifierType" ).text = identifier.licensedocumentationidentifiertype etree.SubElement( licenseDocumentIdentifier, ns.premisBNS + "licenseDocumentationIdentifierValue" ).text = identifier.licensedocumentationidentifiervalue etree.SubElement( licenseDocumentIdentifier, ns.premisBNS + "licenseDocumentationRole" ).text = identifier.licensedocumentationidentifierrole etree.SubElement(licenseInformation, ns.premisBNS + "licenseTerms").text = license.licenseterms for note in license.rightsstatementlicensenote_set.all(): etree.SubElement(licenseInformation, ns.premisBNS + "licenseNote").text = note.licensenote licenseApplicableDates = etree.SubElement( licenseInformation, ns.premisBNS + "licenseApplicableDates") if license.licenseapplicablestartdate: etree.SubElement(licenseApplicableDates, ns.premisBNS + "startDate").text = formatDate( license.licenseapplicablestartdate) if license.licenseenddateopen: etree.SubElement(licenseApplicableDates, ns.premisBNS + "endDate").text = "OPEN" elif license.licenseapplicableenddate: etree.SubElement(licenseApplicableDates, ns.premisBNS + "endDate").text = formatDate( license.licenseapplicableenddate) elif statement.rightsbasis.lower() in ["statute"]: # 4.1.5 statuteInformation (O, R) getstatuteInformation(statement, rightsStatement) elif statement.rightsbasis.lower() in ["donor", "policy", "other"]: otherRightsInformation = etree.SubElement( rightsStatement, ns.premisBNS + "otherRightsInformation") for info in statement.rightsstatementotherrightsinformation_set.all(): # otherRightsDocumentationIdentifier for identifier in info.rightsstatementotherrightsdocumentationidentifier_set.all( ): otherRightsDocumentationIdentifier = etree.SubElement( otherRightsInformation, ns.premisBNS + "otherRightsDocumentationIdentifier") etree.SubElement( otherRightsDocumentationIdentifier, ns.premisBNS + "otherRightsDocumentationIdentifierType" ).text = identifier.otherrightsdocumentationidentifiertype etree.SubElement( otherRightsDocumentationIdentifier, ns.premisBNS + "otherRightsDocumentationIdentifierValue" ).text = identifier.otherrightsdocumentationidentifiervalue etree.SubElement( otherRightsDocumentationIdentifier, ns.premisBNS + "otherRightsDocumentationRole" ).text = identifier.otherrightsdocumentationidentifierrole otherRightsBasis = info.otherrightsbasis if not otherRightsBasis or statement.rightsbasis in RIGHTS_BASIS_OTHER: # not 100% otherRightsBasis = statement.rightsbasis etree.SubElement(otherRightsInformation, ns.premisBNS + "otherRightsBasis").text = otherRightsBasis if info.otherrightsapplicablestartdate or info.otherrightsapplicableenddate: otherRightsApplicableDates = etree.SubElement( otherRightsInformation, ns.premisBNS + "otherRightsApplicableDates") if info.otherrightsapplicablestartdate: etree.SubElement(otherRightsApplicableDates, ns.premisBNS + "startDate").text = formatDate( info.otherrightsapplicablestartdate) if info.otherrightsenddateopen: etree.SubElement(otherRightsApplicableDates, ns.premisBNS + "endDate").text = "OPEN" elif info.otherrightsapplicableenddate: etree.SubElement(otherRightsApplicableDates, ns.premisBNS + "endDate").text = formatDate( info.otherrightsapplicableenddate) # otherRightsNote Repeatable for note in info.rightsstatementotherrightsinformationnote_set.all( ): etree.SubElement(otherRightsInformation, ns.premisBNS + "otherRightsNote").text = note.otherrightsnote # 4.1.6 rightsGranted (O, R) getrightsGranted(job, statement, rightsStatement, state) # 4.1.7 linkingObjectIdentifier (O, R) linkingObjectIdentifier = etree.SubElement( rightsStatement, ns.premisBNS + "linkingObjectIdentifier") etree.SubElement(linkingObjectIdentifier, ns.premisBNS + "linkingObjectIdentifierType").text = "UUID" etree.SubElement(linkingObjectIdentifier, ns.premisBNS + "linkingObjectIdentifierValue").text = fileUUID return rightsStatement