Skip to content

Commit

Permalink
Serialization improvements on propertyAssignments and Generalization …
Browse files Browse the repository at this point in the history
…and GUI improvement on Model Export (#12)

* Included complete OntoUML stereotype list and improved JSON serialization (#9)

* All Steryotypes removed and OntoUML steryotypes added

on plugin start, remove all UML steryotypes both type class and association and install  OntoUML stereotypes.

* Fixed package name.

* buttons for load/unload ontoUML stereotypes

* improve the activation of the default stereotypes

when activate the default stereotype, removed the stereotypes that are  already in the classes.

* [WIP] print json schema for all elements in project. Still missing some features.

added testModel.vpp to the vpp projects folder

* added support for association and other types

* Testing commit

* [wip] added uri to the elements

* Ongoing integration

* Functional remote verification

Non-blocking, logged, remote verification.
Requires refactoring.

* Minor improvements

Bug-fixes and refactoring

* Minor fixes

* Improved generation and error display on LOG 

Transformation shall be updated to workaround limitations of GSON's serialization and improvements on OntoUML Schema.

* Changing Stereotypes with Right Click

* Experimenting with default color profiles

* Fixing GSON issue and ClassCastException

* Updating stereotypes

* Setting up configurations menu

* Configurations Menu

* General improvements

* General refactoring and bugfix

* General refactoring and bugfix #2

* Major Refactoring and Documentation

Classes yet to be refactored/documented:
 - ActivateOntoUMLPlugin
 - ActivateDefaultStereotypes
 - StereotypeUtils
 - CollectionAdapter
 - Most classes within package it.unibz.inf.ontouml.vp.model

* Model Export feature and refactoring

* Auto-coloring feature and icons update

* Minor improvements to auto-coloring

It now affects all views of the selected model element.

* Maven project (#7)

* maven project

* removed readme

* openapi.jar was added to the project folder in order to be executed out of the box using maven compile.

* changed folder name lib to repo / changed compiler to java 11 in pom.xml

* gitignore updated

* solved identation in git ignore file

* Revert "Merge branch 'development' into maven-project"

This reverts commit a72c78c, reversing
changes made to 1cd30e4.

* Update .gitignore

* Delete openapi.jar

* Update .gitignore

* Removed unused imports

* Update .gitignore

* Including debug dependencies

* Cleaning POM file

* added generation of zip file of the plugin

* Update README and .gitignore

Co-authored-by: Tiago Prince Sales <tgoprince@users.noreply.github.com>
Co-authored-by: Claudenir Morais Fonseca <claudenirmf@gmail.com>

* removed toolbar buttons and removed some options in configurations panel.

* cardinality updated

* removed comment

* Removed XML Export Window.

* removed if to test if model verification is enabled

* fixed url server verification

* Fixed string regex in AssociationEnd

* set timeout for 60s in request verification

* added some logs in verification and also added behavior to check if custom server is enabled before mounting the URL.

* Added all stereotypes

* Stereotype order

* Update stereotype serialization

* Removed unused import

* Coloring enabled by default

* Update Stereotypes.java

* updated associationEnd and Attribute cardinalities

* change aggregationkind when applying stereotypes and set abstract to true when aplying mixin stereotype to classes

* [WIP] - implementing new schema

* wip - corrections in model creation to adapt to the new schema

* remove propertyAssignment class.

* created reference class

* fixes

* fix

* Some updates

Ongoing changes

* added propertyAssignment build

* wip - added property assignment to reflect better tagged values, add DataType class as well.

* isDerived logic

* Removed <<historical>> stereotype.

<<historicalDependence>> should be used instead.

* Update .gitignore

* Removed Stereotypes.java

This class only responsibility was to add the prefix ontouml/2 or vp/custom to stereotypes on the serialization. We decided not to have this prefixes on the exchanged models anymore.

* Update ModelExportAction.java

* Removed Reload plugin button

* Bugfix null pointer on Association and Property constructors

* removed datatype class and included datatype constructor in class class. Removed AssociationEnd and Attribute classes because it will be handled by Property class.

* fixed associationclass

* propertyAssignments in all elements

* fixed setName and isDerived

* fixed property assignments for association end

* added some comments

* id was not being set in Package Element

* added description field to the elements

* if description is empty set attribut to null

* fixed Reference in Generalization constructor

* fixed reference in GeneralizationSet

* fixed tagged values when model element is not specified

* ready to be merged

* Improvements from code review

* Removed duplicated code and fixed transformation of missing propertyType

* Missing refactoring from tagged value extraction

* Update Class.java

Co-authored-by: Claudenir Morais Fonseca <claudenirmf@gmail.com>
Co-authored-by: Tiago Prince Sales <tgoprince@users.noreply.github.com>

* added new file dialog to export model. Also suggets filename.

* if no property assignment added - return null

* if a Generalization has stereotypes in both ends does not add this generalization to the model.

* export json

Changed view to File Dialog
Now suggests the same name of the last save

* Quick fix on name suggestion

* Removed unused semicolon

* Only serializes generalizations between classes or associations

* Update ModelElement.java

Co-authored-by: Claudenir Morais Fonseca <claudenirmf@gmail.com>
Co-authored-by: Tiago Prince Sales <tgoprince@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 14, 2020
1 parent 372d16c commit 9d2fb12
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,25 @@ public class ModelExportAction implements VPActionController {
*/
@Override
public void performAction(VPAction action) {
final ProjectConfigurations configurations = Configurations.getInstance().getProjectConfigurations();
final ProjectConfigurations projectConfigurations = Configurations.getInstance().getProjectConfigurations();
final Configurations configs = Configurations.getInstance();

FileDialog fd = new FileDialog((Frame) ApplicationManager.instance().getViewManager().getRootFrame(),
"Choose destination", FileDialog.SAVE);

fd.setDirectory(configurations.getExportFolderPath());
fd.setFile("*.json");


String suggestedFilename;
fd.setDirectory(projectConfigurations.getExportFolderPath());

if(projectConfigurations.getExportFilename().isEmpty()){
String projectName = ApplicationManager.instance().getProjectManager().getProject().getName();
suggestedFilename = projectName+".json";
fd.setFile(suggestedFilename);
}else{
suggestedFilename = projectConfigurations.getExportFilename();
fd.setFile(suggestedFilename);
}

fd.setVisible(true);

String fileDirectory = fd.getDirectory();
Expand All @@ -51,7 +63,9 @@ public void performAction(VPAction action) {
try {
final String jsonModel = ModelElement.generateModel(true);
Files.write(Paths.get(fileDirectory, fileName), jsonModel.getBytes());
configurations.setExportFolderPath(fileDirectory);
projectConfigurations.setExportFolderPath(fileDirectory);
projectConfigurations.setExportFilename(fileName);
configs.save();
} catch (IOException e) {
ViewUtils.log(
"Export Failed. Please submit your Visual Paradigm's log and the time of the error our developers.",
Expand All @@ -72,4 +86,4 @@ public void performAction(VPAction action) {
public void update(VPAction action) {
}

}
}
39 changes: 27 additions & 12 deletions src/main/java/it/unibz/inf/ontouml/vp/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

/**
*
* Implementation of ModelElement to handle IModel objects
* to be serialized as ontouml-schema/Package
* Implementation of ModelElement to handle IModel objects to be serialized as
* ontouml-schema/Package
*
* @author Claudenir Fonseca
* @author Tiago Prince Sales
Expand Down Expand Up @@ -51,16 +51,15 @@ public class Model implements ModelElement {

/**
*
* Constructs a model to contain all project's model elements independent of a
* <code>IModelElement</code>.
* Constructs a model to contain all project's model elements independent of
* a <code>IModelElement</code>.
*
*/
public Model() {
final IProject project = ApplicationManager.instance().getProjectManager().getProject();
final String[] rootLevelElements = { IModelElementFactory.MODEL_TYPE_PACKAGE,
IModelElementFactory.MODEL_TYPE_MODEL, IModelElementFactory.MODEL_TYPE_CLASS, IModelElementFactory.MODEL_TYPE_DATA_TYPE };
final String[] anyLevelElements = { IModelElementFactory.MODEL_TYPE_GENERALIZATION,
IModelElementFactory.MODEL_TYPE_GENERALIZATION_SET, IModelElementFactory.MODEL_TYPE_ASSOCIATION,
final String[] rootLevelElements = { IModelElementFactory.MODEL_TYPE_PACKAGE, IModelElementFactory.MODEL_TYPE_MODEL, IModelElementFactory.MODEL_TYPE_CLASS,
IModelElementFactory.MODEL_TYPE_DATA_TYPE };
final String[] anyLevelElements = { IModelElementFactory.MODEL_TYPE_GENERALIZATION, IModelElementFactory.MODEL_TYPE_GENERALIZATION_SET, IModelElementFactory.MODEL_TYPE_ASSOCIATION,
IModelElementFactory.MODEL_TYPE_ASSOCIATION_CLASS };

this.sourceModelElement = null;
Expand Down Expand Up @@ -112,7 +111,7 @@ public String getDescription() {
}

public void setDescription(String description) {
this.description = ModelElement.safeGetString(description);;
this.description = ModelElement.safeGetString(description);
}

public List<ModelElement> getElements() {
Expand All @@ -133,35 +132,51 @@ public void addElement(ModelElement element) {
public boolean removeElement(ModelElement element) {
return this.contents.remove(element);
}

private void addModelElements(IModelElement[] modelElements) {
for (int i = 0; modelElements != null && i < modelElements.length; i++) {
final IModelElement projectElement = modelElements[i];

switch (projectElement.getModelType()) {
case IModelElementFactory.MODEL_TYPE_PACKAGE:
addElement(new Package((IPackage) projectElement));
break;

case IModelElementFactory.MODEL_TYPE_MODEL:
addElement(new Model((IModel) projectElement));
break;

case IModelElementFactory.MODEL_TYPE_CLASS:
addElement(new Class((IClass) projectElement));
break;

case IModelElementFactory.MODEL_TYPE_DATA_TYPE:
addElement(new Class((IDataType) projectElement));
break;

case IModelElementFactory.MODEL_TYPE_GENERALIZATION:
IGeneralization gen = (IGeneralization) projectElement;
if(!(gen.getFrom().getModelType().equals(IModelElementFactory.MODEL_TYPE_STEREOTYPE)&&gen.getTo().getModelType().equals(IModelElementFactory.MODEL_TYPE_STEREOTYPE)))

String fromType = gen.getFrom().getModelType();
boolean isFromClass = fromType.equals(IModelElementFactory.MODEL_TYPE_CLASS);
boolean isFromAssociation = fromType.equals(IModelElementFactory.MODEL_TYPE_ASSOCIATION);

String toType = gen.getTo().getModelType();
boolean isToClass = toType.equals(IModelElementFactory.MODEL_TYPE_CLASS);
boolean isToAssociation = toType.equals(IModelElementFactory.MODEL_TYPE_ASSOCIATION);

if ((isFromClass || isFromAssociation) && (isToClass || isToAssociation))
addElement(new Generalization((IGeneralization) projectElement));
break;

case IModelElementFactory.MODEL_TYPE_ASSOCIATION:
addElement(new Association((IAssociation) projectElement));
break;

case IModelElementFactory.MODEL_TYPE_GENERALIZATION_SET:
addElement(new GeneralizationSet((IGeneralizationSet) projectElement));
break;

case IModelElementFactory.MODEL_TYPE_ASSOCIATION_CLASS:
addElement(new AssociationClass((IAssociationClass) projectElement));
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/it/unibz/inf/ontouml/vp/model/ModelElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public static JsonObject transformPropertyAssignments(IModelElement sourceElemen

if(obj.size()==0)
return null;
else
return obj;

return obj;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Class that captures user preferences for a given project and enables JSON serialization.
*
* @author Claudenir Fonseca
* @author Victor Viola
*
*/
public class ProjectConfigurations {
Expand All @@ -18,6 +19,7 @@ public class ProjectConfigurations {
public static final boolean DEFAULT_IS_AUTOMATIC_COLORING_ENABLED = true;
public static final String DEFAULT_SERVER_URL = "https://ontouml.herokuapp.com";
public static final String DEFAULT_EXPORT_PATH = System.getProperty("user.home");
public static final String DEFAULT_EXPORT_FILENAME = "";

@SerializedName("projectId")
@Expose()
Expand All @@ -39,6 +41,10 @@ public class ProjectConfigurations {
@Expose()
private String exportFolderPath;

@SerializedName("exportFileName")
@Expose()
private String exportFileName;

@SerializedName("isExportEnabled")
@Expose()
private boolean isModelExportEnabled;
Expand Down Expand Up @@ -73,6 +79,7 @@ public void resetDefaults() {

this.isModelExportEnabled = ProjectConfigurations.DEFAULT_IS_EXPORT_ENABLED;
this.exportFolderPath = ProjectConfigurations.DEFAULT_EXPORT_PATH;
this.exportFileName = ProjectConfigurations.DEFAULT_EXPORT_FILENAME;

this.isAutomaticColoringEnabled = ProjectConfigurations.DEFAULT_IS_AUTOMATIC_COLORING_ENABLED;;
}
Expand Down Expand Up @@ -179,6 +186,29 @@ public void setExportFolderPath(String exportFolderPath) {
this.exportFolderPath = exportFolderPath;
}

/**
*
* Returns automatic export filename as a String.
*
* @return exportFileName
*
*/
public String getExportFilename() {
return exportFileName;
}


/**
*
* Sets automatic export filename from a String.
*
* @param exportFileName
*
*/
public void setExportFilename(String exportFileName) {
this.exportFileName = exportFileName;
}

/**
*
* Checks if an export folder is set for automatic model export.
Expand Down

0 comments on commit 9d2fb12

Please sign in to comment.