Skip to content

Commit

Permalink
fix: better breakdown by adding constructor functions
Browse files Browse the repository at this point in the history
Signed-off-by: Muskan Bararia <[email protected]>
  • Loading branch information
Muskan Bararia committed Nov 13, 2023
1 parent 26da05a commit bb83859
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions packages/concerto-core/lib/decoratorutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,30 @@ class DecoratorUtil {
}
return vocabData;
}
/**
* Constructs Target object for a given model
* @param {string} DCS_VERSION - the version string
* @param {string} namespace - the current namespace
* @param {Object} obj - the ast of the model
* @returns {Object} - the target object
* @private
*/
static constructTarget(DCS_VERSION, namespace, obj){
const target ={
'$class': `org.accordproject.decoratorcommands@${DCS_VERSION}.CommandTarget`,
'namespace':namespace
};
if (obj.declaration && obj.declaration!==''){
target.declaration = obj.declaration;
}
if (obj.property && obj.property!==''){
target.property = obj.property;
}
if (obj.mapElement && obj.mapElement!==''){
target.mapElement = obj.mapElement;
}
return target;
}
/**
* parses the extracted decorators and generates arrays of decorator command set and vocabularies
*
Expand All @@ -199,19 +223,7 @@ class DecoratorUtil {
let vocabObject = {};
jsonData.forEach(obj =>{
const decos = JSON.parse(obj.dcs);
const target = {
'$class': `org.accordproject.decoratorcommands@${DCS_VERSION}.CommandTarget`,
'namespace':namespace
};
if (obj.declaration && obj.declaration!==''){
target.declaration = obj.declaration;
}
if (obj.property && obj.property!==''){
target.property = obj.property;
}
if (obj.mapElement && obj.mapElement!==''){
target.mapElement = obj.mapElement;
}
const target = this.constructTarget(DCS_VERSION, namespace, obj);
decos.forEach(dcs =>{
if (dcs.name !== 'Term' && !patternToDetermineVocab.test(dcs.name)){
dcsObjects = this.parseNonVocabularyDecorators(dcsObjects, dcs, DCS_VERSION, target);
Expand Down

0 comments on commit bb83859

Please sign in to comment.