Skip to content

Commit

Permalink
[TOOLS-4680] Oracle PL/SQL Procedure - Object Mapping Page (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
Srltas authored Dec 18, 2024
1 parent 7e2f6c2 commit a6e9946
Show file tree
Hide file tree
Showing 15 changed files with 1,283 additions and 39 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Copyright (C) 2016 CUBRID Corporation.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* - Neither the name of the <ORGANIZATION> nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
*/
package com.cubrid.cubridmigration.core.engine.config;

/**
* SourceFunctionConfig Description
*
* @author Dongmin Kim
*/
public class SourcePlcsqlFunctionConfig extends SourceConfig {
private final String owner;
private final String targetOwner;
private final String authid;
private final boolean authidChanged;

private final String sourceDDL;
private final String headerDDL;
private final String bodyDDL;
private final String functionDDL;

public SourcePlcsqlFunctionConfig(
String owner,
String targetOwner,
String name,
String targetName,
String authid,
boolean authidChanged,
String sourceDDL,
String headerDDL,
String bodyDDL,
String functionDDL) {
this.owner = owner;
this.targetOwner = targetOwner;
this.setName(name);
this.setTarget(targetName);
this.authid = authid;
this.authidChanged = authidChanged;
this.sourceDDL = sourceDDL;
this.headerDDL = headerDDL;
this.bodyDDL = bodyDDL;
this.functionDDL = functionDDL;
}

public String getOwner() {
return owner;
}

public String getTargetOwner() {
return targetOwner;
}

public String getAuthid() {
return authid;
}

public boolean isAuthidChanged() {
return authidChanged;
}

public String getSourceDDL() {
return sourceDDL;
}

public String getHeaderDDL() {
return headerDDL;
}

public String getBodyDDL() {
return bodyDDL;
}

public String getFunctionDDL() {
return functionDDL;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Copyright (C) 2016 CUBRID Corporation.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* - Neither the name of the <ORGANIZATION> nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
*/
package com.cubrid.cubridmigration.core.engine.config;

/**
* SourceProcedureConfig Description
*
* @author Dongmin Kim
*/
public class SourcePlcsqlProcedureConfig extends SourceConfig {
private final String owner;
private final String targetOwner;
private final String authid;
private final boolean isAuthidChanged;

private final String sourceDDL;
private final String headerDDL;
private final String bodyDDL;
private final String procedureDDL;

public SourcePlcsqlProcedureConfig(
String owner,
String targetOwner,
String name,
String targetName,
String authid,
boolean isAuthidChanged,
String sourceDDL,
String headerDDL,
String bodyDDL,
String procedureDDL) {
this.owner = owner;
this.targetOwner = targetOwner;
this.setName(name);
this.setTarget(targetName);
this.authid = authid;
this.isAuthidChanged = isAuthidChanged;
this.sourceDDL = sourceDDL;
this.headerDDL = headerDDL;
this.bodyDDL = bodyDDL;
this.procedureDDL = procedureDDL;
}

public String getOwner() {
return owner;
}

public String getTargetOwner() {
return targetOwner;
}

public String getAuthid() {
return authid;
}

public boolean isAuthidChagned() {
return isAuthidChanged;
}

public String getSourceDDL() {
return sourceDDL;
}

public String getHeaderDDL() {
return headerDDL;
}

public String getBodyDDL() {
return bodyDDL;
}

public String getProcedureDDL() {
return procedureDDL;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
import com.cubrid.cubridmigration.ui.common.navigator.node.SchemaNode;
import com.cubrid.cubridmigration.ui.common.navigator.node.SequenceNode;
import com.cubrid.cubridmigration.ui.common.navigator.node.SequencesNode;
import com.cubrid.cubridmigration.ui.common.navigator.node.StoredProceduresNode;
import com.cubrid.cubridmigration.ui.common.navigator.node.SynonymNode;
import com.cubrid.cubridmigration.ui.common.navigator.node.SynonymsNode;
import com.cubrid.cubridmigration.ui.common.navigator.node.TableNode;
Expand Down Expand Up @@ -99,6 +98,8 @@ public final class CubridNodeManager {
private static final String PATH_TABLES = "/tables";
private static final String PATH_SYNONYMS = "/synonyms";
private static final String PATH_GRANTS = "/grants";
private static final String PATH_PROCEDURE = "/procedures";
private static final String PATH_FUNCTION = "/functions";
private static final String XML_HOST_NODE_ID = "MySQL dump file";

private static volatile CubridNodeManager instance = null;
Expand Down Expand Up @@ -235,48 +236,54 @@ private void addSynonymNodes(DefaultCUBRIDNode parentNode, Schema schema) {
}

/**
* add store procedure and function nodes
* add procedure nodes
*
* @param parentNode parentNode
* @param schema Schema
* @param parentNode
* @param schema
*/
private void addSPFuncNodes(DefaultCUBRIDNode parentNode, Schema schema) {

private void addProcedureNodes(DefaultCUBRIDNode parentNode, Schema schema) {
String parentID = parentNode.getId();

String spID = parentID + PATH_STORED_PROCEDURE;
String spLabels = "Stored Procedure";
StoredProceduresNode spNode = new StoredProceduresNode(spID, spLabels);
parentNode.addChild(spNode);

// add Procedures
List<Procedure> procedures = schema.getProcedures();
String proceduresID = parentID + "/procedures";
String proceduresLabels = Messages.labelTreeObjProcedure + "(" + procedures.size() + ")";
ProceduresNode proceduresNode = new ProceduresNode(proceduresID, proceduresLabels);
spNode.addChild(proceduresNode);

for (Procedure procedure : procedures) {
// add a procedure
List<Procedure> procedureList = new ArrayList<>();
procedureList.addAll(schema.getPlcsqlProcedures());
String proceduresID = parentID + PATH_PROCEDURE;
String procedureLabels = Messages.labelTreeObjProcedure + "(" + procedureList.size() + ")";
ProceduresNode proceduresNode = new ProceduresNode(proceduresID, procedureLabels);
parentNode.addChild(proceduresNode);
if (procedureList.isEmpty()) {
proceduresNode.setContainer(false);
}
for (Procedure procedure : procedureList) {
String procedureID = proceduresID + "/" + procedure.getName();
String procedureLabels = procedure.getName();
ProcedureNode procedureNode = new ProcedureNode(procedureID, procedureLabels);
String procedureLabel = procedure.getName();
ProcedureNode procedureNode = new ProcedureNode(procedureID, procedureLabel);
procedureNode.setProcedure(procedure);
proceduresNode.addChild(procedureNode);
}
}

// add Functions
List<Function> functions = schema.getFunctions();
String functionsID = parentID + "/functions";
String functionsLabels = Messages.labelTreeObjFunction + "(" + functions.size() + ")";
FunctionsNode functionsNode = new FunctionsNode(functionsID, functionsLabels);
spNode.addChild(functionsNode);
/**
* add function nodes
*
* @param parentNode
* @param schema
*/
private void addFunctionNodes(DefaultCUBRIDNode parentNode, Schema schema) {
String parentID = parentNode.getId();

for (Function function : functions) {
// add a function
List<Function> functionList = new ArrayList<>();
functionList.addAll(schema.getPlcsqlFunctions());
String functionsID = parentID + PATH_FUNCTION;
String functionsLabels = Messages.labelTreeObjFunction + "(" + functionList.size() + ")";
FunctionsNode functionsNode = new FunctionsNode(functionsID, functionsLabels);
parentNode.addChild(functionsNode);
if (functionList.isEmpty()) {
functionsNode.setContainer(false);
}
for (Function function : functionList) {
String functionID = functionsID + "/" + function.getName();
String functionLabels = function.getName();
FunctionNode functionNode = new FunctionNode(functionID, functionLabels);
String functionLabel = function.getName();
FunctionNode functionNode = new FunctionNode(functionID, functionLabel);
functionNode.setFunction(function);
functionsNode.addChild(functionNode);
}
Expand Down Expand Up @@ -478,15 +485,17 @@ public DatabaseNode createDbNode(Catalog catalog, String hostNodeID) {

addViewNodes(parentNode, schema);

addSPFuncNodes(parentNode, schema);

addTriggerNodes(parentNode, schema);

addSerialNodes(parentNode, schema);

addSynonymNodes(parentNode, schema);

addGrantNodes(parentNode, schema);

addProcedureNodes(parentNode, schema);

addFunctionNodes(parentNode, schema);
}

return databaseNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void setFunction(Function function) {
* @param label String
*/
public FunctionNode(String id, String label) {
super(id, label, "");
super(id, label, "icon/db/procedure_func_item.png");
setType(CubridNodeType.USER_FUNCTION);
setContainer(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class FunctionsNode extends DefaultCUBRIDNode {
* @param label String
*/
public FunctionsNode(String id, String label) {
super(id, label, "");
super(id, label, "icon/db/procedure_func_item.png");
setType(CubridNodeType.FUNCTION_FOLDER);
setContainer(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void setProcedure(Procedure procedure) {
* @param label String
*/
public ProcedureNode(String id, String label) {
super(id, label, "");
super(id, label, "icon/db/procedure_sp_item.png");
setType(CubridNodeType.USER_PROCEDURE);
setContainer(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class ProceduresNode extends DefaultCUBRIDNode {
* @param label String
*/
public ProceduresNode(String id, String label) {
super(id, label, "");
super(id, label, "icon/db/procedure_sp_item.png");
setType(CubridNodeType.PROCEDURE_FOLDER);
setContainer(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,9 @@ public class Messages extends NLS {
public static String objectMapPageTabFolderBtnVerify2;
public static String objectMapPageTabFolderErrTableName;
public static String objectMapPageTabFolderErrViewName;
public static String objectMapPageTabFolderFunctions;
public static String objectMapPageTabFolderGrants;
public static String objectMapPageTabFolderProcedures;
public static String objectMapPageTabFolderSequences;
public static String objectMapPageTabFolderSqls;
public static String objectMapPageTabFolderSynonyms;
Expand Down Expand Up @@ -735,6 +737,7 @@ public class Messages extends NLS {
public static String sqlServer2CUBRID;
public static String startButtonText;
public static String tabCharColumns;
public static String tabTitleAuthId;
public static String tabTitleColumn;
public static String tabTitleCondition;
public static String tabTitleConditionDes;
Expand All @@ -743,6 +746,7 @@ public class Messages extends NLS {
public static String tabTitleDataSQLDes;
public static String tabTitleDataType;
public static String tabTitleFK;
public static String tabTitleFunction;
public static String tabTitleGrantAuthType;
public static String tabTitleGeneral;
public static String tabTitleIndexes;
Expand All @@ -752,6 +756,7 @@ public class Messages extends NLS {
public static String tabTitlePartitions;
public static String tabTitlePK;
public static String tabTitlePKDes;
public static String tabTitleProcedure;
public static String tabTitleSourceColumn;
public static String tabTitleSourceFK;
public static String tabTitleSourceGrant;
Expand Down
Loading

0 comments on commit a6e9946

Please sign in to comment.