Skip to content
This repository was archived by the owner on Apr 26, 2021. It is now read-only.

Commit

Permalink
Model Explorer Rebuild
Browse files Browse the repository at this point in the history
Handle '_id' not found Error
Show Modal Dialog when import start
  • Loading branch information
faizanvahevaria committed Oct 24, 2019
1 parent a068e8c commit a582726
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
26 changes: 18 additions & 8 deletions src/transport/relationship.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ function addAssociationClassLink(objRelationship, entity, attr) {
let associationSide = {};
let bindAssos = bindRelationshipToImport(entity, attr.association);
//let associationSide=app.repository.writeObject(bindAssos);
associationSide['$ref'] = bindAssos._id;
if(bindAssos && bindAssos.hasOwnProperty('_id')){
associationSide['$ref'] = bindAssos._id;
}
objRelationship.associationSide = associationSide; //JSON.parse(associationSide);
/* classSide */
let classSide = {};
Expand Down Expand Up @@ -347,10 +349,14 @@ function bindRelationshipToImport(entity, attr) {
/* UMLAssociation (aggregation) */
objRelationship = addAssociationClassLink(objRelationship, entity, attr);
if (objRelationship != null) {
let rel = app.repository.readObject(objRelationship);
rel._parent = entity;
console.log("rel", rel);
return rel;
try{
let rel = app.repository.readObject(objRelationship);
rel._parent = entity;
console.log("rel", rel);
return rel;
}catch(error){
app.dialogs.showErrorDialog(error.message);
}
}
}
}
Expand All @@ -369,8 +375,12 @@ function setRelationship(ownedElements, XMIData) {
entityJson.ownedElements = ownedElements;

forEach(mSubObject.Relationship, function (attr) {
let rel = bindRelationshipToImport(entity, attr);
ownedElements.push(rel);
try{
let rel = bindRelationshipToImport(entity, attr);
ownedElements.push(rel);
}catch(error){
app.dialogs.showErrorDialog(error.message);
}
});
let resRel = app.engine.setProperty(entity, 'ownedElements', ownedElements);
console.log("resRel", resRel);
Expand All @@ -385,4 +395,4 @@ module.exports.addInterfaceRealizationToImport = addInterfaceRealizationToImport
module.exports.addInterfaceToImport = addInterfaceToImport;
module.exports.addAssociationClassLink = addAssociationClassLink;
module.exports.bindRelationshipToImport = bindRelationshipToImport;
module.exports.setRelationship = setRelationship;
module.exports.setRelationship = setRelationship;
14 changes: 11 additions & 3 deletions src/transport/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ function importDataToModel(XMIData) {
}


function importModel() {
async function importModel() {

var mFiles = app.dialogs.showOpenDialog('Import package As JSON (.json)', null, JSON_FILE_FILTERS)
if (mFiles && mFiles.length > 0) {
Expand All @@ -379,14 +379,22 @@ function importModel() {
let res = await processImport(MainXMIData);
if (res != null && res.success) {
vDialog.close();
app.modelExplorer.rebuild();
/* var selected = app.selections.getSelected();
if(!selected){
selected=app.project.getProject()[0];
}
console.log("Get selected",selected); */
setTimeout(function () {
// app.modelExplorer.expand(selected);
app.dialogs.showInfoDialog(constant.mi_msg_success);
}, 5);

});
}
// } catch (error) {
// console.log("importModel", error.message);
// };
}, 5);
});
// }catch(error){
// console.error(error.message);
// }
Expand Down

0 comments on commit a582726

Please sign in to comment.