in src/loading_manifest/osdu_document_manifest.py [0:0]
def create_document_manifest(document_name, file_type, preload_file_path, file_source,
schema_ns_name, schema_ns_value, acl, legal,
schema_version, dict_schemas):
kind_wp = None
kind_wpc = None
kind_file = None
schema_id_lm = None
schema_id_wp = None
schema_id_wpc = None
schema_id_file = None
if schema_version == SCHEMA_VERSION_1_0_0:
kind_wp = cm.WorkProductManifest.KIND_GENERIC_WORK_PRODUCT_1_0_0
kind_wpc = cm.WorkProductComponentManifest.KIND_DOCUMENT_1_0_0
kind_file = cm.FileManifest.KIND_ID_GENERIC_DATASET_1_0_0
schema_id_lm = cm.LoadingManifest.SCHEMA_ID_1_0_0
schema_id_wp = cm.WorkProductManifest.SCHEMA_ID_GENERIC_WORK_PRODUCT_1_0_0
schema_id_wpc = cm.WorkProductComponentManifest.SCHEMA_ID_DOCUMENT_1_0_0
schema_id_file = cm.FileManifest.SCHEMA_ID_GENERIC_DATASET_1_0_0
# create the work product manifest
wp = cm.create_work_product_manifest(
kind=kind_wp,
acl=acl,
legal=legal,
resource_security_classificaton=cm.ResourceSecurityClassification.RESTRICTED,
name=document_name,
description=cm.WorkProductManifest.DESCRIPTION_DOCUMENT
)
# create the work product component manifest
wpc = cm.create_work_product_component_manifest(
kind=kind_wpc,
acl=acl,
legal=legal,
resource_security_classificaton=cm.ResourceSecurityClassification.RESTRICTED,
name=document_name,
description=cm.WorkProductComponentManifest.DESCRIPTION_DOCUMENT
)
# wpc_data = wpc[cm.WorkProductComponentManifest.TAG_DATA]
# create the document file manifest
doc_file_name = document_name + "." + file_type
# file_type_lower = file_type.lower()
f_doc = cm.create_file_manifest(
kind=kind_file,
schema_format_type=None,
acl=acl,
legal=legal,
resource_security_classificaton=cm.ResourceSecurityClassification.RESTRICTED,
preload_file_path=(preload_file_path + doc_file_name),
file_source=("" if file_source is None or len(file_source) == 0
else (file_source + doc_file_name)),
file_name=doc_file_name
)
# associate wpc with wp
cm.associate_work_product_components(wp, [wpc])
# associate document file with wpc
cm.associate_files(wpc, [f_doc])
# create document loading manifest
document = cm.create_loading_manifest(
work_product=wp,
work_product_components=[wpc],
files=[f_doc],
schema_id_lm=schema_id_lm,
schema_id_wp=schema_id_wp,
schema_id_wpc=schema_id_wpc,
schema_id_file=schema_id_file,
schema_ns_name=schema_ns_name,
schema_ns_value=schema_ns_value,
dict_schemas=dict_schemas
)
return document