create mp aggregation in the migrated resource only if needed
@@ -103,7 +103,21 @@ class Command(BaseCommand):
type_element = comp_res.metadata.type
type_element.url = '{0}/terms/{1}'.format(current_site_url(), to_resource_type)
type_element.save()
-
+ create_aggregation = True
+ if not mp_metadata_obj.program:
+ msg = "Resource has no model program specific metadata and no data files. " \
+ "No model program aggregation created for this resource:{}".format(comp_res.short_id)
+ if comp_res.files.count() == 0:
+ # original mp resource has no files and no mp specific metadata - no need to create mp aggregation
+ print(msg)
+ create_aggregation = False
+ elif comp_res.readme_file is not None and comp_res.files.count() == 1:
+ # original mp resource contains only a readme file and no mp specific metadata - no need to
+ # create mp aggregation
+ print(msg)
+ create_aggregation = False
+
+ if create_aggregation:
# create a mp aggregation
try:
mp_aggr = ModelProgramLogicalFile.create(resource=comp_res)
