in src/loading_manifest/osdu_wellboretop_manifest.py [0:0]
def create_wellboretop_manifest(wellboretop_name, preload_file_path, file_source,
wellbore_id, top_markers,
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_WELLBORE_TOP_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_WELLBORE_TOP_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=wellboretop_name,
description=cm.WorkProductManifest.DESCRIPTION_WELLBORE_TOP
)
# 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=wellboretop_name,
description=cm.WorkProductComponentManifest.DESCRIPTION_WELLBORE_TOP
)
wpc_data = wpc[cm.WorkProductComponentManifest.TAG_DATA]
wpc_data[cm.WorkProductComponentManifest.TAG_DATA_WELL_BORE_ID] \
= cm.WorkProductComponentManifest.WELL_BORE_ID + cm.url_quote(wellbore_id) + ":"
wpc_top_markers = []
marker_depth_unit_1 = None
for marker_top_md, marker_depth_unit, marker_name, marker_type in top_markers:
if marker_depth_unit_1 is None:
marker_depth_unit_1 = marker_depth_unit
elif marker_depth_unit_1 != marker_depth_unit:
logging.warning("Inconsistent depth units for %s: %s, %s", wellboretop_name,
marker_depth_unit_1, marker_depth_unit)
marker_item = dict()
marker_item[
cm.WorkProductComponentManifest.TAG_DATA_MERKERS_MARKER_NAME] = marker_name
marker_item[
cm.WorkProductComponentManifest.TAG_DATA_MERKERS_MARKER_DEPTH] = marker_top_md
wpc_top_markers.append(marker_item)
# if marker_depth_unit_1 is not None:
# wpc_data[cm.WorkProductComponentManifest.TAG_DATA_DEPTH_UNIT] \
# = cm.WorkProductComponentManifest.UOM_ID + marker_depth_unit_1 + ":"
wpc_data[cm.WorkProductComponentManifest.TAG_DATA_MERKERS] = wpc_top_markers
wpc_meta = wpc[cm.WorkProductComponentManifest.TAG_META]
if marker_depth_unit_1 is not None and len(marker_depth_unit_1) > 0:
meta_unit = dict()
wpc_meta.append(meta_unit)
meta_unit[cm.WorkProductComponentManifest.TAG_META_KIND] = cm.WorkProductComponentManifest.META_KIND_UNIT
meta_unit[cm.WorkProductComponentManifest.TAG_META_NAME] = marker_depth_unit_1
meta_unit[cm.WorkProductComponentManifest.TAG_META_PERSIST_REF] = ""
meta_unit[cm.WorkProductComponentManifest.TAG_META_UOM] = \
cm.WorkProductComponentManifest.UOM_ID + marker_depth_unit_1 + ":"
meta_unit[cm.WorkProductComponentManifest.TAG_META_PROPERTY_NAMES] = []
meta_unit[cm.WorkProductComponentManifest.TAG_META_PROPERTY_NAMES].append("Markers[].MarkerMeasuredDepth")
# create the wellboretop file manifest
wellboretop_file_name = wellboretop_name
f_doc = cm.create_file_manifest(
kind=kind_file,
schema_format_type=cm.FileManifest.SCHEMA_FORMAT_TYPE_ID_CVS,
acl=acl,
legal=legal,
resource_security_classificaton=cm.ResourceSecurityClassification.RESTRICTED,
preload_file_path=(preload_file_path + wellboretop_file_name),
file_source=("" if file_source is None or len(file_source) == 0
else (file_source + wellboretop_file_name)),
file_name=wellboretop_file_name
)
# associate wpc with wp
cm.associate_work_product_components(wp, [wpc])
# associate wellboretop file with wpc
cm.associate_files(wpc, [f_doc])
# create wellboretop loading manifest
wellboretop = 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 wellboretop