Skip to content

Commit

Permalink
#711: simplify attributeSetIdentifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Mar 1, 2023
1 parent e2e887c commit aa3b710
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions lib/metadataTypes/AttributeGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ class AttributeGroup extends MetadataType {
* @returns {TYPE.MetadataTypeItem} metadata
*/
static postRetrieveTasks(metadata) {
// Member ID
delete metadata.mID;

// attributeSet
for (const attributeSet of metadata.attributeSetIdentifiers) {
metadata.attributeSetIdentifiers = metadata.attributeSetIdentifiers.map((attributeSet) => {
try {
const key = cache.searchForField(
'attributeSet',
Expand All @@ -58,19 +61,19 @@ class AttributeGroup extends MetadataType {
`AttributeSet key mismatch. Found ${key} instead of ${attributeSet.definitionKey}`
);
}
delete attributeSet.definitionID;
delete attributeSet.definitionName;
delete attributeSet.connectingID;
return key;
} catch (ex) {
Util.logger.warn(
` - ${this.definition.type} ${metadata[this.definition.keyField]} (for ${
attributeSet.definitionKey
}): ${ex.message}`
);
return attributeSet;
}
}
// Member ID
delete metadata.mID;
});

// requiredRelationships
// TODO: implement

return metadata;
}
Expand All @@ -81,25 +84,23 @@ class AttributeGroup extends MetadataType {
* @returns {TYPE.MetadataTypeItem} Promise
*/
static async preDeployTasks(metadata) {
// attributeSet
for (const attributeSet of metadata.attributeSetIdentifiers) {
try {
const as = cache.getByKey('attributeSet', attributeSet.definitionKey);
attributeSet.definitionID = as.definitionID;
attributeSet.definitionName = as.definitionName?.value;
attributeSet.connectingID = as.connectingID;
} catch (ex) {
Util.logger.warn(
` - ${this.definition.type} ${metadata[this.definition.keyField]}: ${
ex.message
}`
);
}
}

// Member ID - set to ID of deployment target automatically
metadata.mID = this.buObject.mid;

// attributeSet
metadata.attributeSetIdentifiers = metadata.attributeSetIdentifiers.map((key) => {
const as = cache.getByKey('attributeSet', key);
return {
definitionKey: key,
definitionID: as.definitionID,
definitionName: as.definitionName,
connectingID: as.connectingID,
};
});

// requiredRelationships
// TODO: implement

return metadata;
}
}
Expand Down

0 comments on commit aa3b710

Please sign in to comment.