task(SimpleServiceWorker context) {
+ try {
+ if (schemaFilePath == null) {
+ context.cancel(true);
+ return List.of();
+ }
+
+ saveFilePath();
+
+ final String project = Uml2OntoumlTransformer.transformAndSerialize();
+ final String options = new DbMappingOptions(projectConfigurations).toJson();
+ final Ontouml2DbServiceResult serviceResult =
+ OntoUMLServerAccessController.requestModelTransformationToDb(project, options);
+
+ if (!context.isCancelled()) {
+ if (projectConfigurations.isGenerateSchema()) {
+ Files.write(schemaFilePath, serviceResult.getResult().getSchema().getBytes());
+ }
+ if (projectConfigurations.isGenerateObda()) {
+ Files.write(obdaFilePath, serviceResult.getResult().getObda().getBytes());
+ }
+ if (projectConfigurations.isGenerateConnection()) {
+ Files.write(propertiesFilePath, serviceResult.getResult().getConnection().getBytes());
+ }
+ ViewManagerUtils.log(MESSAGE_MODEL_EXPORTED);
+ return List.of(MESSAGE_MODEL_EXPORTED);
+ }
+
+ return List.of();
+
+ } catch (IOException e) {
+ if (!context.isCancelled()) {
+ ViewManagerUtils.log(e.getMessage());
+ }
+ e.printStackTrace();
+ return List.of(e.getMessage());
+ }
+ }
+
+ private boolean putFilePath() {
+ final FileDialog fileDialog;
+ final Frame rootFrame = (Frame) ApplicationManager.instance().getViewManager().getRootFrame();
+ final String suggestedFolderPath = projectConfigurations.getDbMappingFolderPath();
+ String suggestedFileName = projectConfigurations.getDbMappingFileName();
+
+ if (suggestedFileName.isEmpty()) {
+ suggestedFileName = ApplicationManager.instance().getProjectManager().getProject().getName();
+ }
+
+ final String title = "Choose file destination";
+ fileDialog = new FileDialog(rootFrame, title, FileDialog.SAVE);
+
+ fileDialog.setFile(suggestedFileName);
+ fileDialog.setDirectory(suggestedFolderPath);
+ fileDialog.setMultipleMode(false);
+ fileDialog.setVisible(true);
+
+ final String fileDirectory = fileDialog.getDirectory();
+ final String fileName = removeFileExtension(fileDialog.getFile());
+
+ if (fileDirectory != null && fileName != null) {
+ schemaFilePath = Paths.get(fileDirectory, fileName + schemaFormat);
+ obdaFilePath = Paths.get(fileDirectory, fileName + obdaFormat);
+ propertiesFilePath = Paths.get(fileDirectory, fileName + propertiesFormat);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private void saveFilePath() {
+ final Path directoryPath = schemaFilePath.getParent();
+ final String directoryPathName = directoryPath.toAbsolutePath().getFileName().toString();
+ final String filePathName = removeFileExtension(schemaFilePath.getFileName().toString());
+
+ projectConfigurations.setDbMappingFolderPath(directoryPathName);
+ projectConfigurations.setDbMappingFileName(filePathName);
+ configurations.save();
+ }
+
+ /**
+ * Called when the menu containing the button is accessed allowing for action manipulation, such
+ * as enable/disable or selecting the button.
+ *
+ * OBS: DOES NOT apply to this class.
+ */
+ @Override
+ public void update(VPAction action) {}
+
+ private String removeFileExtension(String fileName) {
+ if (fileName.lastIndexOf('.') > 0) return fileName.substring(0, fileName.lastIndexOf('.'));
+ else return fileName;
+ }
+}
diff --git a/src/main/java/it/unibz/inf/ontouml/vp/controllers/DbMappingDialogHandler.java b/src/main/java/it/unibz/inf/ontouml/vp/controllers/DbMappingDialogHandler.java
new file mode 100644
index 00000000..4888105c
--- /dev/null
+++ b/src/main/java/it/unibz/inf/ontouml/vp/controllers/DbMappingDialogHandler.java
@@ -0,0 +1,98 @@
+package it.unibz.inf.ontouml.vp.controllers;
+
+import com.vp.plugin.ApplicationManager;
+import com.vp.plugin.ViewManager;
+import com.vp.plugin.view.IDialog;
+import com.vp.plugin.view.IDialogHandler;
+import it.unibz.inf.ontouml.vp.OntoUMLPlugin;
+import it.unibz.inf.ontouml.vp.model.Configurations;
+import it.unibz.inf.ontouml.vp.model.ProjectConfigurations;
+import it.unibz.inf.ontouml.vp.views.DbMappingView;
+import java.awt.Component;
+
+public class DbMappingDialogHandler implements IDialogHandler {
+
+ private IDialog dialog;
+ private final DbMappingView view;
+ private final ViewManager viewManager;
+ private boolean wasShown = false;
+ private boolean wasClosed = false;
+ private boolean wasCancelled = false;
+
+ public DbMappingDialogHandler(ProjectConfigurations projectConfigurations) {
+ view = new DbMappingView(projectConfigurations);
+ viewManager = ApplicationManager.instance().getViewManager();
+
+ view.onExport(
+ e -> {
+ if (view.checkValidParamters()) {
+ view.updateConfigurationsValues(projectConfigurations);
+ Configurations.getInstance().save();
+ closeDialog();
+ }
+ });
+ view.onCancel(
+ e -> {
+ wasCancelled = true;
+ closeDialog();
+ });
+ }
+
+ /**
+ * Called once before the dialog is shown. Developer should return the content of the dialog
+ * (similar to the content pane).
+ */
+ @Override
+ public Component getComponent() {
+ return view;
+ }
+
+ /**
+ * Called after the getComponent(). A dialog is created on Visual Paradigm internally (it still
+ * not shown out). Developer can set the outlook of the dialog on prepare().
+ */
+ @Override
+ public void prepare(IDialog dialog) {
+ this.dialog = dialog;
+ dialog.setTitle(OntoUMLPlugin.PLUGIN_NAME);
+ dialog.setModal(true);
+ dialog.setResizable(false); // true
+ dialog.setSize(view.getWidth(), view.getHeight() + 20);
+ dialog.pack();
+ }
+
+ /** Called when the dialog is shown. */
+ @Override
+ public void shown() {}
+
+ /** Called when the dialog is closed by the user clicking on the close button of the frame. */
+ @Override
+ public boolean canClosed() {
+ wasCancelled = true;
+ wasClosed = true;
+ return true;
+ }
+
+ public void showDialog() {
+ if (!wasClosed) {
+ wasShown = true;
+ viewManager.showDialog(this);
+ }
+ }
+
+ public void closeDialog() {
+ if (wasClosed) {
+ System.out.println("Mapping to ER dialog was already closed.");
+ } else if (!wasShown) {
+ System.out.println("Mapping to ER dialog was never shown. Setting wasClosed to \"true\"");
+ } else {
+ System.out.println("Closing mapping do ER dialog.");
+ dialog.close();
+ }
+ wasClosed = true;
+ }
+
+ public boolean wasCancelled() {
+ return wasCancelled;
+ }
+}
diff --git a/src/main/java/it/unibz/inf/ontouml/vp/controllers/OntoUMLServerAccessController.java b/src/main/java/it/unibz/inf/ontouml/vp/controllers/OntoUMLServerAccessController.java
index 6de3ca12..d4ecb20b 100644
--- a/src/main/java/it/unibz/inf/ontouml/vp/controllers/OntoUMLServerAccessController.java
+++ b/src/main/java/it/unibz/inf/ontouml/vp/controllers/OntoUMLServerAccessController.java
@@ -1,12 +1,16 @@
package it.unibz.inf.ontouml.vp.controllers;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.mashape.unirest.http.*;
+import com.mashape.unirest.http.exceptions.UnirestException;
import it.unibz.inf.ontouml.vp.model.Configurations;
import it.unibz.inf.ontouml.vp.model.GufoTransformationServiceResult;
import it.unibz.inf.ontouml.vp.model.ModularizationServiceResult;
+import it.unibz.inf.ontouml.vp.model.Ontouml2DbServiceResult;
import it.unibz.inf.ontouml.vp.model.ProjectConfigurations;
import it.unibz.inf.ontouml.vp.model.ServiceResult;
import it.unibz.inf.ontouml.vp.model.VerificationServiceResult;
+import java.io.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -25,9 +29,11 @@
*/
public class OntoUMLServerAccessController {
+ private static final String MODULARIZATION_SERVICE_ENDPOINT = "/v1/modularize";
private static final String TRANSFORM_GUFO_SERVICE_ENDPOINT = "/v1/transform/gufo";
+ private static final String TRANSFORM_DB_SERVICE_ENDPOINT = "/v1/transform/db";
private static final String VERIFICATION_SERVICE_ENDPOINT = "/v1/verify";
- private static final String MODULARIZATION_SERVICE_ENDPOINT = "/v1/modularize";
+
private static final String USER_MESSAGE_BAD_REQUEST =
"There was a internal plugin error and the service could not be completed.";
private static final String USER_MESSAGE_REQUEST_WITH_SYNTACTICAL_ERRORS =
@@ -46,25 +52,27 @@ private static String getServiceRequestBody(String project, String options) {
return "{\"options\": " + options + ", \"project\": " + project + "}";
}
- private static String getModularizationRequestUrl() {
+ private static String getServerUrl() {
final ProjectConfigurations config = Configurations.getInstance().getProjectConfigurations();
return config.isCustomServerEnabled()
- ? config.getServerURL() + MODULARIZATION_SERVICE_ENDPOINT
- : ProjectConfigurations.DEFAULT_SERVER_URL + MODULARIZATION_SERVICE_ENDPOINT;
+ ? config.getServerURL()
+ : ProjectConfigurations.DEFAULT_SERVER_URL;
+ }
+
+ private static String getModularizationRequestUrl() {
+ return getServerUrl() + MODULARIZATION_SERVICE_ENDPOINT;
}
private static String getVerificationRequestUrl() {
- final ProjectConfigurations config = Configurations.getInstance().getProjectConfigurations();
- return config.isCustomServerEnabled()
- ? config.getServerURL() + VERIFICATION_SERVICE_ENDPOINT
- : ProjectConfigurations.DEFAULT_SERVER_URL + VERIFICATION_SERVICE_ENDPOINT;
+ return getServerUrl() + VERIFICATION_SERVICE_ENDPOINT;
}
private static String getTransformationToGufoRequestUrl() {
- final ProjectConfigurations config = Configurations.getInstance().getProjectConfigurations();
- return config.isCustomServerEnabled()
- ? config.getServerURL() + TRANSFORM_GUFO_SERVICE_ENDPOINT
- : ProjectConfigurations.DEFAULT_SERVER_URL + TRANSFORM_GUFO_SERVICE_ENDPOINT;
+ return getServerUrl() + TRANSFORM_GUFO_SERVICE_ENDPOINT;
+ }
+
+ private static String getMappingToErRequestUrl() {
+ return getServerUrl() + TRANSFORM_DB_SERVICE_ENDPOINT;
}
private static > T parseResponse(
@@ -114,8 +122,19 @@ public static GufoTransformationServiceResult requestModelTransformationToGufo(
return parseResponse(connection, GufoTransformationServiceResult.class);
}
+ public static Ontouml2DbServiceResult requestModelTransformationToDb(
+ String project, String options) throws IOException {
+ final String url = getMappingToErRequestUrl();
+ final String body = getServiceRequestBody(project, options);
+ final HttpURLConnection connection = request(url, body);
+
+ return parseResponse(connection, Ontouml2DbServiceResult.class);
+ }
+
private static HttpURLConnection request(String url, String body) throws IOException {
try {
+ System.out.println(body);
+
final HttpURLConnection connection = performRequest(url, body);
switch (connection.getResponseCode()) {
@@ -136,6 +155,7 @@ private static HttpURLConnection request(String url, String body) throws IOExcep
throw new IOException(USER_MESSAGE_UNKNOWN_ERROR_RESPONSE);
}
} catch (SocketException e) {
+
throw new IOException(USER_MESSAGE_CONNECTION_ERROR);
} catch (IOException e) {
throw e;
@@ -144,36 +164,11 @@ private static HttpURLConnection request(String url, String body) throws IOExcep
}
}
- // public static GufoTransformationServiceResult requestProjectTransformationToGufo(
- // String project, String options) {
- // final String body = getServiceRequestBody(project, options);
- // final String url = getTransformationToGufoRequestUrl();
- //
- // try {
- // final HttpURLConnection connection = performRequest(url, body);
- //
- // switch (connection.getResponseCode()) {
- // case HttpURLConnection.HTTP_OK:
- // if (hasJsonContentType(connection)) {
- // return parseResponse(connection, GufoTransformationServiceResult.class);
- // }
- // case HttpURLConnection.HTTP_BAD_REQUEST:
- // case HttpURLConnection.HTTP_NOT_FOUND:
- // case HttpURLConnection.HTTP_INTERNAL_ERROR:
- // default:
- // System.err.println("Attention! Transformation request was not processed correctly");
- // System.err.println("Status Code: " + connection.getResponseCode());
- // }
- // } catch (IOException ioException) {
- // ioException.printStackTrace();
- // }
- //
- // return null;
- // }
-
private static HttpURLConnection performRequest(String urlString, String body)
- throws IOException {
+ throws IOException, UnirestException {
+
final URL url = new URL(urlString);
+
final HttpURLConnection request = (HttpURLConnection) url.openConnection();
request.setRequestMethod("POST");
diff --git a/src/main/java/it/unibz/inf/ontouml/vp/model/DbMappingOptions.java b/src/main/java/it/unibz/inf/ontouml/vp/model/DbMappingOptions.java
new file mode 100644
index 00000000..572534a4
--- /dev/null
+++ b/src/main/java/it/unibz/inf/ontouml/vp/model/DbMappingOptions.java
@@ -0,0 +1,141 @@
+package it.unibz.inf.ontouml.vp.model;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class DbMappingOptions {
+
+ private MappingStrategy mappingStrategy;
+ private DbmsSupported targetDBMS;
+ private boolean isStandardizeNames;
+ private String baseIri;
+ private boolean generateSchema;
+ private boolean generateConnection;
+ private String hostName;
+ private String databaseName;
+ private String userConnection;
+ private String passwordConnection;
+ private boolean enumFieldToLookupTable;
+ private JsonNode customElementMapping;
+
+ public DbMappingOptions() {}
+
+ public DbMappingOptions(ProjectConfigurations projectConfigurations) {
+
+ this.mappingStrategy = projectConfigurations.getMappingStrategy();
+ this.targetDBMS = projectConfigurations.getTargetDBMS();
+ this.isStandardizeNames = projectConfigurations.isStandardizeNames();
+ this.baseIri = projectConfigurations.getExportGUFOIRI();
+ this.generateSchema = projectConfigurations.isGenerateSchema();
+ this.generateConnection = projectConfigurations.isGenerateConnection();
+ this.hostName = projectConfigurations.getHostNameConnection();
+ this.databaseName = projectConfigurations.getDatabaseNameConnection();
+ this.userConnection = projectConfigurations.getUserNameConnection();
+ this.passwordConnection = projectConfigurations.getPassword();
+ // this.enumFieldToLookupTable = projectConfigurations.isEnumFieldToLookupTable();
+ this.enumFieldToLookupTable = true;
+
+ // TODO: re-introduce element mapping when partial export is available again
+ }
+
+ public MappingStrategy getMappingStrategy() {
+ return mappingStrategy;
+ }
+
+ public void setMappingStrategy(MappingStrategy mappingStrategy) {
+ this.mappingStrategy = mappingStrategy;
+ }
+
+ public DbmsSupported getTargetDBMS() {
+ return targetDBMS;
+ }
+
+ public void setTargetDBMS(DbmsSupported targetDBMS) {
+ this.targetDBMS = targetDBMS;
+ }
+
+ public boolean isStandardizeNames() {
+ return isStandardizeNames;
+ }
+
+ public void setStandardizeNames(boolean isStandardizeNames) {
+ this.isStandardizeNames = isStandardizeNames;
+ }
+
+ public String getBaseIri() {
+ return baseIri;
+ }
+
+ public void setBaseIri(String baseIri) {
+ this.baseIri = baseIri;
+ }
+
+ public boolean isGenerateSchema() {
+ return generateSchema;
+ }
+
+ public void setGenerateSchema(boolean generateSchema) {
+ this.generateSchema = generateSchema;
+ }
+
+ public boolean isGenerateConnection() {
+ return generateConnection;
+ }
+
+ public void setGenerateConnection(boolean generateConnection) {
+ this.generateConnection = generateConnection;
+ }
+
+ public String getHostName() {
+ return hostName;
+ }
+
+ public void setHostName(String hostName) {
+ this.hostName = hostName;
+ }
+
+ public String getDatabaseName() {
+ return databaseName;
+ }
+
+ public void setDatabaseName(String databaseName) {
+ this.databaseName = databaseName;
+ }
+
+ public String getUserConnection() {
+ return userConnection;
+ }
+
+ public void setUserConnection(String userConnection) {
+ this.userConnection = userConnection;
+ }
+
+ public String getPasswordConnection() {
+ return passwordConnection;
+ }
+
+ public void setPasswordConnection(String passwordConnection) {
+ this.passwordConnection = passwordConnection;
+ }
+
+ public boolean isEnumFieldToLookupTable() {
+ return enumFieldToLookupTable;
+ }
+
+ public void setEnumFieldToLookupTable(boolean enumFieldToLookupTable) {
+ this.enumFieldToLookupTable = enumFieldToLookupTable;
+ }
+
+ public JsonNode getCustomElementMapping() {
+ return customElementMapping;
+ }
+
+ public void setCustomElementMapping(JsonNode customElementMapping) {
+ this.customElementMapping = customElementMapping;
+ }
+
+ public String toJson() throws JsonProcessingException {
+ return new ObjectMapper().writeValueAsString(this);
+ }
+}
diff --git a/src/main/java/it/unibz/inf/ontouml/vp/model/DbmsSupported.java b/src/main/java/it/unibz/inf/ontouml/vp/model/DbmsSupported.java
new file mode 100644
index 00000000..ea4874b4
--- /dev/null
+++ b/src/main/java/it/unibz/inf/ontouml/vp/model/DbmsSupported.java
@@ -0,0 +1,24 @@
+package it.unibz.inf.ontouml.vp.model;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+
+public enum DbmsSupported {
+ GENERIC_SCHEMA("Generic Schema"),
+ MYSQL("MySql"),
+ H2("H2"),
+ SQLSERVER("SqlServer"),
+ ORACLE("Oracle"),
+ POSTGREE("Postgree");
+
+ private final String display;
+
+ private DbmsSupported(String s) {
+ display = s;
+ }
+
+ @JsonValue
+ @Override
+ public String toString() {
+ return display;
+ }
+}
diff --git a/src/main/java/it/unibz/inf/ontouml/vp/model/MappingStrategy.java b/src/main/java/it/unibz/inf/ontouml/vp/model/MappingStrategy.java
new file mode 100644
index 00000000..895f327c
--- /dev/null
+++ b/src/main/java/it/unibz/inf/ontouml/vp/model/MappingStrategy.java
@@ -0,0 +1,22 @@
+/** Author: Gustavo Ludovico Guidoni */
+package it.unibz.inf.ontouml.vp.model;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+
+public enum MappingStrategy {
+ ONE_TABLE_PER_CLASS("One Table per Class"),
+ ONE_TABLE_PER_KIND("One Table per Kind"),
+ ONE_TABLE_PER_CONCRETE_CLASS("One Table per Concrete Class");
+
+ private final String display;
+
+ private MappingStrategy(String s) {
+ display = s;
+ }
+
+ @JsonValue
+ @Override
+ public String toString() {
+ return display;
+ }
+}
diff --git a/src/main/java/it/unibz/inf/ontouml/vp/model/Ontouml2DbResult.java b/src/main/java/it/unibz/inf/ontouml/vp/model/Ontouml2DbResult.java
new file mode 100644
index 00000000..541098b0
--- /dev/null
+++ b/src/main/java/it/unibz/inf/ontouml/vp/model/Ontouml2DbResult.java
@@ -0,0 +1,44 @@
+package it.unibz.inf.ontouml.vp.model;
+
+public class Ontouml2DbResult {
+
+ private String schema;
+ private String obda;
+ private String connection;
+
+ Ontouml2DbResult() {
+ this.schema = null;
+ this.obda = null;
+ this.connection = null;
+ }
+
+ Ontouml2DbResult(String schema, String odba, String connection) {
+ this.schema = schema;
+ this.obda = odba;
+ this.connection = connection;
+ }
+
+ public String getSchema() {
+ return schema;
+ }
+
+ public void setSchema(String schema) {
+ this.schema = schema;
+ }
+
+ public String getObda() {
+ return obda;
+ }
+
+ public void setObda(String obda) {
+ this.obda = obda;
+ }
+
+ public String getConnection() {
+ return connection;
+ }
+
+ public void setConnection(String connection) {
+ this.connection = connection;
+ }
+}
diff --git a/src/main/java/it/unibz/inf/ontouml/vp/model/Ontouml2DbServiceResult.java b/src/main/java/it/unibz/inf/ontouml/vp/model/Ontouml2DbServiceResult.java
new file mode 100644
index 00000000..87933907
--- /dev/null
+++ b/src/main/java/it/unibz/inf/ontouml/vp/model/Ontouml2DbServiceResult.java
@@ -0,0 +1,19 @@
+package it.unibz.inf.ontouml.vp.model;
+
+import java.util.List;
+
+public class Ontouml2DbServiceResult extends ServiceResult {
+
+ public Ontouml2DbServiceResult(Ontouml2DbResult result, List issues) {
+ super(result, issues);
+ }
+
+ public Ontouml2DbServiceResult() {
+ super();
+ }
+
+ @Override
+ public String getMessage() {
+ return "The mapping to database was concluded";
+ }
+}
diff --git a/src/main/java/it/unibz/inf/ontouml/vp/model/ProjectConfigurations.java b/src/main/java/it/unibz/inf/ontouml/vp/model/ProjectConfigurations.java
index bd5c18e8..82382c19 100644
--- a/src/main/java/it/unibz/inf/ontouml/vp/model/ProjectConfigurations.java
+++ b/src/main/java/it/unibz/inf/ontouml/vp/model/ProjectConfigurations.java
@@ -25,6 +25,18 @@ public class ProjectConfigurations {
public static final String DEFAULT_EXPORT_FILENAME = "";
public static final String DEFAULT_GUFO_EXPORT_PATH = System.getProperty("user.home");
public static final String DEFAULT_GUFO_EXPORT_FILENAME = "";
+ // ***** DAFAULTS por Export to DB ***************
+ public static final DbmsSupported DEFAULT_DBMS = DbmsSupported.GENERIC_SCHEMA;
+ public static final MappingStrategy DEFAULT_MAPPING_STRATEGY = MappingStrategy.ONE_TABLE_PER_KIND;
+ public static final boolean DEFAULT_STANTDARDIZE_NAMES = true;
+ public static final boolean DEFAULT_GENERATE_INDEXES = false;
+ public static final boolean DEFAULT_GENERATE_SCHEMA = true;
+ public static final boolean DEFAULT_GENERATE_OBDA = true;
+ public static final boolean DEFAULT_GENERATE_CONNECTION = false;
+ public static final String DEFAULT_DB_MAPPING_PATH = System.getProperty("user.home");
+ public static final String DEFAULT_DB_MAPPING_FILE_NAME = "";
+ public static final boolean DEFAULT_IS_ENUMARATION_TO_LOOKUP_TABLE = false;
+ // ***********************************************
@SerializedName("projectId")
@Expose()
@@ -118,6 +130,63 @@ public class ProjectConfigurations {
@Expose()
private boolean ignoreAssociationInversionWarning;
+ // Transformation properties for Relational Schema
+ @SerializedName("mappingStrategy")
+ @Expose()
+ private MappingStrategy mappingStrategy;
+
+ @SerializedName("targetDBMS")
+ @Expose()
+ private DbmsSupported targetDBMS;
+
+ @SerializedName("standarizeNames")
+ @Expose()
+ private boolean standardizeNames;
+
+ @SerializedName("generateSchema")
+ @Expose()
+ private boolean generateSchema;
+
+ @SerializedName("generateObda")
+ @Expose()
+ private boolean generateObda;
+
+ @SerializedName("generateConnection")
+ @Expose()
+ private boolean generateConnection;
+
+ @SerializedName("hostNameConnection")
+ @Expose()
+ private String hostNameConnection;
+
+ @SerializedName("databaseConnection")
+ @Expose()
+ private String databaseConnection;
+
+ @SerializedName("userConnection")
+ @Expose()
+ private String userConnection;
+
+ @SerializedName("passwordConnectino")
+ @Expose()
+ private String passwordConnectino;
+
+ @SerializedName("dbMappingFileName")
+ @Expose()
+ private String dbMappingFileName;
+
+ @SerializedName("dbMappingFolderPath")
+ @Expose()
+ private String dbMappingFolderPath;
+
+ @SerializedName("enumFieldToLookupTable")
+ @Expose()
+ private boolean enumFieldToLookupTable;
+
+ @SerializedName("generateIndexes")
+ @Expose()
+ private boolean generateIndexes;
+
/** Constructor without args to be called when deserializing project settings. */
public ProjectConfigurations() {
this.id = "";
@@ -155,6 +224,17 @@ public void setDefaultValues() {
this.isSmartModellingEnabled = ProjectConfigurations.DEFAULT_IS_AUTOMATIC_MODELLING_ENABLED;
this.ignoreAssociationInversionWarning =
ProjectConfigurations.DEFAULT_IGNORE_ASSOCIATION_INVERSION_WARNING;
+
+ this.targetDBMS = ProjectConfigurations.DEFAULT_DBMS;
+ this.mappingStrategy = ProjectConfigurations.DEFAULT_MAPPING_STRATEGY;
+ this.standardizeNames = ProjectConfigurations.DEFAULT_STANTDARDIZE_NAMES;
+ this.generateIndexes = ProjectConfigurations.DEFAULT_GENERATE_INDEXES;
+ this.generateSchema = ProjectConfigurations.DEFAULT_GENERATE_SCHEMA;
+ this.generateObda = ProjectConfigurations.DEFAULT_GENERATE_OBDA;
+ this.generateConnection = ProjectConfigurations.DEFAULT_GENERATE_CONNECTION;
+ this.dbMappingFileName = ProjectConfigurations.DEFAULT_DB_MAPPING_FILE_NAME;
+ this.dbMappingFolderPath = ProjectConfigurations.DEFAULT_DB_MAPPING_PATH;
+ this.enumFieldToLookupTable = ProjectConfigurations.DEFAULT_IS_ENUMARATION_TO_LOOKUP_TABLE;
}
/**
@@ -426,4 +506,257 @@ public boolean ignoreAssociationInversionWarning() {
public void setIgnoreAssociationInversionWarning(boolean ignoreAssociationInversionWarning) {
this.ignoreAssociationInversionWarning = ignoreAssociationInversionWarning;
}
+
+ /**
+ * Informs the mapping strategy for the relational schema.
+ *
+ * @param mappingStrategy
+ */
+ public void setMappingStrategy(MappingStrategy mappingStrategy) {
+ this.mappingStrategy = mappingStrategy;
+ }
+
+ /**
+ * Returns the mapping strategy for the relational schema.
+ *
+ * @return MappingStrategy
+ */
+ public MappingStrategy getMappingStrategy() {
+ return this.mappingStrategy;
+ }
+
+ /**
+ * Checks whether the nomenclature will be standardized in the database.
+ *
+ * @return boolean
+ */
+ public boolean isStandardizeNames() {
+ return standardizeNames;
+ }
+
+ /**
+ * Informs if the nomenclature will be standardized in the database.
+ *
+ * @param standarizeNames
+ */
+ public void setStandardizeNames(boolean standarizeNames) {
+ this.standardizeNames = standarizeNames;
+ }
+
+ /**
+ * Returns the target DBMS for generating the files.
+ *
+ * @return DBMSSuported
+ */
+ public DbmsSupported getTargetDBMS() {
+ return targetDBMS;
+ }
+
+ /**
+ * Informs the target DBMS for generating the files.
+ *
+ * @param targetDBMS
+ */
+ public void setTargetDBMS(DbmsSupported targetDBMS) {
+ this.targetDBMS = targetDBMS;
+ }
+
+ /**
+ * Returns if it is necessary to generate the relational schema for the ontology.
+ *
+ * @return boolean
+ */
+ public boolean isGenerateSchema() {
+ return this.generateSchema;
+ }
+
+ /**
+ * Informs if it is necessary to generate the relational schema for the ontology.
+ *
+ * @param generateSchema
+ */
+ public void setGenerateSchema(boolean generateSchema) {
+ this.generateSchema = generateSchema;
+ }
+
+ /**
+ * Returns if it is necessary to generate the OBDA file for the ontology.
+ *
+ * @return boolean
+ */
+ public boolean isGenerateObda() {
+ return this.generateObda;
+ }
+
+ /**
+ * Informs if it is necessary to generate the OBDA file for the ontology.
+ *
+ * @param generateSchema
+ */
+ public void setGenerateObda(boolean generateObda) {
+ this.generateObda = generateObda;
+ }
+
+ /**
+ * Returns if it is necessary to generate the connection for the database.
+ *
+ * @return boolean
+ */
+ public boolean isGenerateConnection() {
+ return generateConnection;
+ }
+
+ /**
+ * Informs if it is necessary to generate the connection for the database.
+ *
+ * @param generateConnection
+ */
+ public void setGenerateConnection(boolean generateConnection) {
+ this.generateConnection = generateConnection;
+ }
+
+ /**
+ * Returns the host name connection.
+ *
+ * @return string
+ */
+ public String getHostNameConnection() {
+ return hostNameConnection;
+ }
+
+ /**
+ * Informs the host name connection.
+ *
+ * @param hostName
+ */
+ public void setHostNameConnection(String hostName) {
+ this.hostNameConnection = hostName;
+ }
+
+ /**
+ * Returns the database name connection.
+ *
+ * @return string
+ */
+ public String getDatabaseNameConnection() {
+ return databaseConnection;
+ }
+
+ /**
+ * Informs the database name connection.
+ *
+ * @param databaseName
+ */
+ public void setDatabaseNameConnection(String databaseName) {
+ this.databaseConnection = databaseName;
+ }
+
+ /**
+ * Returns the user name connection.
+ *
+ * @return string
+ */
+ public String getUserNameConnection() {
+ return userConnection;
+ }
+
+ /**
+ * Informs the user name connection.
+ *
+ * @param userName
+ */
+ public void setUserNameConnection(String userName) {
+ this.userConnection = userName;
+ }
+
+ /**
+ * Returns the password connection.
+ *
+ * @return string
+ */
+ public String getPassword() {
+ return passwordConnectino;
+ }
+
+ /**
+ * Informs the password connection.
+ *
+ * @param password
+ */
+ public void setPassword(String password) {
+ this.passwordConnectino = password;
+ }
+
+ /**
+ * Returns the file name for mapping to ER.
+ *
+ * @return
+ */
+ public String getDbMappingFileName() {
+ return this.dbMappingFileName;
+ }
+ ;
+
+ /**
+ * Informs the file name for mapping to ER.
+ *
+ * @param string
+ */
+ public void setDbMappingFileName(String dbMappingFileName) {
+ this.dbMappingFileName = dbMappingFileName;
+ }
+
+ /**
+ * Returns the directory to save the files mapping.
+ *
+ * @return String
+ */
+ public String getDbMappingFolderPath() {
+ return this.dbMappingFolderPath;
+ }
+
+ /**
+ * Informs the directory for mapping to ER.
+ *
+ * @param string
+ */
+ public void setDbMappingFolderPath(String dbMappingFolderPath) {
+ this.dbMappingFolderPath = dbMappingFolderPath;
+ }
+
+ /**
+ * Returns if it is necessary generate a table for the enumeration type fields.
+ *
+ * @return boolean
+ */
+ public boolean isEnumFieldToLookupTable() {
+ return this.enumFieldToLookupTable;
+ }
+
+ /**
+ * Informs if it is necessary generate a table for the enumeration type fields.
+ *
+ * @param boolean
+ */
+ public void setEnumFieldToLookupTable(boolean isEnumFieldToLookupTable) {
+ this.enumFieldToLookupTable = isEnumFieldToLookupTable;
+ }
+
+ /**
+ * Returns if it is necessary generate the index for the schema.
+ *
+ * @return boolean
+ */
+ public boolean isGenerateIndex() {
+ return this.generateIndexes;
+ }
+
+ /**
+ * Informs if it is necessary generate the indexes for the schema.
+ *
+ * @param boolean
+ */
+ public void setGenerateIndexes(boolean generateIndexes) {
+ this.generateIndexes = generateIndexes;
+ }
}
diff --git a/src/main/java/it/unibz/inf/ontouml/vp/model/uml/Class.java b/src/main/java/it/unibz/inf/ontouml/vp/model/uml/Class.java
index da5dd0f2..25f4b26a 100644
--- a/src/main/java/it/unibz/inf/ontouml/vp/model/uml/Class.java
+++ b/src/main/java/it/unibz/inf/ontouml/vp/model/uml/Class.java
@@ -465,7 +465,7 @@ public static void setRestrictedTo(IClass _class, String restrictions) {
}
private static void setDefaultRestrictedTo(IClass element, String stereotypeName) {
- String currentRestrictedTo = getRestrictedTo(element);
+ List currentRestrictedTo = getRestrictedToList(element);
if (RestrictedTo.shouldOverrideRestrictedTo(stereotypeName, currentRestrictedTo)) {
final String defaultNature = RestrictedTo.getDefaultRestrictedTo(stereotypeName);
diff --git a/src/main/java/it/unibz/inf/ontouml/vp/model/uml/Property.java b/src/main/java/it/unibz/inf/ontouml/vp/model/uml/Property.java
index f881d088..c71494ba 100644
--- a/src/main/java/it/unibz/inf/ontouml/vp/model/uml/Property.java
+++ b/src/main/java/it/unibz/inf/ontouml/vp/model/uml/Property.java
@@ -420,13 +420,23 @@ public String getType() {
}
public static void removeRedefinedProperties(IAssociationEnd associationEnd) {
- Stream.of(associationEnd.toRedefinedPropertyArray())
- .forEach(redefined -> associationEnd.removeRedefinedProperty(redefined));
+ var array = associationEnd.toRedefinedPropertyArray();
+
+ if (array == null) {
+ return;
+ }
+
+ Stream.of(array).forEach(redefined -> associationEnd.removeRedefinedProperty(redefined));
}
public static void removeSubsettedProperties(IAssociationEnd associationEnd) {
- Stream.of(associationEnd.toSubsettedPropertyArray())
- .forEach(subsetted -> associationEnd.removeSubsettedProperty(subsetted));
+ var array = associationEnd.toSubsettedPropertyArray();
+
+ if (array == null) {
+ return;
+ }
+
+ Stream.of(array).forEach(subsetted -> associationEnd.removeSubsettedProperty(subsetted));
}
public static void addRedefinedProperties(
diff --git a/src/main/java/it/unibz/inf/ontouml/vp/utils/RestrictedTo.java b/src/main/java/it/unibz/inf/ontouml/vp/utils/RestrictedTo.java
index 93750d52..91e62b07 100644
--- a/src/main/java/it/unibz/inf/ontouml/vp/utils/RestrictedTo.java
+++ b/src/main/java/it/unibz/inf/ontouml/vp/utils/RestrictedTo.java
@@ -82,7 +82,7 @@ public static List possibleRestrictedToValues(String stereotype) {
}
}
- public static boolean shouldOverrideRestrictedTo(String stereotype, String restrictedTo) {
+ public static boolean shouldOverrideRestrictedTo(String stereotype, List restrictedTo) {
switch (stereotype) {
case Stereotype.TYPE:
case Stereotype.EVENT:
@@ -92,11 +92,15 @@ public static boolean shouldOverrideRestrictedTo(String stereotype, String restr
case Stereotype.QUANTITY:
case Stereotype.RELATOR:
case Stereotype.QUALITY:
- case Stereotype.MODE:
case Stereotype.ENUMERATION:
case Stereotype.DATATYPE:
case Stereotype.ABSTRACT:
return true;
+ case Stereotype.MODE:
+ return restrictedTo.stream()
+ .anyMatch(
+ restriction ->
+ !INTRINSIC_MODE.equals(restriction) && !EXTRINSIC_MODE.equals(restriction));
case Stereotype.CATEGORY:
case Stereotype.MIXIN:
case Stereotype.ROLE_MIXIN:
diff --git a/src/main/java/it/unibz/inf/ontouml/vp/views/DbMappingView.java b/src/main/java/it/unibz/inf/ontouml/vp/views/DbMappingView.java
new file mode 100644
index 00000000..f81cb854
--- /dev/null
+++ b/src/main/java/it/unibz/inf/ontouml/vp/views/DbMappingView.java
@@ -0,0 +1,644 @@
+package it.unibz.inf.ontouml.vp.views;
+
+import it.unibz.inf.ontouml.vp.model.DbmsSupported;
+import it.unibz.inf.ontouml.vp.model.MappingStrategy;
+import it.unibz.inf.ontouml.vp.model.ProjectConfigurations;
+import java.awt.Dimension;
+import java.awt.event.ActionListener;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JOptionPane;
+
+public class DbMappingView extends javax.swing.JPanel {
+
+ private static final long serialVersionUID = 1L;
+
+ private javax.swing.JComboBox cbxDBMS;
+ private javax.swing.JCheckBox cbxStandarizeNames;
+ private javax.swing.JCheckBox cxbCreateIndex;
+ private javax.swing.JCheckBox cxbEnumToLookupTable;
+ private javax.swing.JCheckBox cxbGenerateConnection;
+ private javax.swing.JCheckBox cxbGenerateObda;
+ private javax.swing.JCheckBox cxbGenerateSchema;
+ private javax.swing.ButtonGroup groupStrategy;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JLabel jLabel3;
+ private javax.swing.JLabel jLabel4;
+ private javax.swing.JLabel jLabel5;
+ private javax.swing.JLabel jLabel6;
+ private javax.swing.JLabel jLabel7;
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JPanel jPanel4;
+ private javax.swing.JPanel jPanel5;
+ private javax.swing.JPanel jPanel6;
+ private javax.swing.JTabbedPane jTabbedPane1;
+ private javax.swing.JButton jbtnCancel;
+ private javax.swing.JButton jbtnOk;
+ private javax.swing.JTextField jtfBaseIRI;
+ private javax.swing.JTextField jtfDatabase;
+ private javax.swing.JTextField jtfHost;
+ private javax.swing.JTextField jtfPassword;
+ private javax.swing.JTextField jtfUser;
+ private javax.swing.JRadioButton rbtOneTablePerClass;
+ private javax.swing.JRadioButton rbtOneTablePerConcreteClass;
+ private javax.swing.JRadioButton rbtOneTablePerKind;
+
+ public DbMappingView(ProjectConfigurations configurations) {
+ initComponents();
+
+ setComponentsValues(configurations);
+ }
+
+ private void initComponents() {
+
+ // *************************************
+ // Manually generated code.
+ // *************************************
+ setSize(new Dimension(500, 360));
+
+ // *************************************
+ // Automatically generated code.
+ // *************************************
+
+ groupStrategy = new javax.swing.ButtonGroup();
+ jTabbedPane1 = new javax.swing.JTabbedPane();
+ jPanel2 = new javax.swing.JPanel();
+ cxbGenerateSchema = new javax.swing.JCheckBox();
+ jPanel1 = new javax.swing.JPanel();
+ rbtOneTablePerClass = new javax.swing.JRadioButton();
+ rbtOneTablePerConcreteClass = new javax.swing.JRadioButton();
+ rbtOneTablePerKind = new javax.swing.JRadioButton();
+ jLabel3 = new javax.swing.JLabel();
+ cbxDBMS = new javax.swing.JComboBox<>();
+ cbxStandarizeNames = new javax.swing.JCheckBox();
+ jLabel1 = new javax.swing.JLabel();
+ cxbEnumToLookupTable = new javax.swing.JCheckBox();
+ cxbCreateIndex = new javax.swing.JCheckBox();
+ jPanel6 = new javax.swing.JPanel();
+ jLabel2 = new javax.swing.JLabel();
+ jtfBaseIRI = new javax.swing.JTextField();
+ cxbGenerateObda = new javax.swing.JCheckBox();
+ jPanel5 = new javax.swing.JPanel();
+ jLabel4 = new javax.swing.JLabel();
+ jLabel5 = new javax.swing.JLabel();
+ jLabel6 = new javax.swing.JLabel();
+ jLabel7 = new javax.swing.JLabel();
+ jtfHost = new javax.swing.JTextField();
+ jtfUser = new javax.swing.JTextField();
+ jtfDatabase = new javax.swing.JTextField();
+ jtfPassword = new javax.swing.JTextField();
+ cxbGenerateConnection = new javax.swing.JCheckBox();
+ jPanel4 = new javax.swing.JPanel();
+ jbtnCancel = new javax.swing.JButton();
+ jbtnOk = new javax.swing.JButton();
+
+ cxbGenerateSchema.setSelected(true);
+ cxbGenerateSchema.setText("Generate relational schema");
+ cxbGenerateSchema.setActionCommand("Generate database script");
+
+ jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Mapping Strategy: "));
+
+ groupStrategy.add(rbtOneTablePerClass);
+ rbtOneTablePerClass.setText("One Table per Class");
+
+ groupStrategy.add(rbtOneTablePerConcreteClass);
+ rbtOneTablePerConcreteClass.setText("One Table per Concrete Class");
+
+ groupStrategy.add(rbtOneTablePerKind);
+ rbtOneTablePerKind.setSelected(true);
+ rbtOneTablePerKind.setText("One Table per Kind");
+ rbtOneTablePerKind.addItemListener(
+ new java.awt.event.ItemListener() {
+ public void itemStateChanged(java.awt.event.ItemEvent evt) {
+ rbtOneTablePerKindItemStateChanged(evt);
+ }
+ });
+
+ javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
+ jPanel1.setLayout(jPanel1Layout);
+ jPanel1Layout.setHorizontalGroup(
+ jPanel1Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(
+ jPanel1Layout
+ .createSequentialGroup()
+ .addContainerGap()
+ .addGroup(
+ jPanel1Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(rbtOneTablePerClass)
+ .addComponent(rbtOneTablePerConcreteClass)
+ .addComponent(rbtOneTablePerKind))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
+ jPanel1Layout.setVerticalGroup(
+ jPanel1Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(
+ jPanel1Layout
+ .createSequentialGroup()
+ .addContainerGap()
+ .addComponent(
+ rbtOneTablePerClass,
+ javax.swing.GroupLayout.PREFERRED_SIZE,
+ 23,
+ javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(18, 18, 18)
+ .addComponent(
+ rbtOneTablePerConcreteClass,
+ javax.swing.GroupLayout.PREFERRED_SIZE,
+ 23,
+ javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(18, 18, 18)
+ .addComponent(rbtOneTablePerKind)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
+
+ jLabel3.setText("DBMS");
+
+ cbxDBMS.setModel(new DefaultComboBoxModel(DbmsSupported.values()));
+
+ cbxStandarizeNames.setSelected(true);
+ cbxStandarizeNames.setText("Standardize database names");
+
+ jLabel1.setText("eg.: 'BirthDate' to 'birth_date'");
+
+ cxbEnumToLookupTable.setSelected(true);
+ cxbEnumToLookupTable.setText("Enumeration field to lookup table");
+
+ cxbCreateIndex.setSelected(false);
+ cxbCreateIndex.setText("Create indexes");
+
+ javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
+ jPanel2.setLayout(jPanel2Layout);
+ jPanel2Layout.setHorizontalGroup(
+ jPanel2Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(
+ jPanel2Layout
+ .createSequentialGroup()
+ .addContainerGap()
+ .addGroup(
+ jPanel2Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(
+ jPanel1,
+ javax.swing.GroupLayout.PREFERRED_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(cxbGenerateSchema))
+ .addGap(18, 18, 18)
+ .addGroup(
+ jPanel2Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(
+ jPanel2Layout
+ .createSequentialGroup()
+ .addComponent(cbxDBMS, 0, 158, Short.MAX_VALUE)
+ .addGap(26, 26, 26))
+ .addComponent(
+ cxbEnumToLookupTable,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ 184,
+ Short.MAX_VALUE)
+ .addComponent(
+ cbxStandarizeNames,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ Short.MAX_VALUE)
+ .addComponent(
+ cxbCreateIndex,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ Short.MAX_VALUE)
+ .addGroup(
+ jPanel2Layout
+ .createSequentialGroup()
+ .addGroup(
+ jPanel2Layout
+ .createParallelGroup(
+ javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jLabel3)
+ .addGroup(
+ jPanel2Layout
+ .createSequentialGroup()
+ .addGap(21, 21, 21)
+ .addComponent(jLabel1)))
+ .addGap(0, 0, Short.MAX_VALUE)))
+ .addGap(18, 18, 18)));
+ jPanel2Layout.setVerticalGroup(
+ jPanel2Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(
+ jPanel2Layout
+ .createSequentialGroup()
+ .addContainerGap()
+ .addComponent(cxbGenerateSchema)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(
+ jPanel2Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(
+ jPanel2Layout
+ .createSequentialGroup()
+ .addComponent(jLabel3)
+ .addPreferredGap(
+ javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(
+ cbxDBMS,
+ javax.swing.GroupLayout.PREFERRED_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(
+ javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(cxbEnumToLookupTable)
+ .addPreferredGap(
+ javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(cbxStandarizeNames)
+ .addPreferredGap(
+ javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jLabel1)
+ .addPreferredGap(
+ javax.swing.LayoutStyle.ComponentPlacement.RELATED,
+ 5,
+ Short.MAX_VALUE)
+ .addComponent(cxbCreateIndex)
+ .addContainerGap())
+ .addComponent(
+ jPanel1,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ Short.MAX_VALUE))));
+
+ jTabbedPane1.addTab("Relational Schema", jPanel2);
+
+ jLabel2.setText("Base IRI:");
+
+ jtfBaseIRI.setText("http://example.com");
+
+ cxbGenerateObda.setSelected(true);
+ cxbGenerateObda.setText("Generate OBDA file");
+
+ javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
+ jPanel6.setLayout(jPanel6Layout);
+ jPanel6Layout.setHorizontalGroup(
+ jPanel6Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(
+ jPanel6Layout
+ .createSequentialGroup()
+ .addContainerGap()
+ .addGroup(
+ jPanel6Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(
+ jPanel6Layout
+ .createSequentialGroup()
+ .addComponent(cxbGenerateObda)
+ .addGap(0, 0, Short.MAX_VALUE))
+ .addGroup(
+ jPanel6Layout
+ .createSequentialGroup()
+ .addComponent(jLabel2)
+ .addPreferredGap(
+ javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(
+ jtfBaseIRI,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ 348,
+ Short.MAX_VALUE)))
+ .addContainerGap()));
+ jPanel6Layout.setVerticalGroup(
+ jPanel6Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(
+ javax.swing.GroupLayout.Alignment.TRAILING,
+ jPanel6Layout
+ .createSequentialGroup()
+ .addContainerGap()
+ .addComponent(cxbGenerateObda)
+ .addGap(18, 18, 18)
+ .addGroup(
+ jPanel6Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel2)
+ .addComponent(
+ jtfBaseIRI,
+ javax.swing.GroupLayout.PREFERRED_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addContainerGap(118, Short.MAX_VALUE)));
+
+ jTabbedPane1.addTab("OBDA", jPanel6);
+
+ jLabel4.setText("Host :");
+
+ jLabel5.setText("Database :");
+ jLabel5.setToolTipText("");
+
+ jLabel6.setText("User :");
+
+ jLabel7.setText("Passoword :");
+
+ cxbGenerateConnection.setSelected(true);
+ cxbGenerateConnection.setText("Generate the connection");
+
+ javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
+ jPanel5.setLayout(jPanel5Layout);
+ jPanel5Layout.setHorizontalGroup(
+ jPanel5Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(
+ jPanel5Layout
+ .createSequentialGroup()
+ .addContainerGap()
+ .addGroup(
+ jPanel5Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(
+ jPanel5Layout
+ .createSequentialGroup()
+ .addGroup(
+ jPanel5Layout
+ .createParallelGroup(
+ javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jLabel7)
+ .addComponent(jLabel6))
+ .addPreferredGap(
+ javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(
+ jPanel5Layout
+ .createParallelGroup(
+ javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jtfUser)
+ .addComponent(jtfPassword)))
+ .addGroup(
+ jPanel5Layout
+ .createSequentialGroup()
+ .addComponent(jLabel4)
+ .addGap(34, 34, 34)
+ .addComponent(jtfHost))
+ .addGroup(
+ jPanel5Layout
+ .createSequentialGroup()
+ .addComponent(cxbGenerateConnection)
+ .addGap(0, 0, Short.MAX_VALUE))
+ .addGroup(
+ jPanel5Layout
+ .createSequentialGroup()
+ .addComponent(jLabel5)
+ .addPreferredGap(
+ javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(jtfDatabase)))
+ .addContainerGap()));
+ jPanel5Layout.setVerticalGroup(
+ jPanel5Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(
+ jPanel5Layout
+ .createSequentialGroup()
+ .addContainerGap()
+ .addComponent(cxbGenerateConnection)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(
+ jPanel5Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel4)
+ .addComponent(
+ jtfHost,
+ javax.swing.GroupLayout.PREFERRED_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(
+ jPanel5Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel5)
+ .addComponent(
+ jtfDatabase,
+ javax.swing.GroupLayout.PREFERRED_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(
+ jPanel5Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel6)
+ .addComponent(
+ jtfUser,
+ javax.swing.GroupLayout.PREFERRED_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(
+ jPanel5Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel7)
+ .addComponent(
+ jtfPassword,
+ javax.swing.GroupLayout.PREFERRED_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
+
+ jTabbedPane1.addTab("Conection", jPanel5);
+
+ jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
+
+ jbtnCancel.setText("Cancel");
+ jbtnCancel.setMaximumSize(new java.awt.Dimension(135, 29));
+ jbtnCancel.setMinimumSize(new java.awt.Dimension(135, 29));
+ jbtnCancel.setPreferredSize(new java.awt.Dimension(135, 29));
+
+ jbtnOk.setText("Do Mapping");
+ jbtnOk.setMaximumSize(new java.awt.Dimension(135, 29));
+ jbtnOk.setMinimumSize(new java.awt.Dimension(135, 29));
+ jbtnOk.setPreferredSize(new java.awt.Dimension(135, 29));
+
+ javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
+ jPanel4.setLayout(jPanel4Layout);
+ jPanel4Layout.setHorizontalGroup(
+ jPanel4Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(
+ javax.swing.GroupLayout.Alignment.TRAILING,
+ jPanel4Layout
+ .createSequentialGroup()
+ .addGap(36, 36, 36)
+ .addComponent(
+ jbtnOk,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ Short.MAX_VALUE)
+ .addGap(61, 61, 61)
+ .addComponent(
+ jbtnCancel,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ Short.MAX_VALUE)
+ .addGap(57, 57, 57)));
+ jPanel4Layout.setVerticalGroup(
+ jPanel4Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(
+ jPanel4Layout
+ .createSequentialGroup()
+ .addContainerGap()
+ .addGroup(
+ jPanel4Layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(
+ jbtnCancel,
+ javax.swing.GroupLayout.PREFERRED_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(
+ jbtnOk,
+ javax.swing.GroupLayout.PREFERRED_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(
+ layout
+ .createSequentialGroup()
+ .addContainerGap()
+ .addGroup(
+ layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jTabbedPane1)
+ .addComponent(
+ jPanel4,
+ javax.swing.GroupLayout.Alignment.TRAILING,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ Short.MAX_VALUE))
+ .addContainerGap()));
+ layout.setVerticalGroup(
+ layout
+ .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(
+ layout
+ .createSequentialGroup()
+ .addContainerGap()
+ .addComponent(jTabbedPane1)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(
+ jPanel4,
+ javax.swing.GroupLayout.PREFERRED_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap()));
+ }
+
+ private void rbtOneTablePerKindItemStateChanged(java.awt.event.ItemEvent evt) {
+ if (rbtOneTablePerKind.isSelected()) {
+ cxbCreateIndex.setEnabled(true);
+ cxbCreateIndex.setSelected(true);
+ } else {
+ cxbCreateIndex.setSelected(false);
+ cxbCreateIndex.setEnabled(false);
+ }
+ }
+
+ /**
+ * Updates components with project configurations' information.
+ *
+ * @param configurations
+ */
+ private void setComponentsValues(ProjectConfigurations configurations) {
+ cxbGenerateSchema.setSelected(configurations.isGenerateSchema());
+ cxbGenerateObda.setSelected(configurations.isGenerateObda());
+ cxbGenerateConnection.setSelected(configurations.isGenerateConnection());
+
+ if (configurations.getMappingStrategy() != null) {
+ if (configurations.getMappingStrategy() == MappingStrategy.ONE_TABLE_PER_CLASS)
+ rbtOneTablePerClass.setSelected(true);
+ else if (configurations.getMappingStrategy() == MappingStrategy.ONE_TABLE_PER_CONCRETE_CLASS)
+ rbtOneTablePerConcreteClass.setSelected(true);
+ else rbtOneTablePerKind.setSelected(true);
+ }
+
+ cbxDBMS.setSelectedItem(configurations.getTargetDBMS());
+ cbxStandarizeNames.setSelected(configurations.isStandardizeNames());
+ jtfBaseIRI.setText(configurations.getExportGUFOIRI());
+ cxbCreateIndex.setSelected(configurations.isGenerateIndex());
+ jtfHost.setText(configurations.getHostNameConnection());
+ jtfDatabase.setText(configurations.getDatabaseNameConnection());
+ jtfUser.setText(configurations.getUserNameConnection());
+ jtfPassword.setText(configurations.getPassword());
+ cxbEnumToLookupTable.setSelected(configurations.isEnumFieldToLookupTable());
+ }
+
+ /** Updates project configurations with components' information. */
+ public void updateConfigurationsValues(ProjectConfigurations configurations) {
+ configurations.setGenerateSchema(cxbGenerateSchema.isSelected());
+ configurations.setGenerateObda(cxbGenerateObda.isSelected());
+ configurations.setGenerateConnection(cxbGenerateConnection.isSelected());
+
+ if (rbtOneTablePerClass.isSelected())
+ configurations.setMappingStrategy(MappingStrategy.ONE_TABLE_PER_CLASS);
+ else if (rbtOneTablePerConcreteClass.isSelected())
+ configurations.setMappingStrategy(MappingStrategy.ONE_TABLE_PER_CONCRETE_CLASS);
+ else configurations.setMappingStrategy(MappingStrategy.ONE_TABLE_PER_KIND);
+
+ configurations.setTargetDBMS((DbmsSupported) cbxDBMS.getSelectedItem());
+ configurations.setStandardizeNames(cbxStandarizeNames.isSelected());
+ configurations.setExportGUFOIRI(jtfBaseIRI.getText().trim());
+ configurations.setGenerateIndexes(cxbCreateIndex.isSelected());
+ configurations.setHostNameConnection(jtfHost.getText().trim());
+ configurations.setDatabaseNameConnection(jtfDatabase.getText().trim());
+ configurations.setUserNameConnection(jtfUser.getText().trim());
+ configurations.setPassword(jtfPassword.getText().trim());
+ configurations.setEnumFieldToLookupTable(cxbEnumToLookupTable.isSelected());
+ }
+
+ public void onExport(ActionListener onExportAction) {
+ ActionListener[] currentListeners = jbtnOk.getActionListeners();
+
+ for (int i = 0; currentListeners != null && i < currentListeners.length; i++) {
+ jbtnOk.removeActionListener(currentListeners[i]);
+ }
+
+ jbtnOk.addActionListener(onExportAction);
+ }
+
+ public void onCancel(ActionListener onCancelAction) {
+ ActionListener[] currentListeners = jbtnCancel.getActionListeners();
+
+ for (int i = 0; currentListeners != null && i < currentListeners.length; i++) {
+ jbtnCancel.removeActionListener(currentListeners[i]);
+ }
+
+ jbtnCancel.addActionListener(onCancelAction);
+ }
+
+ public boolean checkValidParamters() {
+ if ((DbmsSupported) cbxDBMS.getSelectedItem() == DbmsSupported.GENERIC_SCHEMA
+ && !cxbEnumToLookupTable.isSelected()) {
+ JOptionPane.showMessageDialog(
+ this,
+ "You can not create an enumeration field to a generic database.",
+ "Error",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+
+ if (!cxbGenerateSchema.isSelected()
+ && !cxbGenerateObda.isSelected()
+ && !cxbGenerateConnection.isSelected()) {
+ JOptionPane.showMessageDialog(
+ this,
+ "You must select at least one file to be generated (schema, OBDA or connection).",
+ "Error",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/src/main/resources/icons/toolbar/export_ontop.png b/src/main/resources/icons/toolbar/export_ontop.png
new file mode 100644
index 00000000..c09854e0
Binary files /dev/null and b/src/main/resources/icons/toolbar/export_ontop.png differ
diff --git a/src/main/resources/icons/toolbar/export_ontop32.ico b/src/main/resources/icons/toolbar/export_ontop32.ico
new file mode 100644
index 00000000..892273f1
Binary files /dev/null and b/src/main/resources/icons/toolbar/export_ontop32.ico differ
diff --git a/src/main/resources/icons/toolbar/export_schema.png b/src/main/resources/icons/toolbar/export_schema.png
new file mode 100644
index 00000000..e6dfb7d7
Binary files /dev/null and b/src/main/resources/icons/toolbar/export_schema.png differ
diff --git a/src/main/resources/icons/toolbar/export_schema32.ico b/src/main/resources/icons/toolbar/export_schema32.ico
new file mode 100644
index 00000000..283454cd
Binary files /dev/null and b/src/main/resources/icons/toolbar/export_schema32.ico differ
diff --git a/src/main/resources/plugin.xml b/src/main/resources/plugin.xml
index 3d062c8d..a3a8ffff 100644
--- a/src/main/resources/plugin.xml
+++ b/src/main/resources/plugin.xml
@@ -1,6 +1,6 @@
@@ -124,6 +124,30 @@
ribbonPath="Project/Export/#">
+
+
+
+
+
+
+
+
@@ -164,6 +188,7 @@
- -->