Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class AuthorityController extends ItemController<Authority> implements Authority
accessControlService.checkAdministrator()
Authority cleanedItem = cleanBody(authority)
cleanedItem = updateCreationProperties(cleanedItem) as Authority
setStableId(cleanedItem)
authorityService.create(cleanedItem)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class ApiPropertyController extends ItemController<ApiProperty> implements ApiPr

updateCreationProperties(apiProperty)

setStableId(apiProperty)

apiPropertyRepository.save(apiProperty)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ abstract class FacetController<I extends Facet> extends ItemController<I> implem

AdministeredItem administeredItem = readAdministeredItem(domainType, domainId)
accessControlService.checkRole(Role.EDITOR, administeredItem)

createEntity(administeredItem, facet)
I created= createEntity(administeredItem, facet)
setStableId(created)
return created
}

protected I createEntity(@NonNull AdministeredItem administeredItem, @NonNull I cleanFacet) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class RuleRepresentationController extends ItemController<RuleRepresentation> im
accessControlService.checkRole(Role.EDITOR, readAdministeredItemForFacet(rule))
ruleRepresentation.ruleId = rule.id
updateCreationProperties(ruleRepresentation)
setStableId(ruleRepresentation)
ruleRepresentationCacheableRepository.save(ruleRepresentation)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class SummaryMetadataReportController extends ItemController<SummaryMetadataRepo
accessControlService.checkRole(Role.EDITOR, readAdministeredItemForFacet(summaryMetadata))
summaryMetadataReport.summaryMetadataId = summaryMetadata.id
updateCreationProperties(summaryMetadataReport)
setStableId(summaryMetadataReport)
summaryMetadataReportCacheableRepository.save(summaryMetadataReport)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class FolderController extends ModelController<Folder> implements FolderApi {
folder.authority = super.authorityService.getDefaultAuthority()
pathRepository.readParentItems(folder)
folder.updatePath()
setStableId(folder)
folderRepository.save(folder)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class VersionedFolderController extends ModelController<Folder> implements Versi

pathRepository.readParentItems(folder)
folder.updatePath()

setStableId(folder)
folderRepository.save(folder)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ abstract class AdministeredItemController<I extends AdministeredItem, P extends
cleanItem.parent = parent

updateDerivedProperties(cleanItem)
setStableId(cleanItem)
administeredItemRepository.save(cleanItem)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract class ItemController<I extends Item> implements AdministeredItemReader
* Properties disallowed in a simple update request.
*/
List<String> getDisallowedProperties() {
['class_', 'class', 'id', 'dateCreated', 'lastUpdated', 'createdBy', 'versionable', 'domainType', 'version']
['class_', 'class', 'id', 'dateCreated', 'lastUpdated', 'createdBy', 'versionable', 'domainType', 'version', 'stableId']
}

/**
Expand Down Expand Up @@ -94,4 +94,10 @@ abstract class ItemController<I extends Item> implements AdministeredItemReader
}
return hasChanged
}

protected void setStableId(Item item) {
if(item.stableId){return}

item.stableId=UUID.randomUUID()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ApiKeyController extends ItemController<ApiKey> implements ApiKeyApi {
apiKey.disabled = false
}
apiKey.updateExpiryDate()
setStableId(apiKey)
apiKeyCacheableRepository.save(apiKey)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class CatalogueUserController extends ItemController<CatalogueUser> implements C
newUser.salt = SecureRandomStringGenerator.generateSalt()
newUser.password = null

setStableId(newUser)
catalogueUserRepository.save(newUser)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class SecurableResourceGroupRoleController extends ItemController<SecurableResou
userGroup: userGroup
)

setStableId(securableResourceGroupRole)
securableResourceGroupRoleRepository.save(securableResourceGroupRole)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class UserGroupController extends ItemController<UserGroup> implements UserGroup
@Post(Paths.USER_GROUP_LIST)
UserGroup create(@Body @NonNull UserGroup userGroup) {
accessControlService.checkAdministrator()
setStableId(userGroup)
userGroupRepository.save(userGroup)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class DataModelNewBranchVersionIntegrationSpec extends CommonDataSpec {
@Shared
UUID dataModelId
@Shared
UUID dataModelStableId
@Shared
UUID dataTypeId1
@Shared
UUID dataTypeId2
Expand Down Expand Up @@ -63,6 +65,7 @@ class DataModelNewBranchVersionIntegrationSpec extends CommonDataSpec {
folderId = folderApi.create(folder()).id
dataModel = dataModelApi.create(folderId, dataModelPayload())
dataModelId = dataModel.id
dataModelStableId = dataModel.stableId
dataTypeId1 = dataTypeApi.create(dataModelId,
new DataType(label: 'string',
description: 'character string of variable length',
Expand Down Expand Up @@ -138,6 +141,8 @@ class DataModelNewBranchVersionIntegrationSpec extends CommonDataSpec {
newBranchVersionDataModel.summaryMetadata[0].id != summaryMetadataId
newBranchVersionDataModel.summaryMetadata[0].summaryMetadataReports.size() == 1
newBranchVersionDataModel.summaryMetadata[0].summaryMetadataReports[0].id != summaryMetadataReportId
//stable id carries over
newBranchVersionDataModel.stableId==dataModelStableId

when:
ListResponse<DataModel> dataModelsList = dataModelApi.list(folderId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class FolderIntegrationSpec extends CommonDataSpec {
folderResponse.label == 'Test folder'
folderResponse.path.toString() == 'fo:Test folder'
folderResponse.authority
folderResponse.stableId
}

void 'create child folder'() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,11 @@ abstract class Item implements Serializable {
dateCreated = null
lastUpdated = null
}

/**
* The unchanging immutable identity of an object. This value persists between versions.
* Set when the object is created for the first time
*/
@Nullable
UUID stableId
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ create table core."authority"
"created_by" uuid,
"breadcrumb_tree_id" uuid,
"url" varchar(255) not null,
"default_authority" boolean default false
"default_authority" boolean default false,
"stable_id" uuid
);

-- Metadata
Expand All @@ -30,7 +31,8 @@ create table "core"."metadata"
"created_by" uuid,
"namespace" text not null,
"key" text not null,
"value" text not null
"value" text not null,
"stable_id" uuid
);
create unique index "idx_metadata_multi_facet_aware_item_id_namespace_key" on "core"."metadata" (multi_facet_aware_item_id, namespace, key);

Expand All @@ -46,7 +48,8 @@ create table "core"."version_link"
"created_by" uuid,
"version_link_type" varchar(255) not null,
"target_model_id" uuid not null,
"target_model_domain_type" varchar(255) not null
"target_model_domain_type" varchar(255) not null,
"stable_id" uuid
);
create unique index "idx_version_link_multi_facet_aware_item_id_target_model_id" on "core"."version_link" (multi_facet_aware_item_id, target_model_id);

Expand All @@ -73,7 +76,8 @@ create table core."folder"
"model_version" varchar(255),
"model_version_tag" varchar(255),
"parent_folder_id" uuid,
"class" varchar(255)
"class" varchar(255),
"stable_id" uuid
);
create index "idx_folder_parent_folder_id" on core."folder" (parent_folder_id);

Expand All @@ -100,7 +104,8 @@ create table security."catalogue_user"
"last_login" timestamp with time zone,
"salt" bytea not null,
"password" bytea,
"temp_password" varchar(255)
"temp_password" varchar(255),
"stable_id" uuid
);
create unique index "idx_catalogue_user_email_address" on "security"."catalogue_user" (trim(lower(email_address)));

Expand All @@ -114,7 +119,8 @@ create table security."user_group"
"name" varchar(255) not null,
"description" text,
"undeletable" boolean default false,
"application_role" varchar(255)
"application_role" varchar(255),
"stable_id" uuid
);
create unique index "idx_security_user_group_name" on security.user_group (trim(lower(name)));

Expand All @@ -128,7 +134,8 @@ create table security."securable_resource_group_role"
"securable_resource_domain_type" varchar(255) not null,
"securable_resource_id" uuid not null,
"user_group_id" uuid not null references security.user_group (id) initially deferred,
"role" varchar(255) not null
"role" varchar(255) not null,
"stable_id" uuid
);
create unique index "idx_securable_resource_group_role_securable_resource_user_group_id" on security.securable_resource_group_role (securable_resource_domain_type, securable_resource_id, user_group_id);

Expand Down Expand Up @@ -166,7 +173,8 @@ create table terminology."terminology"
"authority_id" uuid /*NOT NULL REFERENCES authority(id) initially deferred*/,
"branch_name" varchar(255),
"model_version" varchar(255),
"model_version_tag" varchar(255)
"model_version_tag" varchar(255),
"stable_id" uuid
);
create unique index "idx_terminology_folder_id_label_branch_name_model_version" on terminology."terminology" (folder_id, label, branch_name, model_version);

Expand All @@ -184,7 +192,8 @@ create table terminology."term_relationship_type"
"idx" integer,
"terminology_id" uuid not null references terminology.terminology (id) initially deferred,
"parental_relationship" boolean,
"child_relationship" boolean
"child_relationship" boolean,
"stable_id" uuid
);
create unique index "idx_term_relationship_type_terminology_id_label" on terminology."term_relationship_type" (terminology_id, label);

Expand All @@ -206,7 +215,8 @@ create table terminology."term"
"definition" text not null,
"url" varchar(255),
"is_parent" boolean,
"depth" integer
"depth" integer,
"stable_id" uuid
);
create unique index "idx_term_terminology_id_code" on terminology."term" (terminology_id, code);

Expand All @@ -225,7 +235,8 @@ create table terminology."term_relationship"
"terminology_id" uuid not null references terminology.terminology (id) initially deferred,
"source_term_id" uuid not null references terminology.term (id) initially deferred,
"target_term_id" uuid not null references terminology.term (id) initially deferred,
"relationship_type_id" uuid not null references terminology.term_relationship_type (id) initially deferred
"relationship_type_id" uuid not null references terminology.term_relationship_type (id) initially deferred,
"stable_id" uuid
);

create index "idx_term_relationship_terminology_id" on terminology."term_relationship" (terminology_id);
Expand Down Expand Up @@ -258,7 +269,8 @@ create table datamodel."data_model" (
"authority_id" uuid /*NOT NULL REFERENCES authority(id) initially deferred*/,
"branch_name" varchar(255),
"model_version" varchar(255),
"model_version_tag" varchar(255)
"model_version_tag" varchar(255),
"stable_id" uuid
);


Expand All @@ -280,7 +292,8 @@ create table datamodel."data_class" (
"description" text,
"aliases_string" text,
"min_multiplicity" integer,
"max_multiplicity" integer
"max_multiplicity" integer,
"stable_id" uuid
);

create index "idx_data_class_data_model_id" on datamodel."data_class"(data_model_id);
Expand All @@ -302,7 +315,8 @@ create table datamodel."data_type" (
"units" varchar(255),
"reference_class_id" uuid references datamodel.data_class(id) initially deferred,
"model_resource_id" uuid,
"model_resource_domain_type" varchar(255)
"model_resource_domain_type" varchar(255),
"stable_id" uuid
);

create index "idx_data_type_data_model_id" on datamodel."data_type"(data_model_id);
Expand All @@ -322,7 +336,8 @@ create table datamodel."data_element" (
"description" text,
"aliases_string" text,
"min_multiplicity" integer,
"max_multiplicity" integer
"max_multiplicity" integer,
"stable_id" uuid
);
create index "idx_data_element_data_class_id" on datamodel."data_element"(data_class_id);
create index "idx_data_element_data_type_id" on datamodel."data_element"(data_type_id);
Expand All @@ -342,7 +357,8 @@ create table datamodel."enumeration_value" (
"aliases_string" text,
"category" text,
"key" text not null,
"value" text
"value" text,
"stable_id" uuid
);

create index "idx_enumeration_value_enumeration_type_id" on datamodel."enumeration_value"(enumeration_type_id);
Expand All @@ -364,7 +380,8 @@ create table "core"."edit" (
"multi_facet_aware_item_id" uuid not null,
"created_by" uuid not null,
"description" text not null,
"title" varchar(255) not null
"title" varchar(255) not null,
"stable_id" uuid
);

create table "core"."semantic_link"
Expand All @@ -379,5 +396,6 @@ create table "core"."semantic_link"
"link_type" varchar(255) not null,
"target_multi_facet_aware_item_id" uuid not null,
"target_multi_facet_aware_item_domain_type" varchar(255) not null,
"unconfirmed" boolean not null
"unconfirmed" boolean not null,
"stable_id" uuid
);
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ create table security.api_key (
"disabled" boolean not null,
"catalogue_user_id" uuid not null references security.catalogue_user (id) initially deferred,
"name" varchar(255) not null,
"created_by" uuid
"created_by" uuid,
"stable_id" uuid
);
create index apiKey_created_by_idx ON security.api_key(created_by);
create index apiKey_catalogue_user_idx ON security.api_key(catalogue_user_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ create table if not exists core."rule" (
"multi_facet_aware_item_id" uuid not null,
"created_by" varchar(255),
"name" text not null,
"description" text
"description" text,
"stable_id" uuid
);
create unique index "idx_rule_multi_facet_aware_item_id_rule" on "core"."rule" (multi_facet_aware_item_id, name);

Expand All @@ -20,7 +21,8 @@ create table if not exists core.rule_representation (
"created_by" varchar(255),
"language" varchar(255) not null,
"representation" text,
"rule_id" uuid not null references core.rule (id) initially deferred
"rule_id" uuid not null references core.rule (id) initially deferred,
"stable_id" uuid
);
create index "idx_rule_representation_rule_id" on "core"."rule_representation" (rule_id);

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ create table if not exists federation."subscribed_catalogue" (
"client_id" text,
"client_secret" text,
"access_token" text,
"access_token_expiry_time" timestamp
"access_token_expiry_time" timestamp,
"stable_id" uuid
);

create table if not exists federation."subscribed_model" (
Expand All @@ -35,7 +36,8 @@ create table if not exists federation."subscribed_model" (
"subscribed_model_type" text,
"folder_id" uuid not null,
"last_read" timestamp with time zone,
"local_model_id" uuid
"local_model_id" uuid,
"stable_id" uuid
);

create index "idx_subscribed_model_subscribed_catalogue_id" on federation."subscribed_model" (subscribed_catalogue_id);
Expand Down
Loading