diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..88d886429d072e920a1523850aa199f85ddce594 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,56 @@ +stages: + - build + - package + - deploy + +variables: + # Maven + MAVEN_OPTS: -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true + # MAVEN_CONFIG: --batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true -s .mvn/settings.xml + MAVEN_CONFIG: --batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -s .mvn/settings.xml + MAVEN_USER_HOME: .mvn/ + +before_script: + - echo _auth=$(echo -n $ARTIFACTS_REPO_USERNAME:$ARTIFACTS_REPO_PASSWORD | base64) >> .npmrc + + + +Build with Maven: + stage: build + tags: + - alicloud + except: + variables: + - $CI_COMMIT_MESSAGE =~ /^Helm debug:\ .*/ + cache: + paths: + - .mvn/wrapper/maven-wrapper.jar + - .mvn/wrapper/dists/ + - .mvn/repository/ + image: openjdk:8-stretch + script: + - chmod a+x ./mvnw + - ./mvnw -DskipTests=true clean install +# artifacts: +# paths: +# - caf-boot-parent/target/app.jar +# expire_in: 10d + +Package: + stage: package + tags: + - alicloud + only: + - master + - dev + - tags + - F_release + cache: + paths: + - .mvn/wrapper/maven-wrapper.jar + - .mvn/wrapper/dists/ + - .mvn/repository/ + image: openjdk:8-stretch + script: + - chmod a+x ./mvnw + - ./mvnw -DskipTests=true clean deploy \ No newline at end of file diff --git a/.mvn/settings.xml b/.mvn/settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..1d3993e8903a1d3c2c1968edbde06cf92e76e3e0 --- /dev/null +++ b/.mvn/settings.xml @@ -0,0 +1,75 @@ + + + + .mvn/repository + + + caf-repo + ${env.ARTIFACTS_REPO_USERNAME} + ${env.ARTIFACTS_REPO_PASSWORD} + + + caf-releases-repo + ${env.ARTIFACTS_REPO_USERNAME} + ${env.ARTIFACTS_REPO_PASSWORD} + + + caf-snapshots-repo + ${env.ARTIFACTS_REPO_USERNAME} + ${env.ARTIFACTS_REPO_PASSWORD} + + + + + caf-repo + caf-rep + https://repos.iec.io/repository/maven-caf/ + + + caf-snapshots-repo + caf-rep + caf-snapshots-repo + https://repos.iec.io/repository/maven-caf-snapshots/ + + + caf-releases-repo + caf-rep + caf-releases-repo + https://repos.iec.io/repository/maven-caf-releases/ + + + + + repos.iec.io-caf + + + caf-rep + https://repos.iec.io/repository/maven-caf/ + + true + + + true + always + + + + + + + + repos.iec.io-caf + + diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000000000000000000000000000000000000..424c252798433bf6dac99271b0bab22a89bb8216 --- /dev/null +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,111 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = + // "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; + "https://repo1.maven.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if (mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if (mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: : " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if (!outputFile.getParentFile().exists()) { + if (!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000000000000000000000000000000000000..eba07f5896b3df02fe5a7426f590df7dc715b26c --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,15 @@ +# +# Copyright ? OpenAtom Foundation. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip +distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip diff --git a/caf-database-object-api/pom.xml b/caf-database-object-api/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..4a90cefa8a7013e6e1cabdf38b5f598c1213cf25 --- /dev/null +++ b/caf-database-object-api/pom.xml @@ -0,0 +1,71 @@ + + + + + + caf-database-object + io.iec.edp + 0.2.10 + + 4.0.0 + + caf-database-object-api + jar + + + io.iec.edp + caf-dimension-api + 0.1.10 + + + javax.persistence + javax.persistence-api + 2.2 + + + jakarta.ws.rs + jakarta.ws.rs-api + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-annotations + + + io.iec.edp + caf-commons-runtime + 1.0.0-rc.1 + provided + + + io.iec.edp + caf-data-jdbc + 1.0.0-rc.1 + provided + + + commons-io + commons-io + 2.6 + compile + + + + diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/BaseConfig.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/BaseConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..85061eaaf1e3658cc1ad14ff9d1cbcfd0f8b37a0 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/BaseConfig.java @@ -0,0 +1,32 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.configuration; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 基类 + * + * @author zhaoleitr + */ +@Data +public class BaseConfig implements Serializable { + /** + * 名称 + */ + private String name; +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/DatabaseObjectConfiguration.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/DatabaseObjectConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..d3f73f3d3e853297ac51ad945bc61e44abc66eae --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/DatabaseObjectConfiguration.java @@ -0,0 +1,69 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.configuration; + + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +/** + * 数据库对象全局配置文件对应的实体类 + * + * @author liu_wei + */ +public class DatabaseObjectConfiguration implements Serializable { + /** + * 数据库类型编号 + */ + @JsonProperty("DBTypeCode") + private String DBTypeCode; + + public final String getDBTypeCode() { + return DBTypeCode; + } + + public final void setDBTypeCode(String value) { + DBTypeCode = value; + } + + /** + * 数据库类型名称 + */ + @JsonProperty("DBTypeName") + private String DBTypeName; + + public final String getDBTypeName() { + return DBTypeName; + } + + public final void setDBTypeName(String value) { + DBTypeName = value; + } + + /** + * 数据库对象SQL反射器 + */ + @JsonProperty("SQLReflector") + private SQLReflector SQLReflector; + + public final SQLReflector getSQLReflector() { + return SQLReflector; + } + + public final void setSQLReflector(SQLReflector value) { + SQLReflector = value; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/DatabaseObjectConfigurationLoader.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/DatabaseObjectConfigurationLoader.java new file mode 100644 index 0000000000000000000000000000000000000000..64156808e051f54f8a7df13ec6c8083120a6480f --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/DatabaseObjectConfigurationLoader.java @@ -0,0 +1,96 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.configuration; + +import io.iec.edp.caf.databaseobject.api.configuration.DatabaseObjectConfiguration; +import io.iec.edp.caf.databaseobject.api.configuration.funcmapping.DatabaseFuncConfiguration; +import io.iec.edp.caf.databaseobject.api.helper.DboConfigurationHelper; + +import java.io.IOException; +import java.io.Serializable; +import java.util.ArrayList; + +/** + * 配置加载器 + * + * @author liu_wei + */ +public class DatabaseObjectConfigurationLoader implements Serializable { + private static String fileName = FileUtils.getSqlConfigPath(); + private static String sectionName = "DatabaseObjectSQLConfiguration"; + + private static ArrayList DatabaseObjectConfigurations; + + private static ArrayList getDatabaseObjectConfigurations() { + return DatabaseObjectConfigurations; + } + + private static void setDatabaseObjectConfigurations(ArrayList value) { + DatabaseObjectConfigurations = value; + } + + + /** + * 构造函数 + */ + public DatabaseObjectConfigurationLoader() { + GetDatabaseObjectConfigurations(); + //GSPConfigurationSource.Current.AddSectionChangeHandler(MetadataServiceConfigSetting.fileName, MetadataServiceConfigSetting.SectionName, ConfigurationChanged); + } + + + /** + * 获取配置文件数据 + * + * @return 配置列表 + */ + private static ArrayList GetDatabaseObjectConfigurations() { + if (getDatabaseObjectConfigurations() == null || getDatabaseObjectConfigurations().size() <= 0) { + DboConfigurationHelper helper = new DboConfigurationHelper(); + ArrayList confs = null; + + try { + confs = helper.getSqlReflectConfiguration(fileName, sectionName); + } catch (IOException e) { + throw new RuntimeException("获取数据库对象配置信息报错", e); + } + + setDatabaseObjectConfigurations(confs); + return getDatabaseObjectConfigurations(); + } else { + return getDatabaseObjectConfigurations(); + } + } + + /** + * 获取数据库对象配置信息 + * + * @param typeName 类型名称 + * @return 配置 + */ + protected final DatabaseObjectConfiguration GetDatabaseObjectConfigurationData(String typeName) { + GetDatabaseObjectConfigurations(); + if (getDatabaseObjectConfigurations() != null && !getDatabaseObjectConfigurations().isEmpty()) { + for (DatabaseObjectConfiguration data : getDatabaseObjectConfigurations()) { + if (data.getDBTypeCode().toLowerCase().equals(typeName.toLowerCase())) { + return data; + } + } + return null; + } else { + return null; + } + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/FileUtils.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/FileUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..5c435a66d0d1b646f676f1921988f42a8a81bfc5 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/FileUtils.java @@ -0,0 +1,108 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.configuration; + +import io.iec.edp.caf.commons.runtime.CafEnvironment; +import org.springframework.boot.configurationprocessor.json.JSONObject; + +import java.io.*; +import java.nio.file.Paths; + +/** + * 文件操作集 + * + * @author liu_wei + */ +public class FileUtils { + + private static final String CAF_DBO_TABLE_CONFIG = "config/platform/common/caf_dbo_tablename.json"; + private static final String CAF_DBO_SLQ_CONFIG = "config/platform/common/caf_dbosqlextend.json"; + + private static String tableConfigPath; + + public static String getTableConfigPath() { + if (tableConfigPath == null) { + tableConfigPath = Paths.get(CafEnvironment.getServerRTPath(), "config/platform/common/caf_dbo_tablename.json").toString(); + } + return tableConfigPath; + } + + private static String sqlConfigPath; + + public static String getSqlConfigPath() { + if (sqlConfigPath == null) { + sqlConfigPath = Paths.get(CafEnvironment.getServerRTPath(), "config/platform/common/caf_dbosqlextend.json").toString(); + } + return sqlConfigPath; + } + + public static String fileRead(String path) throws IOException { + String encoding = "UTF-8"; + File file = new File(path); + Long filelength = file.length(); + byte[] filecontent = new byte[filelength.intValue()]; + + FileInputStream in = new FileInputStream(file); + in.read(filecontent); + in.close(); + + //判断有没有utf-8 bom头。有则去除。 + String fileContents = new String(filecontent, encoding); + if (fileContents.startsWith("\ufeff")) { + + fileContents = fileContents.substring(1); + + } + return fileContents; + } + + public static boolean isExportOpen() { + String configPath = getSqlConfigPath(); + File file = new File(configPath); + String exportOpen = ""; + try { + String content = org.apache.commons.io.FileUtils.readFileToString(file, "UTF-8"); + JSONObject jsonObject = new JSONObject(content); + exportOpen = (jsonObject.getString("isExportOpen").toLowerCase()); + } catch (Exception e) { + exportOpen = "false"; + } + return ("true").equals(exportOpen); + } + + private static String reservedWordOpen; + + public static boolean getReservedWordOpen() + { + if(reservedWordOpen == null) + { + String configPath = getSqlConfigPath(); + File file = new File(configPath); + try { + String content = org.apache.commons.io.FileUtils.readFileToString(file, "UTF-8"); + JSONObject jsonObject = new JSONObject(content); + if(jsonObject.isNull("isReservedWordOpen")) + { + reservedWordOpen = "true"; + } + reservedWordOpen = (jsonObject.getString("isReservedWordOpen").toLowerCase()); + } catch (Exception e) { + reservedWordOpen = "true"; + } + } + return ("true").equals(reservedWordOpen); + } + +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/ObjectNameMaxLengthConfiguration.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/ObjectNameMaxLengthConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..c874813d38a4d3c67d68d426a93fcb123d77b9af --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/ObjectNameMaxLengthConfiguration.java @@ -0,0 +1,50 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.configuration; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author zhaoleitr + */ +@Data +public class ObjectNameMaxLengthConfiguration implements Serializable { + /** + * 表名最大长度 + */ + private int tableNameMaxLength; + + /** + * 字段名最大长度 + */ + private int columnNameMaxLength; + + /** + * 主键名最大长度 + */ + private int pkNameMaxLength; + + /** + * 索引名最大长度 + */ + private int indexNameMaxLength; + + /** + * 约束名最大长度 + */ + private int constraintNameMaxLength; +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/ObjectNameMaxLengthLoader.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/ObjectNameMaxLengthLoader.java new file mode 100644 index 0000000000000000000000000000000000000000..51f093da52ea064c51a71050b63aa6a953412bda --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/ObjectNameMaxLengthLoader.java @@ -0,0 +1,69 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.configuration; + +import io.iec.edp.caf.databaseobject.api.helper.DboConfigurationHelper; + +import java.io.IOException; + +/** + * 对象名称最大长度加载器 + * + * @author liu_wei + */ +public class ObjectNameMaxLengthLoader { + private static String fileName = FileUtils.getSqlConfigPath(); + private static String sectionName = "ObjectNameMaxLength"; + + private static ObjectNameMaxLengthConfiguration databaseObjectConfiguration; + + public static ObjectNameMaxLengthConfiguration getDatabaseObjectConfiguration() { + return databaseObjectConfiguration; + } + + public static void setDatabaseObjectConfiguration(ObjectNameMaxLengthConfiguration value) { + databaseObjectConfiguration = value; + } + + + /** + * 构造函数 + * + * @throws IOException 异常 + */ + public ObjectNameMaxLengthLoader() throws IOException { + GetDatabaseObjectConfiguration(); + } + + + /** + * 获取配置文件数据 + * + * @return 最大名称长度 + * @throws IOException 异常 + */ + public static ObjectNameMaxLengthConfiguration GetDatabaseObjectConfiguration() throws IOException { + if (getDatabaseObjectConfiguration() == null) { + DboConfigurationHelper helper = new DboConfigurationHelper(); + ObjectNameMaxLengthConfiguration conf = null; + + conf = helper.getObjectNameMaxLengthConfiguration(fileName, sectionName); + setDatabaseObjectConfiguration(conf); + return getDatabaseObjectConfiguration(); + } else { + return getDatabaseObjectConfiguration(); + } + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/SQLReflector.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/SQLReflector.java new file mode 100644 index 0000000000000000000000000000000000000000..00888922ddcb27967802f638c57d784cc561c4a5 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/SQLReflector.java @@ -0,0 +1,26 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.configuration; + +import java.io.Serializable; + +/** + * SQL反射加载器 + * + * @author liu_wei + */ +public class SQLReflector extends BaseConfig implements Serializable { + +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/TableNameConfiguration.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/TableNameConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..e859abe04f994abc05c566a1a24f44929ec2772a --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/TableNameConfiguration.java @@ -0,0 +1,34 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.configuration; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * 对象名称规则扩展实现配置 + * + * @author zhaoleitr + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class TableNameConfiguration extends BaseConfig implements Serializable { + /** + * 规则编号 + */ + private String ruleCode; +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/TableNameConfigurationLoader.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/TableNameConfigurationLoader.java new file mode 100644 index 0000000000000000000000000000000000000000..a887cb373855923c17c2dc9d565db7d175954b64 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/TableNameConfigurationLoader.java @@ -0,0 +1,88 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.configuration; + + +import io.iec.edp.caf.databaseobject.api.helper.DboConfigurationHelper; + +import java.io.*; +import java.util.List; + +/** + * 配置文件加载 + * + * @author liu_wei + */ +public class TableNameConfigurationLoader implements Serializable { + private static String fileName = FileUtils.getTableConfigPath(); + private static String sectionName = "TableNameConfiguration"; + + private static List DatabaseObjectConfigurations; + + private static List getDatabaseObjectConfigurations() { + return DatabaseObjectConfigurations; + } + + private static void setDatabaseObjectConfigurations(List value) { + DatabaseObjectConfigurations = value; + } + + + /** + * 构造函数 + * + * @throws IOException 异常 + */ + public TableNameConfigurationLoader() throws IOException { + GetDatabaseObjectConfigurations(); + } + + /** + * 获取配置文件数据 + */ + private static List GetDatabaseObjectConfigurations() throws IOException { + if (getDatabaseObjectConfigurations() == null || getDatabaseObjectConfigurations().size() <= 0) { + DboConfigurationHelper helper = new DboConfigurationHelper(); + List configuration = helper.getTableNameConfigurations(fileName, sectionName); + setDatabaseObjectConfigurations(configuration); + + return getDatabaseObjectConfigurations(); + } else { + return getDatabaseObjectConfigurations(); + } + } + + + /** + * 获取数据库对象配置信息 + * + * @param ruleCode 规则编号 + * @return 表名配置 + */ + protected final TableNameConfiguration GetDatabaseObjectConfigurationData(String ruleCode) throws IOException { + GetDatabaseObjectConfigurations(); + if (getDatabaseObjectConfigurations() != null && !getDatabaseObjectConfigurations().isEmpty()) { + for (TableNameConfiguration data : getDatabaseObjectConfigurations()) { + if (data.getRuleCode().equals(ruleCode)) { + return data; + } + } + return null; + } else { + return null; + } + } + +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/datatype/DBODataTypeConfigurationLoader.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/datatype/DBODataTypeConfigurationLoader.java new file mode 100644 index 0000000000000000000000000000000000000000..c1da0ce275ddce61bee2ccb8dc014725ffc6ddbd --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/datatype/DBODataTypeConfigurationLoader.java @@ -0,0 +1,82 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.configuration.datatype; + +import io.iec.edp.caf.databaseobject.api.configuration.FileUtils; +import io.iec.edp.caf.databaseobject.api.configuration.funcmapping.DatabaseFuncConfiguration; +import io.iec.edp.caf.databaseobject.api.helper.DboConfigurationHelper; + +import java.io.IOException; +import java.util.List; + +/** + * 字段类型映射配置加载 + * + * @author liu_wei + */ +public class DBODataTypeConfigurationLoader { + private static String fileName = FileUtils.getSqlConfigPath(); + private static String sectionName = "DataTypeConverter"; + + private static List databaseObjectConfigurations; + + private static List getDatabaseObjectConfigurations() { + return databaseObjectConfigurations; + } + + private static void setDatabaseObjectConfiguration(List value) { + databaseObjectConfigurations = value; + } + + /** + * 构造函数 + */ + public DBODataTypeConfigurationLoader() throws IOException { + GetDatabaseObjectConfigurations(); + //GSPConfigurationSource.Current.AddSectionChangeHandler(MetadataServiceConfigSetting.fileName, MetadataServiceConfigSetting.SectionName, ConfigurationChanged); + } + + /** + * 获取配置文件数据 + */ + public static List GetDatabaseObjectConfigurations() throws IOException { + if (getDatabaseObjectConfigurations() == null) { + DboConfigurationHelper helper = new DboConfigurationHelper(); + List confs = null; + + confs = helper.getDataTypeConfiguration(fileName, sectionName); + setDatabaseObjectConfiguration(confs); + return getDatabaseObjectConfigurations(); + } else { + return getDatabaseObjectConfigurations(); + } + } + + public static DatabaseObjectDataTypeConfiguration GetDatabaseObjectConfiguration(String dataType) throws IOException { + GetDatabaseObjectConfigurations(); + if (getDatabaseObjectConfigurations() != null && !getDatabaseObjectConfigurations().isEmpty()) { + for (DatabaseObjectDataTypeConfiguration data : getDatabaseObjectConfigurations()) { + if (data.getDBODataType().equals(dataType)) { + return data; + } + } + return null; + } else { + return null; + } + } + + +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/datatype/DataTypeMapping.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/datatype/DataTypeMapping.java new file mode 100644 index 0000000000000000000000000000000000000000..7deec82aae296a637eb9c15bb9a9f5ca6dd218bb --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/datatype/DataTypeMapping.java @@ -0,0 +1,51 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.configuration.datatype; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * 数据库类型映射关系 + * + * @author liu_wei + */ +public class DataTypeMapping { + /** + * 数据库类型 + */ + @JsonProperty("DBType") + private String DBType; + + public final String getDBType() { + return DBType; + } + + public final void setDBType(String value) { + DBType = value; + } + + /** + * 数据类型 + */ + private String DataType; + + public final String getDataType() { + return DataType; + } + + public final void setDataType(String value) { + DataType = value; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/datatype/DatabaseObjectDataTypeConfiguration.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/datatype/DatabaseObjectDataTypeConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..7d7dce1b18e1bc07087b2c590d1ab8401c578c2d --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/datatype/DatabaseObjectDataTypeConfiguration.java @@ -0,0 +1,54 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.configuration.datatype; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; +import java.util.*; + +/** + * 数据库对象类型映射配置 + * + * @author liu_wei + */ +public class DatabaseObjectDataTypeConfiguration implements Serializable { + /** + * DBO中字段类型 + */ + @JsonProperty("DBODataType") + private String DBODataType; + + public final String getDBODataType() { + return DBODataType; + } + + public final void setDBODataType(String value) { + DBODataType = value; + } + + /** + * 数据库类型映射关系列表 + */ + private ArrayList DataTypeMappings; + + public final ArrayList getDataTypeMappings() { + return DataTypeMappings; + } + + public final void setDataTypeMappings(ArrayList value) { + DataTypeMappings = value; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/deplpyconfig/DboDeployConfiguration.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/deplpyconfig/DboDeployConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..35d6de23e453ecbb71b83be7e6ab5c3328a652fb --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/deplpyconfig/DboDeployConfiguration.java @@ -0,0 +1,46 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.configuration.deplpyconfig; + +import io.iec.edp.caf.commons.runtime.CafEnvironment; +import lombok.Data; + +import java.nio.file.Paths; + +/** + * DBO部署配置 + * + * @author liu_wei + */ +@Data +public class DboDeployConfiguration { + private String classPath; + + public String getClassPath() { + return Paths.get(CafEnvironment.getServerRTPath(), classPath).toString(); + } + + private String javaPath; + + public String getJavaPath() { + return Paths.get(CafEnvironment.getServerRTPath(), javaPath).toString(); + } + + private String jarPath; + + public String getJarPath() { + return Paths.get(CafEnvironment.getServerRTPath(), jarPath).toString(); + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/deplpyconfig/DboDeployConfigurationLoader.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/deplpyconfig/DboDeployConfigurationLoader.java new file mode 100644 index 0000000000000000000000000000000000000000..42cf81e75ee2e4704225932356ce5cc4184d049e --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/deplpyconfig/DboDeployConfigurationLoader.java @@ -0,0 +1,69 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.configuration.deplpyconfig; + + +import io.iec.edp.caf.databaseobject.api.configuration.FileUtils; +import io.iec.edp.caf.databaseobject.api.configuration.TableNameConfiguration; +import io.iec.edp.caf.databaseobject.api.helper.DboConfigurationHelper; + +import java.io.IOException; +import java.io.Serializable; +import java.util.List; + +/** + * 配置文件加载 + * + * @author liu_wei + */ +public class DboDeployConfigurationLoader implements Serializable { + private static String fileName = FileUtils.getSqlConfigPath(); + private static String sectionName = "DboDeployConfiguration"; + + private static DboDeployConfiguration DatabaseObjectConfiguration; + + protected static DboDeployConfiguration getDatabaseObjectConfiguration() { + return DatabaseObjectConfiguration; + } + + private static void setDatabaseObjectConfiguration(DboDeployConfiguration value) { + DatabaseObjectConfiguration = value; + } + + /** + * 构造函数 + */ + public DboDeployConfigurationLoader() { + GetDatabaseObjectConfigurationData(); + } + + + public static DboDeployConfiguration GetDatabaseObjectConfigurationData() { + if (getDatabaseObjectConfiguration() == null) { + DboConfigurationHelper helper = new DboConfigurationHelper(); + DboDeployConfiguration conf = null; + + try { + conf = helper.getDboDeployConfiguration(fileName, sectionName); + } catch (IOException e) { + throw new RuntimeException("获取数据库对象部署配置报错", e); + } + setDatabaseObjectConfiguration(conf); + return getDatabaseObjectConfiguration(); + } else { + return getDatabaseObjectConfiguration(); + } + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/funcmapping/DBOFuncMappingLoader.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/funcmapping/DBOFuncMappingLoader.java new file mode 100644 index 0000000000000000000000000000000000000000..d2dc7bb98e00e7e306693957d69d97fc440a328c --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/funcmapping/DBOFuncMappingLoader.java @@ -0,0 +1,92 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.configuration.funcmapping; + +import io.iec.edp.caf.databaseobject.api.configuration.FileUtils; +import io.iec.edp.caf.databaseobject.api.configuration.TableNameConfiguration; +import io.iec.edp.caf.databaseobject.api.helper.DboConfigurationHelper; + +import java.io.IOException; +import java.util.*; + +/** + * 函数映射配置加载 + * + * @author liu_wei + */ +public class DBOFuncMappingLoader { + private static String fileName = FileUtils.getSqlConfigPath(); + private static String sectionName = "SysFuncConvert"; + + + private static List databaseObjectConfigurations; + + private static List getDatabaseObjectConfigurations() { + return databaseObjectConfigurations; + } + + private static void setDatabaseObjectConfigurations(List value) { + databaseObjectConfigurations = value; + } + + /** + * 构造函数 + */ + public DBOFuncMappingLoader() throws IOException { + GetDatabaseObjectConfigurations(); + } + + + /** + * 获取配置文件数据 + * + * @return 配置数据列表 + * @throws IOException 异常 + */ + public static List GetDatabaseObjectConfigurations() throws IOException { + if (getDatabaseObjectConfigurations() == null) { + DboConfigurationHelper helper = new DboConfigurationHelper(); + ArrayList confs = null; + + confs = helper.getFuncConfiguration(fileName, sectionName); + + setDatabaseObjectConfigurations(confs); + return getDatabaseObjectConfigurations(); + } else { + return getDatabaseObjectConfigurations(); + } + } + + /** + * 根据功能名称获取配置 + * + * @param funcName 功能名称 + * @return 配置数据 + * @throws IOException 异常 + */ + public static DatabaseFuncConfiguration GetDatabaseObjectConfiguration(String funcName) throws IOException { + GetDatabaseObjectConfigurations(); + if (getDatabaseObjectConfigurations() != null && !getDatabaseObjectConfigurations().isEmpty()) { + for (DatabaseFuncConfiguration data : getDatabaseObjectConfigurations()) { + if (data.getFuncName().equals(funcName)) { + return data; + } + } + return null; + } else { + return null; + } + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/funcmapping/DatabaseFuncConfiguration.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/funcmapping/DatabaseFuncConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..a4f67e9180703e7c71d21fdae05caa96536b07fd --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/funcmapping/DatabaseFuncConfiguration.java @@ -0,0 +1,44 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.configuration.funcmapping; + +import java.io.Serializable; +import java.util.*; + +/** + * @author liu_wei + */ +public class DatabaseFuncConfiguration implements Serializable { + + private String FuncName; + + public final String getFuncName() { + return FuncName; + } + + public final void setFuncName(String value) { + FuncName = value; + } + + private ArrayList DatabaseFuncMappings; + + public final ArrayList getDatabaseFuncMappings() { + return DatabaseFuncMappings; + } + + public final void setDatabaseFuncMappings(ArrayList value) { + DatabaseFuncMappings = value; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/funcmapping/DatabaseFuncMapping.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/funcmapping/DatabaseFuncMapping.java new file mode 100644 index 0000000000000000000000000000000000000000..d1b2b6a15ce8985b58f5c2c585b1056b32dfb7b7 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/configuration/funcmapping/DatabaseFuncMapping.java @@ -0,0 +1,46 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.configuration.funcmapping; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +/** + * @author liu_wei + */ +public class DatabaseFuncMapping implements Serializable { + + @JsonProperty("DBType") + private String DBType; + + public final String getDBType() { + return DBType; + } + + public final void setDBType(String value) { + DBType = value; + } + + private String Func; + + public final String getFunc() { + return Func; + } + + public final void setFunc(String value) { + Func = value; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/context/DatabaseObjectContext.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/context/DatabaseObjectContext.java new file mode 100644 index 0000000000000000000000000000000000000000..bae35b0ef3e271f8afd4bcdb0c2822494d6ca9e7 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/context/DatabaseObjectContext.java @@ -0,0 +1,52 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.context; + +/** + * DBO上下文 + * + * @author zhaoleitr + */ +public class DatabaseObjectContext { + /** + * dbo文件后缀 + */ + public static String getSuffix() { + return ".dbo"; + } + + + /** + * 数据库对象开发路径 + * + */ + private static String DBORootRelativePath; + + public static String getDBORootRelativePath() { + return DBORootRelativePath; + } + + public static void setDBORootRelativePath(String value) { + DBORootRelativePath = value; + } + + /** + * 默认存放文件夹 + */ + public static String getDefaultFolder() { + + return "dbo"; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/context/DatabaseObjectReservedWords.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/context/DatabaseObjectReservedWords.java new file mode 100644 index 0000000000000000000000000000000000000000..47768099c7e35f795c8ad001e090a9d9ece264f6 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/context/DatabaseObjectReservedWords.java @@ -0,0 +1,65 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.context; + +import io.iec.edp.caf.databaseobject.api.entity.DatabaseObjectColumn; + +import java.util.ArrayList; + +/** + * 数据库对象保留字(时间戳字段,租户标识字段) + * + * @author liu_wei + */ +public class DatabaseObjectReservedWords { + private static ArrayList reservedWords; + + /** + * 数据库保留字列表 + * + * + */ + public static ArrayList getReservedWords() { + if (reservedWords == null || reservedWords.size() <= 0) { + reservedWords = getReservedWordsFromConfig(); + } + return reservedWords; + } + + + /** + * 判断字符串是否是数据库对象保留字 + * + * @param word 单词 + * @return 如果是数据库保留字,返回true,否则,返回false + */ + public static boolean isReservedWord(String word) { + return getReservedWords().contains(word); + } + + private static ArrayList getReservedWordsFromConfig() { + ArrayList reservedWords = new ArrayList<>(); + ArrayList timeStampColumns = ReservedColumns.getTimeStampColumns(); + if (timeStampColumns != null && !timeStampColumns.isEmpty()) { + for (DatabaseObjectColumn column : timeStampColumns) { + reservedWords.add(column.getCode()); + } + } + if (ReservedColumns.getTenantIdColumn() != null) { + reservedWords.add(ReservedColumns.getTenantIdColumn().getCode()); + } + return reservedWords; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/context/DatabaseReservedWords.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/context/DatabaseReservedWords.java new file mode 100644 index 0000000000000000000000000000000000000000..3722073d40ec7be78206daa3261d3989cb8a0f5a --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/context/DatabaseReservedWords.java @@ -0,0 +1,60 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.context; + + +import io.iec.edp.caf.databaseobject.api.configuration.FileUtils; + +import java.util.ArrayList; +import java.util.Arrays; + +/** + * 数据库保留字 + * + * @author liu_wei + */ +public class DatabaseReservedWords { + private static ArrayList reservedWords; + + /** + * 数据库保留字列表 + */ + public static ArrayList getReservedWords() { + if (reservedWords == null || reservedWords.size() <= 0) { + reservedWords = getReservedWordsFromConfig(); + } + return reservedWords; + } + + /** + * 判断字符串是否是数据库保留字 + * + * @param word + * @return 如果是数据库保留字,返回true,否则,返回false + * + */ + public static boolean isReservedWord(String word) { + if(!FileUtils.getReservedWordOpen()) + { + return false; + } + return getReservedWords().contains(word.toUpperCase()); + } + + private static ArrayList getReservedWordsFromConfig() { + ArrayList reservedWords = new ArrayList(Arrays.asList(new String[]{"ADD", "ALL", "ALTER", "AND", "ANY", "AS", "ASC", "AUTHORIZATION", "AVG", "BACKUP", "BEGIN", "BETWEEN", "BREAK", "BROWSE", "BULK", "BY", "CASCADE", "CASE", "CHECK", "CHECKPOINT", "CLOSE", "CLUSTERED", "COALESCE", "COLLATE", "COLUMN", "COMMIT", "COMPUTE", "CONSTRAINT", "CONTAINS", "CONTAINSTABLE", "CONTINUE", "CONVERT", "COUNT", "CREATE", "CROSS", "CURRENT", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "CURRENT_USER", "CURSOR", "DATABASE", "DATABASEPASSWORD", "DATEADD", "DATEDIFF", "DATENAME", "DATEPART", "DBCC", "DEALLOCATE", "DECLARE", "DEFAULT", "DELETE", "DENY", "DESC", "DISK", "DISTINCT", "DISTRIBUTED", "DOUBLE", "DROP", "DUMP", "ELSE", "ENCRYPTION", "END", "ERRLVL", "ESCAPE", "EXCEPT", "EXEC", "EXECUTE", "EXISTS", "EXIT", "EXPRESSION", "FETCH", "FILE", "FILLFACTOR", "FOR", "FOREIGN", "FREETEXT", "FREETEXTTABLE", "FROM", "FULL", "FUNCTION", "GOTO", "GRANT", "GROUP", "HAVING", "HOLDLOCK", "IDENTITY", "IDENTITY_INSERT", "IDENTITYCOL", "IF", "IN", "INDEX", "INNER", "INSERT", "INTERSECT", "INTO", "IS", "JOIN", "KEY", "KILL", "LEFT", "LIKE", "LINENO", "LOAD", "MAX", "MIN", "NATIONAL", "NOCHECK", "NONCLUSTERED", "NOT", "NULL", "NULLIF", "OF", "OFF", "OFFSETS", "ON", "ONLY", "OPEN", "OPENDATASOURCE", "OPENQUERY", "OPENROWSET", "OPENXML", "OPTION", "OR", "ORDER", "OUTER", "OVER", "PERCENT", "PLAN", "PRECISION", "PRIMARY", "PRINT", "PROC", "PROCEDURE", "PUBLIC", "RAISERROR", "READ", "READTEXT", "RECONFIGURE", "REFERENCES", "REPLICATION", "RESTORE", "RESTRICT", "RETURN", "REVOKE", "RIGHT", "ROLLBACK", "ROWCOUNT", "ROWGUIDCOL", "RULE", "SAVE", "SCHEMA", "SELECT", "SESSION_USER", "SET", "SETUSER", "SHUTDOWN", "SOME", "STATISTICS", "SUM", "SYSTEM_USER", "TABLE", "TEXTSIZE", "THEN", "TO", "TOP", "TRAN", "TRANSACTION", "TRIGGER", "TRUNCATE", "TSEQUAL", "UNION", "UNIQUE", "UPDATE", "UPDATETEXT", "USE", "USER", "VALUES", "VARYING", "VIEW", "WAITFOR", "WHEN", "WHERE", "WHILE", "WITH", "WRITETEXT", "ANALYSE", "ANALYZE", "ARRAY", "ASYMMETRIC", "BINARY", "BOTH", "CAST", "COLLATION", "CONCURRENTLY", "CURRENT_CATALOG", "CURRENT_ROLE", "CURRENT_SCHEMA", "DEFERRABLE", "DO", "FALSE", "FREEZE", "ILIKE", "INITIALLY", "ISNULL", "LATERAL", "LEADING", "LIMIT", "LOCALTIME", "LOCALTIMESTAMP", "NATURAL", "NOTNULL", "OFFSET", "ORDER", "OUTER", "OVERLAPS", "PLACING", "RETURNING", "SIMILAR", "SYMMETRIC", "TABLESAMPLE", "TRAILING", "TRUE", "USING", "VARIADIC", "VERBOSE", "WINDOW", "ACCESS", "AUDIT", "CHAR", "CLUSTER", "COLUMN_VALUE", "COMPRESS", "CONNECT", "DATE", "DECIMAL", "EXCLUSIVE", "FLOAT", "IDENTIFIED", "IMMEDIATE", "INCREMENT", "INITIAL", "INTEGER", "LEVEL", "LOCK", "LONG", "MAXEXTENTS", "MINUS", "MLSLABEL", "MODE", "MODIFY", "NESTED_TABLE_ID", "NOAUDIT", "NOCOMPRESS", "NOWAIT", "OFFLINE", "ONLINE", "PCTFREE", "PRIOR", "PRIVILEGES", "RAW", "RENAME", "RESOURCE", "ROW", "ROWID", "ROWNUM", "ROWS", "SESSION", "SHARE", "SIZE", "SMALLINT", "START", "SUCCESSFUL", "SYNONYM", "SYSDATE", "UID", "VALIDATE", "VARCHAR", "VARCHAR2", "WHENEVER", "ADMIN", "BIGDATEDIFF", "BYTE", "CALL", "CLUSTERBTR", "CONNECT_BY_ROOT", "CRYPTO", "CUBE", "DISKSPACE", "DOMAIN", "DROP", "EQU", "EXCEPTION", "EXCHANGE", "EXTRACT", "FIRST", "FULLY", "FUNCTION", "GROUP", "GROUPING", "INLINE", "INTERVAL", "KEEP", "LAST", "LINK", "LOGIN", "LIST", "LNNVL", "NEW", "NEXT", "NOCYCLE", "NVL", "OBJECT", "OUT", "OVERLAY", "PACKAGE", "PARTITION", "PENDANT", "REF", "REFERENCE", "REFERENCING", "REPEAT", "REPLICATE", "REVERSE", "ROLLUP", "SAVEPOINT", "SECTION", "SETS", "SIZEOF", "STATIC", "TIMESTAMPADD", "TIMESTAMPDIFF", "TRIM", "TYPEOF", "VERIFY", "VIRTUAL", "WITHIN", "INT", "TRXID", "VERSIONS_STARTTIME", "VERSIONS_ENDTIME", "VERSIONS_STARTTRXID", "VERSIONS_ENDTRXID", "VERSIONS_OPERATION"})); + return reservedWords; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/context/ReservedColumns.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/context/ReservedColumns.java new file mode 100644 index 0000000000000000000000000000000000000000..407e5e21502293b40650838ffb387f90846df88b --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/context/ReservedColumns.java @@ -0,0 +1,95 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.context; + + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.*; +import io.iec.edp.caf.databaseobject.api.configuration.DatabaseObjectConfiguration; +import io.iec.edp.caf.databaseobject.api.entity.DatabaseObjectColumn; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * 数据库对象保留字段信息 + * + * @author zhaoleitr + */ +public final class ReservedColumns { + private static ArrayList timeStampColumns; + + /** + * 时间戳字段列表 + */ + public static ArrayList getTimeStampColumns() { + if (timeStampColumns == null || timeStampColumns.size() <= 0) { + try { + timeStampColumns = getTimeStampColumnsFromConf(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return timeStampColumns; + } + + private static DatabaseObjectColumn tenantIDColumn; + + /** + * 租户标识字段 + */ + public static DatabaseObjectColumn getTenantIdColumn() { + if (tenantIDColumn == null) { + try { + tenantIDColumn = getTenantIdColumnfromConf(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return tenantIDColumn; + } + + private static String reservedColumns = "{\"TimeStampColumns\": [{\"DataType\": 9,\"DataTypeStr\": \"NVarchar\",\"Length\": 256,\"Precision\": 0,\"Scale\": 0,\"DefaultValue\": \"\",\"IfPrimaryKey\": false,\"IsNullable\": true,\"IsUnique\": false,\"ID\": \"dbc24616-3f96-4bb4-9870-b3044a7c69ff\",\"Code\": \"CreatedBy\",\"Name\": \"CreatedBy\",\"Description\": null,\"Type\": 3,\"TypeStr\": \"Column\",\"Version\": null},{\"DataType\": 6,\"DataTypeStr\": \"TimeStamp\",\"Length\": 0,\"Precision\": 0,\"Scale\": 0,\"DefaultValue\": \"\",\"IfPrimaryKey\": false,\"IsNullable\": true,\"IsUnique\": false,\"ID\": \"gt524616-3f96-4bb4-9870-b3044a7c69ff\",\"Code\": \"CreatedOn\",\"Name\": \"CreatedOn\",\"ShowName\": null,\"Description\": null,\"Type\": 3,\"TypeStr\": \"Column\",\"Version\": null},{\"DataType\": 9,\"DataTypeStr\": \"NVarchar\",\"Length\": 256,\"Precision\": 0,\"Scale\": 0,\"DefaultValue\": \"\",\"IfPrimaryKey\": false,\"IsNullable\": true,\"IsUnique\": false,\"ID\": \"v4s24616-3f96-4bb4-9870-b3044a7c69ff\",\"Code\": \"LastChangedBy\",\"Name\": \"LastChangedBy\",\"Description\": null,\"Type\": 3,\"TypeStr\": \"Column\",\"Version\": null},{\"DataType\": 6,\"DataTypeStr\": \"TimeStamp\",\"Length\": 0,\"Precision\": 0,\"Scale\": 0,\"DefaultValue\": \"\",\"IfPrimaryKey\": false,\"IsNullable\": true,\"IsUnique\": false,\"ID\": \"3f524616-3f96-4bb4-9870-b3044a7c69ff\",\"Code\": \"LastChangedOn\",\"Name\": \"LastChangedOn\",\"Description\": null,\"Type\": 3,\"TypeStr\": \"Column\",\"Version\": null}],\"TanantIDColumn\": {\"DataType\": 1,\"DataTypeStr\": \"Varchar\",\"Length\": 256,\"Precision\": 0,\"Scale\": 0,\"DefaultValue\": \"\",\"IfPrimaryKey\": false,\"IsNullable\": true,\"IsUnique\": false,\"ID\": \"efsa4616-3f96-4bb4-9870-b3044a7c69ff\",\"Code\": \"TenantID\", \"Name\": \"TenantID\", \"Description\": null,\"Type\": 3, \"TypeStr\": \"Column\",\"Version\": null}}"; + + private static ArrayList getTimeStampColumnsFromConf() throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + //N转J忽略大小写 + mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true); + JsonNode rootNode = mapper.readTree(reservedColumns); + + String content = rootNode.findValue("TimeStampColumns").toString(); + return mapper.readValue(content, new TypeReference>() { + }); + + } + + private static DatabaseObjectColumn getTenantIdColumnfromConf() throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + //N转J忽略大小写 + mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true); + JsonNode rootNode = mapper.readTree(reservedColumns); + String content = rootNode.findValue("TanantIDColumn").toString(); + return mapper.readValue(content, DatabaseObjectColumn.class); + } + + private static JavaType getCollectionType(ObjectMapper mapper, Class collectionClass, Class... elementClasses) { + return mapper.getTypeFactory().constructParametricType(collectionClass, elementClasses); + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/AbstractDatabaseObject.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/AbstractDatabaseObject.java new file mode 100644 index 0000000000000000000000000000000000000000..0bf0ee2bdae38e11934ffb6ccd76970ba5001e8b --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/AbstractDatabaseObject.java @@ -0,0 +1,120 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.io.Serializable; +import java.io.*; +import java.time.LocalDateTime; + +/** + * 数据库对象基类 + * + * @author liu_wei + */ +@Data +public class AbstractDatabaseObject implements Cloneable, Serializable { + /** + * 对象唯一标识 + */ + + private String id; + + /** + * 对象编号 + */ + private String code; + + + /** + * 对象名称 + */ + private String name; + + /** + * 对象类型 + */ + @JsonProperty(value = "Type") + private DatabaseObjectType type = DatabaseObjectType.values()[0]; + + public DatabaseObjectType getType() { + return type; + } + + public void setType(DatabaseObjectType value) { + type = value; + } + + /** + * 对象类型 + */ + private String typeStr; + + public String getTypeStr() { + return String.valueOf(this.getType()); + } + + /** + * 版本(保存自动生成,用于部署时判断是否变更) + * + */ + private String version; + + /** + * 对象说明 + */ + private String description; + + /** + * 对象说明 + */ + @JsonIgnore + private LocalDateTime lastModifiedTime; + + /** + * 克隆 + * + * @return 数据库对象表 + */ + @Override + public AbstractDatabaseObject clone() { + ObjectOutputStream os = null; + ObjectInputStream ois = null; + AbstractDatabaseObject target = null; + try { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + os = new ObjectOutputStream(bos); + os.writeObject(this); + + ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); + ois = new ObjectInputStream(bis); + target = (AbstractDatabaseObject) ois.readObject(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + ois.close(); + os.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return target; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/ColumnChangeOperation.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/ColumnChangeOperation.java new file mode 100644 index 0000000000000000000000000000000000000000..a31eb672f1870efd0fdb1b5e5650209b56cb5eaf --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/ColumnChangeOperation.java @@ -0,0 +1,38 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + + +import lombok.Data; + +import java.util.List; + +/** + * @author renmh + */ +@Data +public class ColumnChangeOperation { + + /** + * 列对象 + */ + private DatabaseObjectColumn column; + + /** + * 操作集合 + */ + private List operations; + +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/ColumnOperation.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/ColumnOperation.java new file mode 100644 index 0000000000000000000000000000000000000000..c3f530a0171c572ab804d0834eeefa5a985f8e07 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/ColumnOperation.java @@ -0,0 +1,38 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +import lombok.Data; + +/** + * 列的操作行为 + * + * @author renmh + */ +@Data +public class ColumnOperation { + /** + * 操作类型,1:修改类型,2:修改长度 3:修改默认值 + */ + private int operationType; + /** + * 类型变化前的旧值 + */ + private Object oldValue; + /** + * 类型变化后的新值 + */ + private Object newValue; +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DBInfo.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DBInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..f7a7d97d44859cf3049f14f8a2bf9acf9dd9eb47 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DBInfo.java @@ -0,0 +1,160 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +/** + * 数据库连接信息 + * + * @author liu_wei + */ +public class DBInfo { + + /** + * 数据库类型 + */ + private DbType dbType; + + public DbType getDbType() { + return dbType; + } + + public void setDbType(DbType dbType) { + this.dbType = dbType; + } + + /** + * 数据库地址 + */ + private String server; + + public String getServer() { + return server; + } + + public void setServer(String server) { + this.server = server; + } + + /** + * 数据库名称 + */ + private String dbName; + + public String getDbName() { + return dbName; + } + + public void setDbName(String dbName) { + this.dbName = dbName; + } + + /** + * 数据库账号 + */ + private String userName; + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + /** + * 数据库密码 + */ + private String passWord; + + public String getPassWord() { + return passWord; + } + + public void setPassWord(String passWord) { + this.passWord = passWord; + } + + /** + * 端口 + */ + private String port; + + public String getPort() { + return port; + } + + public void setPort(String port) { + this.port = port; + } + + /** + * 数据库连接串 + */ + private String url; + + public String getUrl() { + if (url == null || url.length() <= 0) { + switch (dbType) { + case DM: + url = "jdbc:dm://" + server + ":" + port + "/DMSERVER?schema=" + dbName; + break; + case PgSQL: + url = "jdbc:postgresql://" + server + ":" + port + "/" + dbName; + break; + case Oracle: + url = "jdbc:oracle:thin:@//" + server + ":" + port + "/" + dbName; + break; + case SQLServer: + url = "jdbc:sqlserver://" + server + "\\" + dbName + ":" + port + ";database=" + dbName; + break; + case HighGo: + url = "jdbc:highgo://" + server + ":" + port + "/" + dbName; + break; + case MySQL: + url = "jdbc:mysql://" + server + ":" + port + "/" + dbName + "?characterEncoding=utf8&serverTimezone=UTC&useSSL=false"; + break; + case Oscar: + url = "jdbc:oscar://" + server + ":" + port + "/" + dbName; + break; + case Kingbase: + url = "jdbc:kingbase8://" + server + ":" + port + "/" + dbName; + break; + case DB2: + url = "jdbc:db2://" + server + ":" + port + "/" + dbName; + break; + default: + throw new RuntimeException("数据库类型不正确"); + } + } + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + /** + * 模式 + */ + private String schema; + + public String getSchema() { + return schema; + } + + public void setSchema(String schema) { + this.schema = schema; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DBOTableNameRule.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DBOTableNameRule.java new file mode 100644 index 0000000000000000000000000000000000000000..bf7172e73cb169a2067ee073c37cdb958baf2354 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DBOTableNameRule.java @@ -0,0 +1,72 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * 数据库对象表名规则实体 + * + * @author liu_wei + */ +@Data +public class DBOTableNameRule implements Serializable { + public DBOTableNameRule() { + this.setDimensionStrategyWithOrder(new ArrayList<>()); + } + + /** + * 规则标识 + */ + private String id; + + /** + * 规则标识 + */ + private String code; + /** + * 规则名称 + */ + private String name; + + /** + * 是否同步结构 + */ + @JsonProperty("IsSynStructure") + private boolean isSynStructure; + + /** + * 带顺序维度策略列表 + */ + private List dimensionStrategyWithOrder; + + @Override + public Object clone() { + DBOTableNameRule rule = new DBOTableNameRule(); + rule.setId(this.getId()); + rule.setCode(this.getCode()); + rule.setName(this.getName()); + rule.setSynStructure(this.isSynStructure); + for (DimensionStrategyWithOrder strategy : dimensionStrategyWithOrder) { + rule.dimensionStrategyWithOrder.add((DimensionStrategyWithOrder) strategy.clone()); + } + return rule; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DataType.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DataType.java new file mode 100644 index 0000000000000000000000000000000000000000..5b405a9ab9a8769f28478555c9e0454c43b2261b --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DataType.java @@ -0,0 +1,118 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +/** + * 数据类型 + * + * @author liu_wei + */ +public enum DataType { + /** + * 字符型 + */ + Char, + + /** + * 可变长字符型 + */ + Varchar, + + /** + * 长文本 + */ + Clob, + + /** + * 整型 + */ + Int, + + /** + * 十进制 + */ + Decimal, + + /** + * 日期型 + */ + DateTime, + + /** + * 日期时间型 + */ + TimeStamp, + + /** + * 大二进制 + */ + Blob, + + /** + * Unicode字符数据类型 + */ + NChar, + + /** + * Unicode字符串数据类型 + */ + NVarchar, + + /** + * Unicode长文本 + */ + NClob, + + /** + * Bool类型 + */ + Boolean, + + /** + * 数字 + */ + SmallInt, + + /** + * 长整型数据 + */ + LongInt, + + /** + * 浮点型 + */ + Float, + + /** + * 暂未支持类型 + */ + NotSupported, + + /** + * 产品需求,兼容pg的Jsonb类型,仅作为标识 + */ + Jsonb; + + + public static final int SIZE = java.lang.Integer.SIZE; + + public int getValue() { + return this.ordinal(); + } + + public static DataType forValue(int value) { + return values()[value]; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectColumn.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectColumn.java new file mode 100644 index 0000000000000000000000000000000000000000..2216694ed885681a97a5efb86c8ce20f4316cb09 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectColumn.java @@ -0,0 +1,133 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.*; + +/** + * 数据库对象列实体 + * + * @author liu_wei + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class DatabaseObjectColumn extends AbstractDatabaseObject implements Serializable { + /** + * 构造函数 + */ + public DatabaseObjectColumn() { + this(UUID.randomUUID().toString()); + } + + private DatabaseObjectColumn(String colId) { + this.setId(colId); + } + + /** + * 字段数据类型 + */ + private DataType DataType; + /** + * 字段数据类型 + */ + private DataType DataTypeStr; + + public final String getDataTypeStr() { + return String.valueOf(this.getDataType()); + } + + /** + * 字段长度 + */ + private int length; + + /** + * 字段精度 + */ + private int precision; + + /** + * 字段小数位数 + */ + private int scale; + + /** + * 字段默认值 + */ + private String defaultValue; + /** + * 是否主键 + */ + @JsonProperty("ifPrimaryKey") + private boolean ifPrimaryKey; + + /** + * 是否可为空 + */ + @JsonProperty("isNullable") + private boolean isNullable; + + /** + * 是否唯一 + */ + @JsonProperty("isUnique") + private boolean isUnique; + + /** + 获取对应的GSPDbDataTyp + + @return + */ +// public final GSPDbDataType GetGSPDbDataType() +// { +// return DataTypeConverter.getInstance().ConvertDataTypeToGSPDbDataType(this.getDataType()); +// } + + /** + * 唯一约束名 + */ + private String ucName; + + /** + * 克隆 + * + * @return 数据库对象表 + * + */ + @Override + public final DatabaseObjectColumn clone() { + DatabaseObjectColumn column = new DatabaseObjectColumn(this.getId()); + column.setCode(this.getCode()); + column.setName(this.getName()); + column.setDataType(this.getDataType()); + column.setLength(this.getLength()); + column.setPrecision(this.getPrecision()); + column.setScale(this.getScale()); + column.setDefaultValue(this.getDefaultValue()); + column.setUnique(this.isUnique); + column.setIfPrimaryKey(this.ifPrimaryKey); + column.setNullable(this.isNullable); + column.setType(DatabaseObjectType.Column); + column.setUcName(this.getUcName()); + column.setVersion(this.getVersion()); + column.setDescription(this.getDescription()); + return column; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectIndex.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectIndex.java new file mode 100644 index 0000000000000000000000000000000000000000..a21b4f255e0f43479952e7b4ac6b665177bd122f --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectIndex.java @@ -0,0 +1,104 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.*; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + + +/** + * 数据库对象索引实体 + * 考虑之后是否要添加条件描述及索引关联字段上添加升序、降序描述等 + * + * @author liu_wei + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class DatabaseObjectIndex extends AbstractDatabaseObject implements Serializable { + /** + * 构造函数 + */ + public DatabaseObjectIndex() { + this(UUID.randomUUID().toString()); + } + + private DatabaseObjectIndex(String indexId) { + this.setId(indexId); + this.setColumns(new ArrayList<>()); + } + + /** + * 是否主键索引 + * + */ + @JsonProperty("ifPrimary_Key") + private boolean ifPrimary_Key; + + /** + * 是否聚集索引 + * + */ + @JsonProperty("isCluster_Constraint") + private boolean isCluster_Constraint; + + /** + * 是否唯一索引 + */ + @JsonProperty("isUnique_Constraint") + private boolean isUnique_Constraint; + + /** + * 索引关联的列 + */ + private List columns; + + public final List getColumns() { + return columns; + } + + public final void setColumns(List value) { + columns = value; + } + + /** + * 克隆 + * + * @return 数据库对象视图 + */ + @Override + public final DatabaseObjectIndex clone() { + DatabaseObjectIndex index = new DatabaseObjectIndex(this.getId()); + index.setCode(this.getCode()); + index.setName(this.getName()); + index.setDescription(this.getName()); + index.setIfPrimary_Key(this.ifPrimary_Key); + index.setCluster_Constraint(this.isCluster_Constraint); + index.setUnique_Constraint(this.isUnique_Constraint); + index.setType(this.getType()); + index.setVersion(this.getVersion()); + if (this.getColumns() != null && this.getColumns().size() > 0) { + for (DatabaseObjectColumn item : this.getColumns()) { + index.getColumns().add(item.clone()); + } + } + return index; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectInfo.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..ef7bba8b676e0b5eff05172f6d4d3cbf23d7356f --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectInfo.java @@ -0,0 +1,35 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +/** + * DBO文件信息 + * + * @author zhaoleitr + */ +public class DatabaseObjectInfo extends AbstractDatabaseObject { + /** + * 数据库对象全路径 + */ + private String filePath; + + public final String getFilePath() { + return filePath; + } + + public final void setFilePath(String value) { + filePath = value; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectTable.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectTable.java new file mode 100644 index 0000000000000000000000000000000000000000..e7505fb5782bde736dfe272ac888c11fa92f5323 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectTable.java @@ -0,0 +1,395 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.*; +import java.util.*; + +/** + * 数据库对象表实体 + * 因为使用的ObjectMapper序列化,存在一个bug,所有is开头的属性,必须使用JsonProperty标签且设置忽略大小写,否则会一直返回false + * + * @author liu_wei + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class DatabaseObjectTable extends DatabaseObjectTableCore implements Serializable { + /** + * 数据库对象表构造函数 + */ + public DatabaseObjectTable() { + this(UUID.randomUUID().toString()); + } + + private DatabaseObjectTable(String dboId) { + this.setId(dboId); + this.setType(DatabaseObjectType.Table); + this.setColumns(new ArrayList<>()); + this.setIndexes(new ArrayList<>()); + this.setPrimaryKey(new ArrayList<>()); + this.multiLanguageColumns = new ArrayList<>(); + } + + /** + * 数据库对象实体构造方法 + * + * @param code 编号 + * @param name 名称 + * @param isSynHis 是否同步创建历史表 + * @param isI18NObject 是否多语 + * @param isUsingTimeStamp 是否启用时间戳字段 + * @param isFiscalTable 是否为年度表 + * @param businessObjectId 业务对象字段ID + */ + + public DatabaseObjectTable(String code, String name, boolean isSynHis, boolean isI18NObject, boolean isUsingTimeStamp, boolean isFiscalTable, String businessObjectId) { + this(code, name, isSynHis, isI18NObject, isUsingTimeStamp, isFiscalTable, businessObjectId, null); + } + + + public DatabaseObjectTable(String code, String name, boolean isSynHis, boolean isI18NObject, boolean isUsingTimeStamp, boolean isFiscalTable, String businessObjectId, String ID) { + if (ID == null || ID.length() == 0) { + this.setId(UUID.randomUUID().toString()); + } else { + this.setId(ID); + } + this.setCode(code); + this.setName(name); + this.setSynHis(isSynHis); + this.setI18NObject(isI18NObject); + this.setType(DatabaseObjectType.Table); + this.setUsingTimeStamp(isUsingTimeStamp); + this.setFiscalTable(isFiscalTable); + this.setBusinessObjectId(businessObjectId); + this.setColumns(new ArrayList<>()); + this.setIndexes(new ArrayList<>()); + this.setPrimaryKey(new ArrayList<>()); + this.multiLanguageColumns = new ArrayList<>(); + } + + /** + * 业务对象字段关联属性 + */ + private String businessObjectId; + + /** + * 主键名 + */ + private String pkName; + /** + * 对象是否多语 + */ + @JsonProperty("isI18nObject") + private boolean isI18NObject; + /** + * 是否年度表 + */ + @JsonProperty("isFiscalTable") + private boolean isFiscalTable; + /** + * 是否同步历史表 + */ + @JsonProperty("isSynHis") + private boolean isSynHis; + /** + * 是否启用时间戳字段 + */ + @JsonProperty("isUsingTimeStamp") + private boolean isUsingTimeStamp; + + private List primaryKey; + + /** + * 数据库对象表主键列(冗余字段) + */ + public final List getPrimaryKey() { + if (primaryKey == null) { + primaryKey = new ArrayList<>(); + } + return primaryKey; + } + + public final void setPrimaryKey(List value) { + primaryKey = value; + } + + private List indexes; + + /** + * 数据库对象索引列表 + */ + public final List getIndexes() { + if (this.indexes == null) { + this.indexes = new ArrayList<>(); + } + return indexes; + } + + public final void setIndexes(List value) { + this.indexes = value; + } + + private List multiLanguageColumns; + + /** + * 多语字段 + */ + public final List getMultiLanguageColumns() { + if (multiLanguageColumns == null) { + multiLanguageColumns = new ArrayList<>(); + } + return multiLanguageColumns; + } + + @JsonIgnore + private Map multiLanguageColumnCodes; + + /** + * 多语字段的编号 + */ + public final Map getMultiLanguageColumnCodes() { + if (multiLanguageColumns == null) { + multiLanguageColumnCodes = new HashMap<>(); + } else { + multiLanguageColumnCodes = new HashMap<>(); + for (String multiLanguageId : multiLanguageColumns) { + DatabaseObjectColumn column = getColumnById(multiLanguageId); + multiLanguageColumnCodes.put(multiLanguageId, column.getCode()); + } + } + return multiLanguageColumnCodes; + } + + public final void setMultiLanguageColumns(List value) { + multiLanguageColumns = value; + } + + /** + * 租户标识字段 + */ + private DatabaseObjectColumn tenantIdentityColumn; + + /** + * 数据库对象表名规则 + */ + private DBOTableNameRule dboTableNameRule; + + private boolean hasNameRule; + + /** + * DBO是否包含表名规则的只读属性 + */ + public final boolean getHasNameRule() { + return getDboTableNameRule() != null && getDboTableNameRule().getDimensionStrategyWithOrder() != null && !getDboTableNameRule().getDimensionStrategyWithOrder().isEmpty(); + } + + /** + * 添加列 + * + * @param id ID + * @param code 编号 + * @param name 名称 + * @param dataType 数据类型 + * @param length 长度 + * @param precision 精度 + * @param scale 小数位数 + * @param defaultValue 默认值 + * @param ifUnique 是否唯一 + * @param ifPK 是否主键 + * @param isNullable 是否可为空 + * @param isI18n 是否多语 + */ + public final void addColumn(String id, String code, String name, DataType dataType, int length, int precision, int scale, String defaultValue, boolean ifUnique, boolean ifPK, boolean isNullable, boolean isI18n) { + DatabaseObjectColumn column = new DatabaseObjectColumn(); + column.setId(id); + column.setCode(code); + column.setName(name); + column.setDataType(dataType); + column.setLength(length); + column.setPrecision(precision); + column.setScale(scale); + column.setDefaultValue(defaultValue); + column.setUnique(ifUnique); + column.setIfPrimaryKey(ifPK); + column.setNullable(isNullable); + column.setType(DatabaseObjectType.Column); + + if (ifPK) { + this.getPrimaryKey().add(id); + column.setNullable(false); + column.setUnique(true); + } + if (isI18n) { + column.setDataType(convertToI18NDataType(dataType, column.getCode())); + this.getMultiLanguageColumns().add(id); + this.setI18NObject(true); + } + this.getColumns().add(column); + } + + /** + * 修改列 + * + * @param id ID + * @param name 字段名称 + * @param dataType 数据类型 + * @param length 长度 + * @param precision 精度 + * @param scale 小数位数 + * @param defaultValue 默认值 + * @param ifUnique 是否唯一 + * @param ifPK 是否主键 + * @param isNullable 是否可为空 + * @param isI18n 是否多语 + */ + public final void modifyColumn(String id, String name, DataType dataType, int length, int precision, int scale, String defaultValue, boolean ifUnique, boolean ifPK, boolean isNullable, boolean isI18n) { + DatabaseObjectColumn column = getColumnById(id); + if (column == null) { + throw new RuntimeException(String.format("数据库对象表中不存在ID为%1$s的字段", id)); + } + column.setId(id); + if (isI18n || getMultiLanguageColumns().contains(id)) { + dataType = convertToI18NDataType(dataType, column.getCode()); + } + column.setName(name); + column.setDataType(dataType); + column.setLength(length); + column.setPrecision(precision); + column.setScale(scale); + column.setDefaultValue(defaultValue); + column.setUnique(ifUnique); + column.setIfPrimaryKey(ifPK); + column.setNullable(isNullable); + if (ifPK) { + column.setNullable(false); + column.setUnique(true); + + if (!getPrimaryKey().contains(id)) { + getPrimaryKey().add(id); + } + } + if (!ifPK && this.getPrimaryKey().contains(id)) { + this.getPrimaryKey().remove(id); + } + if (isI18n && !getMultiLanguageColumns().contains(id)) { + this.getMultiLanguageColumns().add(id); + this.setI18NObject(true); + } + } + + private DataType convertToI18NDataType(DataType dataType, String columnCode) { + if (dataType == DataType.Varchar || dataType == DataType.NVarchar) { + return DataType.NVarchar; + } + if (dataType == DataType.Char || dataType == DataType.NChar) { + return DataType.NChar; + } + if (dataType == DataType.Clob || dataType == DataType.NClob) { + return DataType.NClob; + } else { + throw new RuntimeException(String.format("当前字段数据类型不支持多语,字段编号为%1$s,当前数据类型为%2$s,请确认。", columnCode, dataType)); + } + } + + + /** + * 添加租户标识字段 + */ + public final void addTenantIdColumn() { + if (this.getColumnByCode("TenantID") == null) { + this.setTenantIdentityColumn(new DatabaseObjectColumn()); + this.getTenantIdentityColumn().setId(UUID.randomUUID().toString()); + this.getTenantIdentityColumn().setCode("TenantID"); + this.getTenantIdentityColumn().setName("TenantID"); + this.getTenantIdentityColumn().setDataType(DataType.Varchar); + this.getTenantIdentityColumn().setLength(36); + this.getTenantIdentityColumn().setPrecision(0); + this.getTenantIdentityColumn().setScale(0); + this.getTenantIdentityColumn().setDefaultValue(null); + this.getTenantIdentityColumn().setUnique(false); + this.getTenantIdentityColumn().setIfPrimaryKey(false); + this.getTenantIdentityColumn().setNullable(true); + } + } + + /** + * 克隆 + * + * @return 数据库对象表 + */ + @Override + public DatabaseObjectTable clone() { + DatabaseObjectTable table = new DatabaseObjectTable(this.getId()); + table.setCode(this.getCode()); + table.setName(this.getName()); + table.setPkName(getPkName()); + table.setBusinessObjectId(getBusinessObjectId()); + if (this.getHasNameRule()) + table.setDboTableNameRule((DBOTableNameRule) this.getDboTableNameRule().clone()); + table.setDescription(this.getDescription()); + table.setI18NObject(this.isI18NObject); + table.setSynHis(this.isSynHis); + table.setUsingTimeStamp(this.isUsingTimeStamp); + if (this.tenantIdentityColumn != null) { + table.setTenantIdentityColumn(this.tenantIdentityColumn.clone()); + } + table.setType(this.getType()); + table.setVersion(this.getVersion()); + table.setFiscalTable(this.isFiscalTable); + table.setLastModifiedTime(this.getLastModifiedTime()); + for (DatabaseObjectColumn column : this.getColumns()) { + table.getColumns().add(column.clone()); + } + for (DatabaseObjectIndex index : this.getIndexes()) { + table.getIndexes().add(index.clone()); + } + if (this.getMultiLanguageColumns() != null && this.getMultiLanguageColumns().size() > 0) { + table.getMultiLanguageColumns().addAll(this.getMultiLanguageColumns()); + } + if (this.getPrimaryKey() != null && this.getPrimaryKey().size() > 0) { + table.getPrimaryKey().addAll(this.getPrimaryKey()); + } + return table; + } + + /** + * 根据字段ID获取字段 + * + * @param columnId 字段ID + * @return 字段实体 + */ + @Override + public final DatabaseObjectColumn getColumnById(String columnId) { + Optional columnsOpt = this.getColumns().stream().filter((item) -> item.getId().equals(columnId)).findFirst(); + return columnsOpt.orElse(null); + } + + /** + * 根据字段编号获取字段 + * + * @param columnCode 字段编号 + * @return 字段实体 + */ + @Override + public final DatabaseObjectColumn getColumnByCode(String columnCode) { + Optional columnsOpt = this.getColumns().stream().filter((item) -> item.getCode().toLowerCase().equals(columnCode.toLowerCase())).findFirst(); + return columnsOpt.orElse(null); + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectTableCore.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectTableCore.java new file mode 100644 index 0000000000000000000000000000000000000000..3264900370730949939d9d0a3a8125b62f758dd6 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectTableCore.java @@ -0,0 +1,74 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +/** + * 数据库对象表核心内容实体 + * + * @author liu_wei + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class DatabaseObjectTableCore extends AbstractDatabaseObject implements Serializable { + + + private List columns; + + /** + * 数据库表字段列表 + */ + public List getColumns() { + if (this.columns == null) { + this.columns = new ArrayList<>(); + } + return columns; + } + + public void setColumns(List value) { + this.columns = value; + } + + /** + * 根据字段ID获取字段 + * + * @param columnId 字段ID + * @return 字段实体 + */ + public DatabaseObjectColumn getColumnById(String columnId) { + Optional columnsOpt = this.getColumns().stream().filter((item) -> item.getId().equals(columnId)).findFirst(); + return columnsOpt.orElse(null); + } + + /** + * 根据字段编号获取字段 + * + * @param columnCode 字段编号 + * @return 字段实体 + */ + public DatabaseObjectColumn getColumnByCode(String columnCode) { + Optional columnsOpt = this.getColumns().stream().filter((item) -> item.getCode().toLowerCase().equals(columnCode.toLowerCase())).findFirst(); + return columnsOpt.orElse(null); + } + +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectTempTable.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectTempTable.java new file mode 100644 index 0000000000000000000000000000000000000000..989e892334db4afc78a779beabceaf895ef8a14b --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectTempTable.java @@ -0,0 +1,99 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +/** + * 临时表 + * + * @author liu_wei + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class DatabaseObjectTempTable extends DatabaseObjectTable implements Serializable { + + public DatabaseObjectTempTable() { + this(UUID.randomUUID().toString()); + } + + private DatabaseObjectTempTable(String dboId) { + this.setId(dboId); + this.setType(DatabaseObjectType.TempTable); + this.setColumns(new ArrayList<>()); + this.setIndexes(new ArrayList<>()); + this.setPrimaryKey(new ArrayList<>()); + } + + /** + * 对象类型 + */ + @JsonProperty(value = "Type") + private DatabaseObjectType type = DatabaseObjectType.values()[6]; + + @Override + public DatabaseObjectType getType() { + return type; + } + + /** + * 对象是否多语 + */ + @JsonProperty("isI18nObject") + private boolean isI18nObject; + + + /** + * 克隆 + * + * @return 数据库对象临时表 + */ + @Override + public DatabaseObjectTempTable clone() { + DatabaseObjectTempTable table = new DatabaseObjectTempTable(this.getId()); + table.setCode(this.getCode()); + table.setName(this.getName()); + table.setPkName(getPkName()); + table.setBusinessObjectId(getBusinessObjectId()); + table.setLastModifiedTime(this.getLastModifiedTime()); + if (this.getHasNameRule()) { + table.setDboTableNameRule((DBOTableNameRule) this.getDboTableNameRule().clone()); + } + table.setDescription(this.getDescription()); + //table.setI18NObject(isI18NObject); + table.setType(this.getType()); + table.setVersion(this.getVersion()); + for (DatabaseObjectColumn column : this.getColumns()) { + table.getColumns().add(column.clone()); + } + for (DatabaseObjectIndex index : this.getIndexes()) { + table.getIndexes().add(index.clone()); + } + if (this.getMultiLanguageColumns() != null && this.getMultiLanguageColumns().size() > 0) { + table.getMultiLanguageColumns().addAll(this.getMultiLanguageColumns()); + } + if (this.getPrimaryKey() != null && this.getPrimaryKey().size() > 0) { + table.getPrimaryKey().addAll(this.getPrimaryKey()); + } + return table; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectType.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectType.java new file mode 100644 index 0000000000000000000000000000000000000000..f8e760db309816b5951644d22f8b0a4d9d9ab8bf --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectType.java @@ -0,0 +1,91 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +import com.fasterxml.jackson.annotation.JsonValue; + +import java.util.HashMap; +import java.util.Map; + +/** + * 数据库对象类型 + * + * @author liu_wei + */ +public enum DatabaseObjectType { + /** + * 表 + */ + Table(0), + + /** + * 视图 + */ + View(1), + + /** + * 函数 + */ + Function(2), + + /** + * 字段 + */ + Column(3), + + /** + * 索引 + */ + Index(4), + + /** + * 存储过程 + */ + StoreProcedure(5), + + /** + * 临时表 + */ + TempTable(6); + + public static final int SIZE = java.lang.Integer.SIZE; + + private int intValue; + private static Map mappings; + + private static Map getMappings() { + if (mappings == null) { + synchronized (DatabaseObjectType.class) { + if (mappings == null) { + mappings = new HashMap(); + } + } + } + return mappings; + } + + private DatabaseObjectType(int value) { + intValue = value; + getMappings().put(value, this); + } + + public int getValue() { + return intValue; + } + + public static DatabaseObjectType forValue(int value) { + return getMappings().get(value); + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectView.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectView.java new file mode 100644 index 0000000000000000000000000000000000000000..daa4c91bcd1ff5dc112f08295d6d32f0eeeefc40 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectView.java @@ -0,0 +1,143 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +/** + * 视图 + * + * @author zhaoleitr + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class DatabaseObjectView extends DatabaseObjectTableCore implements Serializable { + public DatabaseObjectView() { + this.setMultiLanguageColumns(new ArrayList<>()); + this.setDefinationWithDbType(new ArrayList<>()); + this.setDboTableNameRule(new DBOTableNameRule()); + } + + /** + * 业务对象字段关联属性 + */ + private String businessObjectId; + + private List multiLanguageColumns; + + /** + * 定义 + */ + private String defination; + + + private List definationWithDbType; + + /** + * 对象是否多语 + */ + @JsonProperty("isI18nObject") + private boolean isI18nObject; + + + /** + * 数据库对象表名规则 + */ + private DBOTableNameRule dboTableNameRule; + + private boolean hasNameRule; + + /** + * 对象类型 + */ + @JsonProperty(value = "Type") + private DatabaseObjectType type = DatabaseObjectType.values()[1]; + + @Override + public DatabaseObjectType getType() { + return type; + } + + /** + * DBO是否包含表名规则的只读属性 + */ + public final boolean getHasNameRule() { + return getDboTableNameRule() != null && getDboTableNameRule().getDimensionStrategyWithOrder() != null && !getDboTableNameRule().getDimensionStrategyWithOrder().isEmpty(); + } + + /** + * 根据字段ID获取字段 + * + * @param columnId 字段ID + * @return 字段实体 + */ + @Override + public final DatabaseObjectColumn getColumnById(String columnId) { + Optional columnsOpt = this.getColumns().stream().filter((item) -> item.getId().equals(columnId)).findFirst(); + return columnsOpt.orElse(null); + } + + /** + * 根据字段编号获取字段 + * + * @param columnCode 字段编号 + * @return 字段实体 + */ + @Override + public final DatabaseObjectColumn getColumnByCode(String columnCode) { + Optional columnsOpt = this.getColumns().stream().filter((item) -> item.getCode().toLowerCase().equals(columnCode.toLowerCase())).findFirst(); + return columnsOpt.orElse(null); + } + + @Override + public DatabaseObjectView clone() { + DatabaseObjectView view = new DatabaseObjectView(); + view.setId(this.getId()); + view.setCode(this.getCode()); + view.setName(this.getName()); + view.setBusinessObjectId(getBusinessObjectId()); + if (this.getHasNameRule()) + view.setDboTableNameRule((DBOTableNameRule) this.getDboTableNameRule().clone()); + view.setDescription(this.getDescription()); + view.setType(this.getType()); + view.setVersion(this.getVersion()); + view.setI18nObject(this.isI18nObject); + view.setLastModifiedTime(this.getLastModifiedTime()); + + view.setDefination(this.getDefination()); + if (this.getColumns() != null && this.getColumns().size() > 0) { + for (DatabaseObjectColumn column : this.getColumns()) { + view.getColumns().add(column.clone()); + } + } + if (this.getMultiLanguageColumns() != null && this.getMultiLanguageColumns().size() > 0) { + view.getMultiLanguageColumns().addAll(this.getMultiLanguageColumns()); + } + if (this.getDefinationWithDbType() != null && this.getDefinationWithDbType().size() > 0) { + for (ViewDefination defination : this.getDefinationWithDbType()) { + view.getDefinationWithDbType().add((ViewDefination) defination.clone()); + } + } + return view; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectViewDefinition.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectViewDefinition.java new file mode 100644 index 0000000000000000000000000000000000000000..e33122681328dc0601eed0fc508773240e2589f8 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DatabaseObjectViewDefinition.java @@ -0,0 +1,37 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 数据库对象视图函数存储过程定义实体 + * + * @author liu_wei + */ +@Data +public class DatabaseObjectViewDefinition implements Serializable { + /** + * 数据库类型 + */ + public String dbType; + + /** + * 定义 + */ + public String definition; +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DbType.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DbType.java new file mode 100644 index 0000000000000000000000000000000000000000..a69b3863c66adbc6c8b56ad08a7679f74a126fd2 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DbType.java @@ -0,0 +1,69 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +/** + * 支持的数据库类型 + * + * @author liu_wei + */ + +public enum DbType { + + /** + * PgSQL + */ + PgSQL, + + /** + * SQLServer + */ + SQLServer, + + /** + * Oracle + */ + Oracle, + + /** + * 达梦 + */ + DM, + + /** + * 瀚高 + */ + HighGo, + + /** + * MySQL + */ + MySQL, + + /** + * 神通 + */ + Oscar, + + /** + * 人大金仓 + */ + Kingbase, + + /** + * DB2 + */ + DB2 +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DboDeployResultInfo.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DboDeployResultInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..699d9dda1e6cbd79327bfa73afd67ed0398680bd --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DboDeployResultInfo.java @@ -0,0 +1,50 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +import java.util.Map; + +/** + * DBO部署结果类 + * + * @author liu_wei + */ +public class DboDeployResultInfo { + /** + * 整体部署结果 + */ + private Boolean isDeploySuccess; + + /** + * Dbo明细部署结果 + */ + private Map deployResult; + + public Boolean getDeploySuccess() { + return isDeploySuccess; + } + + public void setDeploySuccess(Boolean deploySuccess) { + isDeploySuccess = deploySuccess; + } + + public Map getDeployResult() { + return deployResult; + } + + public void setDeployResult(Map deployResult) { + this.deployResult = deployResult; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DboTableChangeInfo.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DboTableChangeInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..8551b58e901c777af3ea2238464ef52d983e7253 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DboTableChangeInfo.java @@ -0,0 +1,103 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +import lombok.Data; + +import java.util.List; + +/** + * Dbo增量实体类 + * + * @author liu_wei + */ +@Data +public class DboTableChangeInfo { + + /** + * 增加的列 + */ + private List addedColumn; + + /** + * 增加的索引 + */ + private List addedIndex; + + /** + * 变化的索引 + */ + private List changedIndex; + + /** + * 变化的列 + */ + private List changedColumn; + + /** + * 变化的列详细信息 + */ + private List changedColumnOperations; + + /** + * Dbo表命名规则 + */ + private DBOTableNameRule dboTableNameRule; + + /** + * 描述 + */ + private String description; + + /** + * 是否为历史表 + */ + private boolean isSynHis; + + /** + * 是否使用TimeStamp + */ + private boolean isUsingTimeStamp; + + /** + * 新增的多语列 + */ + private List newMulityLanguageColumns; + + /** + * 主键名 + */ + private String pkName; + + /** + * 主键 + */ + private List primaryKey; + + /** + * 名称 + */ + private String name; + + /** + * 是否为多语DBO + */ + private boolean isI18nObject; + + /** + * 版本 + */ + private String version; +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DimensionStrategyWithOrder.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DimensionStrategyWithOrder.java new file mode 100644 index 0000000000000000000000000000000000000000..fee555770bf2cb83d3c21b8730995d76d704e4ce --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DimensionStrategyWithOrder.java @@ -0,0 +1,46 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +import io.iec.edp.caf.dimension.api.entity.DimensionEntity; +import lombok.Data; + +import java.io.Serializable; + +/** + * 带顺序的维度策略 + * + * @author liu_wei + */ +@Data +public class DimensionStrategyWithOrder implements Serializable { + /** + * 维度策略 + */ + private DimensionEntity dimensionEntity; + + /** + * 顺序 + */ + private int order; + + @Override + public Object clone() { + DimensionStrategyWithOrder strategy = new DimensionStrategyWithOrder(); + strategy.setOrder(this.getOrder()); + strategy.setDimensionEntity((DimensionEntity) this.getDimensionEntity().clone()); + return strategy; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DimensionValueEntity.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DimensionValueEntity.java new file mode 100644 index 0000000000000000000000000000000000000000..799302c50a59b4dc74287cd86cea202e3d751e1a --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/DimensionValueEntity.java @@ -0,0 +1,30 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +import lombok.Data; + +import java.util.List; + +/** + * 维度值 + * + * @author liu_wei + */ +@Data +public class DimensionValueEntity { + + private List CurrentValues; +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/GspDatabaseObject.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/GspDatabaseObject.java new file mode 100644 index 0000000000000000000000000000000000000000..c663956cb850944e844371cdc32ec0c0c354bf15 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/GspDatabaseObject.java @@ -0,0 +1,201 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +import lombok.Data; + +import javax.persistence.*; +import java.time.LocalDateTime; + +/** + * 数据库对象信息实体 + * + * @author liu_wei + */ +@Data +@Entity +@Table(name = "GSPDatabaseObject") +public class GspDatabaseObject { + /** + * 唯一标识 + */ + @Id + @Column(length = 36) + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public String getIsFiscalTable() { + return isFiscalTable; + } + + public void setIsFiscalTable(String isFiscalTable) { + this.isFiscalTable = isFiscalTable; + } + + public String getIsI18NObject() { + return isI18NObject; + } + + public void setIsI18NObject(String isI18NObject) { + this.isI18NObject = isI18NObject; + } + + public String getTenantIDColumnCode() { + return tenantIDColumnCode; + } + + public void setTenantIDColumnCode(String tenantIDColumnCode) { + this.tenantIDColumnCode = tenantIDColumnCode; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public void setContent(String content) { + this.content = content; + } + + public String getBusinessObjectId() { + return businessObjectId; + } + + public void setBusinessObjectId(String businessObjectId) { + this.businessObjectId = businessObjectId; + } + + public LocalDateTime getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(LocalDateTime createdTime) { + this.createdTime = createdTime; + } + + public LocalDateTime getLastModifiedTime() { + return lastModifiedTime; + } + + public void setLastModifiedTime(LocalDateTime lastModifiedTime) { + this.lastModifiedTime = lastModifiedTime; + } + + + /** + * 编号 + */ + private String code; + + /** + * 名称 + */ + private String name; + + /** + * 类型 + */ + private int type; + + /** + * 是否年度表 + */ + private String isFiscalTable; + + /** + * 是否多语 + */ + private String isI18NObject; + + /** + * 租户标识字段编号 + */ + private String tenantIDColumnCode; + + /** + * 版本 + */ + private String version; + + /** + * 对象实体内容 + * 此处不能添加text注解,否则会出现content记录变成数字的错误 + */ + private String content; + + @Lob + @Column(columnDefinition = "TEXT") + public String getContent() { + return content; + } + + /** + * 业务对象字段关联属性 + */ + private String businessObjectId; + + /** + * 表规则Id + */ + private String ruleId; + + /** + * 表规则Code + */ + private String ruleCode; + + /** + * 创建时间 + */ + private LocalDateTime createdTime = LocalDateTime.MIN; + /** + * 最后修改时间 + */ + private LocalDateTime lastModifiedTime = LocalDateTime.MIN; +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/GspDatabaseObjectDT.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/GspDatabaseObjectDT.java new file mode 100644 index 0000000000000000000000000000000000000000..4212f04da60121a76ed8a9b5e3209afa58707c65 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/GspDatabaseObjectDT.java @@ -0,0 +1,88 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import java.time.LocalDateTime; + +/** + * @author liu_wei + */ +@Data +@Entity +@Table(name = "GSPDatabaseObjectVersion") +public class GspDatabaseObjectDT { + + /** + * 唯一标识 + */ + @Id + @Column(length = 36) + private String id; + + /** + * 编号 + */ + private String code; + + /** + * 名称 + */ + private String name; + + /** + * 类型 + */ + private int type; + + /** + * 对象实体内容 + */ + private String content; + + /** + * 业务对象字段关联属性 + */ + private String businessObjectId; + + /** + * 版本 + */ + private String version; + + /** + * 创建人 + */ + private String creator; + + /** + * 最后修改人 + */ + private String lastModifier; + + /** + * 创建时间 + */ + private LocalDateTime createdTime = LocalDateTime.MIN; + /** + * 最后修改时间 + */ + private LocalDateTime lastModifiedTime = LocalDateTime.MIN; +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/ScopeType.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/ScopeType.java new file mode 100644 index 0000000000000000000000000000000000000000..eafdcb41c7d8b44f08aed4a60f5efcb118bdf468 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/ScopeType.java @@ -0,0 +1,32 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +/** + * @author liu_wei + */ + +public enum ScopeType { + + /** + * 会话级 + */ + Session, + + /** + * 事务级 + */ + Transactional +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/TempTableContext.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/TempTableContext.java new file mode 100644 index 0000000000000000000000000000000000000000..82c526cd441d220d8e8ce1425d48d087bcb123f1 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/TempTableContext.java @@ -0,0 +1,26 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +import lombok.Data; + +/** + * @author liu_wei + */ +@Data +public class TempTableContext { + + private String tableName; +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/ViewDefination.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/ViewDefination.java new file mode 100644 index 0000000000000000000000000000000000000000..90949f6ba6f75f56aedd9c2de23e6cc0b842bf40 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/entity/ViewDefination.java @@ -0,0 +1,39 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.entity; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author liu_wei + */ +@Data +public class ViewDefination implements Serializable { + @JsonProperty("DbType") + private String dbType; + + private String defination; + + @Override + public Object clone() { + ViewDefination viewDefination = new ViewDefination(); + viewDefination.setDbType(this.getDbType()); + viewDefination.setDefination(this.getDefination()); + return viewDefination; + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/exception/DboException.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/exception/DboException.java new file mode 100644 index 0000000000000000000000000000000000000000..0226a3da47f15907db1ee650d2ebdad520a2e1a3 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/exception/DboException.java @@ -0,0 +1,38 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.exception; + +/** + * @author : liu_wei + * @date : 2021-09-08 09:49 + **/ +public class DboException extends RuntimeException { + + public DboException() { + + } + + public DboException(String message) { + super(message); + } + + public DboException(String message, Throwable cause) { + super(message, cause); + } + + public DboException(Throwable cause) { + super(cause); + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/helper/DboConfigurationHelper.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/helper/DboConfigurationHelper.java new file mode 100644 index 0000000000000000000000000000000000000000..7a976197c4903244f1befd7f07827a5588f41eec --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/helper/DboConfigurationHelper.java @@ -0,0 +1,143 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.helper; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import io.iec.edp.caf.databaseobject.api.configuration.DatabaseObjectConfiguration; +import io.iec.edp.caf.databaseobject.api.configuration.FileUtils; +import io.iec.edp.caf.databaseobject.api.configuration.ObjectNameMaxLengthConfiguration; +import io.iec.edp.caf.databaseobject.api.configuration.TableNameConfiguration; +import io.iec.edp.caf.databaseobject.api.configuration.datatype.DatabaseObjectDataTypeConfiguration; +import io.iec.edp.caf.databaseobject.api.configuration.deplpyconfig.DboDeployConfiguration; +import io.iec.edp.caf.databaseobject.api.configuration.funcmapping.DatabaseFuncConfiguration; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * 配置帮助类 + * + * @author liu_wei + */ +public class DboConfigurationHelper { + ObjectMapper objectMapper = new ObjectMapper(); + + /** + * 构造函数 + */ + public DboConfigurationHelper() { + objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + /** + * 获取表名配置 + * + * @param filePath 路径 + * @param sectionName 节点 + * @return 表名配置列表 + * @throws IOException 异常 + */ + public List getTableNameConfigurations(String filePath, String sectionName) throws IOException { + String fileContent = FileUtils.fileRead(filePath); + JsonNode objectNode = objectMapper.readTree(fileContent); + String configuration = objectNode.findValue(sectionName).toString(); + return objectMapper.readValue(configuration, new TypeReference>() { + }); + } + + /** + * 获取名称最大长度配置 + * + * @param filePath 路径 + * @param sectionName 节点 + * @return 表名配置列表 + * @throws IOException 异常 + */ + public ObjectNameMaxLengthConfiguration getObjectNameMaxLengthConfiguration(String filePath, String sectionName) throws IOException { + String fileContent = FileUtils.fileRead(filePath); + JsonNode objectNode = objectMapper.readTree(fileContent); + String configuration = objectNode.findValue(sectionName).toString(); + return objectMapper.readValue(configuration, ObjectNameMaxLengthConfiguration.class); + } + + /** + * 获取数据库类型配置 + * + * @param filePath 路径 + * @param sectionName 节点 + * @return 表名配置列表 + * @throws IOException 异常 + */ + public ArrayList getDataTypeConfiguration(String filePath, String sectionName) throws IOException { + String fileContent = FileUtils.fileRead(filePath); + JsonNode objectNode = objectMapper.readTree(fileContent); + String configuration = objectNode.findValue(sectionName).toString(); + return objectMapper.readValue(configuration, new TypeReference>() { + }); + } + + /** + * 获取功能配置 + * + * @param filePath 路径 + * @param sectionName 节点 + * @return 表名配置列表 + * @throws IOException 异常 + */ + public ArrayList getFuncConfiguration(String filePath, String sectionName) throws IOException { + String fileContent = FileUtils.fileRead(filePath); + JsonNode objectNode = objectMapper.readTree(fileContent); + String configuration = objectNode.findValue(sectionName).toString(); + return objectMapper.readValue(configuration, new TypeReference>() { + }); + } + + /** + * 获取SQL反射配置 + * + * @param filePath 路径 + * @param sectionName 节点 + * @return 表名配置列表 + * @throws IOException 异常 + */ + public ArrayList getSqlReflectConfiguration(String filePath, String sectionName) throws IOException { + String fileContent = FileUtils.fileRead(filePath); + JsonNode objectNode = objectMapper.readTree(fileContent); + String configuration = objectNode.findValue(sectionName).toString(); + return objectMapper.readValue(configuration, new TypeReference>() { + }); + } + + /** + * 获取DBO部署配置 + * + * @param filePath 路径 + * @param sectionName 节点 + * @return 表名配置列表 + * @throws IOException 异常 + */ + public DboDeployConfiguration getDboDeployConfiguration(String filePath, String sectionName) throws IOException { + String fileContent = FileUtils.fileRead(filePath); + JsonNode objectNode = objectMapper.readTree(fileContent); + String configuration = objectNode.findValue(sectionName).toString(); + return objectMapper.readValue(configuration, DboDeployConfiguration.class); + } +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/service/IDatabaseObjectDeployService.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/service/IDatabaseObjectDeployService.java new file mode 100644 index 0000000000000000000000000000000000000000..074942270280a6b56efb9041af22bb2c19989643 --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/service/IDatabaseObjectDeployService.java @@ -0,0 +1,110 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.service; + +import io.iec.edp.caf.databaseobject.api.entity.AbstractDatabaseObject; +import io.iec.edp.caf.databaseobject.api.entity.DBInfo; +import io.iec.edp.caf.databaseobject.api.entity.DboDeployResultInfo; +import io.iec.edp.caf.databaseobject.api.entity.DimensionValueEntity; + +import java.util.List; +import java.util.Map; + +/** + * DBO部署服务 + * + * @author zhaoleitr + */ +public interface IDatabaseObjectDeployService { + + /** + * 部署单个DBO + * + * @param databaseObject DBO实体 + * @param dimensionInfo 维度信息 + */ + void deployDatabaseObject(AbstractDatabaseObject databaseObject, Map dimensionInfo); + + /** + * 部署单个DBO到指定服务单元 + * + * @param databaseObject DBO实体 + * @param dimensionInfo 维度信息 + * @param su 服务单元 + */ + void deployDatabaseObject(AbstractDatabaseObject databaseObject, Map dimensionInfo, String su); + + /** + * 部署多个DBO + * + * @param databaseObjects DBO实体列表 + * @param dimensionValue 维度信息 + * @return 部署结果 + */ + DboDeployResultInfo deployDatabaseObjects(List databaseObjects, Map dimensionValue); + + /** + * 部署多个DBO到指定服务单元 + * + * @param databaseObjects DBO实体列表 + * @param dimensionValue 维度信息 + * @param su 服务单元 + * @return 部署结果 + */ + DboDeployResultInfo deployDatabaseObjects(List databaseObjects, Map dimensionValue, String su); + + /** + * 部署指定路径下DBO + * + * @param dboPath dbo存放路径 + * @param dimensionInfo 维度信息 + */ + void deployDboList(String dboPath, Map dimensionInfo); + + /** + * 部署指定路径下DBO + * + * @param dboPath dbo存放路径 + * @param dimensionInfos 维度信息 + */ + void deployDboWithDimensionList(String dboPath, Map> dimensionInfos); + + /** + * 部署指定路径下DBO到指定库 + * + * @param dboPath dbo存放路径 + * @param dimensionInfo 维度信息 + * @param dbInfo 数据库信息 + */ + void deployDboList(String dboPath, Map dimensionInfo, DBInfo dbInfo); + + /** + * 部署指定路径下DBO到指定库 + * + * @param dboPath dbo存放路径 + * @param dimensionInfos 维度信息 + * @param dbInfo 数据库信息 + */ + void deployDboWithDimensionList(String dboPath, Map> dimensionInfos, DBInfo dbInfo); + + + /** + * 根据新语言,修改已有的多语DBO + * + * @param languages 语言 + */ + void modifyI18nDatabaseObjectsByNewLanguage(List languages); + +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/service/IDatabaseObjectDtService.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/service/IDatabaseObjectDtService.java new file mode 100644 index 0000000000000000000000000000000000000000..9167dcf6a0fd3f6ef56fbb8a447e2459aefa495c --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/service/IDatabaseObjectDtService.java @@ -0,0 +1,105 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.service; + +import io.iec.edp.caf.databaseobject.api.entity.AbstractDatabaseObject; + + +/** + * @author liu_wei + */ +public interface IDatabaseObjectDtService { + + /** + * 获取设计时DBO + * + * @param dboId id + * @return DBO + */ + AbstractDatabaseObject getDtDatabaseObject(String dboId); + + /** + * 获取设计时DBO + * + * @param dboId id + * @param su 服务单元 + * @return DBO + */ + AbstractDatabaseObject getDtDatabaseObject(String dboId, String su); + + /** + * 获取设计时DBO + * + * @param dboCode code + * @return DBO + */ + AbstractDatabaseObject getDtDatabaseObjectByCode(String dboCode); + + /** + * 获取设计时DBO + * + * @param dboCode code + * @param su 服务单元 + * @return DBO + */ + AbstractDatabaseObject getDtDatabaseObjectByCode(String dboCode, String su); + + /** + * 保存 + * + * @param databaseObject DBO + */ + void saveDtDatabaseObject(AbstractDatabaseObject databaseObject); + + /** + * 保存 + * + * @param databaseObject DBO + * @param su 服务单元 + */ + void saveDtDatabaseObject(AbstractDatabaseObject databaseObject, String su); + + /** + * 删除 + * + * @param dboId id + */ + void deleteDtDatabaseObject(String dboId); + + /** + * 删除 + * + * @param dboId id + * @param su 服务单元 + */ + void deleteDtDatabaseObject(String dboId, String su); + + /** + * 根据Id判断设计时DBO是否存在 + * + * @param dboId id + * @return 结果 + */ + boolean isExistDatabaseObjectDt(String dboId); + + /** + * 根据Id判断设计时DBO是否存在 + * + * @param dboId id + * @param su 服务单元 + * @return 结果 + */ + boolean isExistDatabaseObjectDt(String dboId, String su); +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/service/IDatabaseObjectExportService.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/service/IDatabaseObjectExportService.java new file mode 100644 index 0000000000000000000000000000000000000000..fc2a85ed24a9aaeb48ccd7a4f9c2245566d064ac --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/service/IDatabaseObjectExportService.java @@ -0,0 +1,61 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.service; + +import io.iec.edp.caf.databaseobject.api.entity.AbstractDatabaseObject; +import io.iec.edp.caf.databaseobject.api.entity.DBInfo; + +import java.util.List; + +/** + * @author liu_wei + */ +public interface IDatabaseObjectExportService { + + /** + * 是否在IDE中暴露数据库导出DBO的功能 + * + * @return 是否 + */ + boolean isExportOpen(); + + /** + * 获取当前数据库所有表名 + * + * @return 表名列表 + */ + List getAllTablesName(DBInfo info); + + /** + * 根据表名获取DBO实体 + * + * @param tablesName 表名列表 + * @param businessObjectId 业务对象Id + * @param info 数据库连接信息 + * @return dbo实体列表 + */ + List getDatabaseObjectsByTablesName(List tablesName, String businessObjectId, DBInfo info); + + /** + * 根据表名获取DBO实体 + * + * @param tableName 表名 + * @param dboName DBO名 + * @param businessObjectId 业务对象Id + * @param info 数据库连接信息 + * @return DBO实体 + */ + AbstractDatabaseObject getDatabaseObjectByTableName(String tableName, String dboName, String businessObjectId, DBInfo info); +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/service/IDatabaseObjectRtService.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/service/IDatabaseObjectRtService.java new file mode 100644 index 0000000000000000000000000000000000000000..de304f4c667ac25abb4b890c873a6f59ee28b5ff --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/service/IDatabaseObjectRtService.java @@ -0,0 +1,270 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.service; + + +import io.iec.edp.caf.databaseobject.api.entity.AbstractDatabaseObject; +import io.iec.edp.caf.databaseobject.api.entity.DBOTableNameRule; +import io.iec.edp.caf.databaseobject.api.entity.DatabaseObjectTable; +import io.iec.edp.caf.databaseobject.api.entity.TempTableContext; +import io.iec.edp.caf.dimension.api.entity.DimensionEntity; +import org.springframework.web.bind.annotation.RequestBody; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import java.sql.SQLException; +import java.util.*; +import java.util.List; + +/** + * DBO运行时服务接口 + * + * @author zhaoleitr + */ +@Path("/") +@Produces(MediaType.APPLICATION_JSON) +public interface IDatabaseObjectRtService { + + /** + * 获取默认DBO实体列表 + * + * @return DBO实体列表 + */ + @GET + List getDatabaseObjectList(); + + /** + * 获取默认DBO实体列表 + * + * @param su 服务单元 + * @return DBO实体列表 + */ + //List getDatabaseObjectList(String su); + + /** + * 根据ID获取数据库对象表详细信息 + * + * @param dboId 数据库对象ID + * @return 数据库对象实体 + * 返回的数据库对象实体是基类,需要转成具体的类型,表转成DatabaseObjectTable,视图、函数、存储过程转成DatabaseObjectSPVF + */ + @GET + @Path(value = "/{dboId}") + AbstractDatabaseObject getDatabaseObject(@PathParam("dboId") String dboId); + + /** + * 根据ID获取数据库对象表详细信息 + * + * @param dboId 数据库对象Id + * @param su 服务单元 + * @return 数据库对象实体 + */ + AbstractDatabaseObject getDatabaseObject(String dboId, String su); + + /** + * 清空全部缓存 + */ + @POST + @Path("/cache/clear") + void clearDatabaseObjectContent(); + + /** + * 根据dboIds清空缓存 + * + * @param ids 数据库对象ID列表 + */ + @POST + @Path("/cache/clear/ids") + void clearDatabaseObjectContentByIds(@RequestBody String ids); + + /** + * 根据id清理缓存 + * + * @param id 缓存id + */ + void clearDatabaseObjectContentById(String id); + + /** + * 添加DBO缓存 + * + * @param databaseObject DBO对象 + */ + void addDatabaseObjectContent(AbstractDatabaseObject databaseObject); + + /** + * 保存数据库对象表 + * + * @param databaseObject 数据库对象 + */ + void saveDatabaseObject(AbstractDatabaseObject databaseObject); + + /** + * 是否存在数据库对象 + * + * @param dboId 数据库对象ID + * @return 是否存在数据库对象,存在,返回true,否则返回false + */ + boolean isExistDatabaseObject(String dboId); + + /** + * 获取多语的数据库对象 + * + * @return 数据库对象表列表 + */ + List getI18nObjectTables(); + + /** + * 根据数据库对象编号获取数据库对象 + * + * @param dboCode 数据库对象编号 + * @return 数据库对象列表 + */ + AbstractDatabaseObject getDatabaseObjectByCode(String dboCode); + + /** + * 根据数据库对象编号获取数据库对象 + * + * @param dboCode 数据库对象编号 + * @param su 服务单元 + * @return 数据库对象列表 + */ + AbstractDatabaseObject getDatabaseObjectByCode(String dboCode, String su); + + /** + * 根据数据库对象ID获取数据库对象编号 + * + * @param dboId 数据库对象ID + * @return 数据库对象编号 + */ + String getDatabaseObjectCodeById(String dboId); + + /** + * 根据维度值获取表名 + * + * @param dboId 数据库对象ID + * @param dimensionInfo 维度信息 + * @return 表名 + */ + String getTableNameWithDimensionValue(String dboId, Map dimensionInfo); + + /** + * 根据多个维护获取dbo的多个表名(例如多年度) + * + * @param dboId 数据库对象ID + * @param dimensionInfo 多个维度信息 + * @return 一组表名 + */ + List getTableNamesWithDimensionValues(String dboId, Map> dimensionInfo); + + /** + * 根据维度值获取表名 + * + * @param dboCodes 数据库对象ID列表 + * @param dimensionInfo 维度信息 + * @return 表名 + */ + List getTableNamesWithDimensionValue(List dboCodes, Map dimensionInfo); + + + /** + * 根据规则获取数据库对象表 + * + * @param ruleCode 规则编号 + * @return 数据库对象列表 + */ + List getDatabaseObjectByRule(String ruleCode); + + /** + * 根据Dbo编号获取物理表列集合 + * + * @param dboCode dbo编号 + * @return 物理表列集合 + */ + List getTableColumnNamesByCode(String dboCode); + + + /** + * 根据Dbo编号获取物理表列集合 + * + * @param dboCodes dbo编号列表 + * @return 编号和列集合的map + */ + Map> getTableColumnNamesByCode(List dboCodes); + + /** + * 根据传入的表ID和字段ID返回字段编号,如果启用多语,字段后根据当前语言拼上多语后缀 + * + * @param tableId 表ID + * @param columnIds 字段ID列表 + * @return 字段编号列表 + */ + List getColumnCodeWithI18n(String tableId, List columnIds); + + /** + * 根据传入的表ID和字段ID返回字段编号,如果启用多语,会返回所有的多语字段 + * + * @param tableId 表ID + * @param columnIds 字段ID列表 + * @return 字段编号列表 + */ + Map> getAllColumnCodeWithI18n(String tableId, List columnIds); + + /** + * 根据业务对象字段关联属性获取数据库对象 + * + * @param businessObjectId 业务对象ID + * @return 数据库对象列表 + */ + List getDatabaseObjectByBOID(String businessObjectId); + + /** + * 删除数据库对象 + * + * @param dboId 数据库对象ID + */ + void deleteDatabaseObject(String dboId); + + /** + * 根据数据库对象ID获取维度实体 + * + * @param dboId dboId + * @return 维度实体 + */ + List getDimensionListByDboId(String dboId); + + /** + * 根据表名列表判断表是否存在 + * + * @param tableNames 表名列表 + * @return 表和是否存在的map + */ + Map isTablesExist(List tableNames); + + /** + * 根据dboId创建临时表 + * + * @param dboId Id + * @return 临时表上下文 + */ + TempTableContext creatTempTables(String dboId); + + /** + * 临时表删除 + * + * @param context 临时表上下文 + * @param dboId Id + */ + void dropTempTable(TempTableContext context, String dboId); +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/service/IDatabaseObjectService.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/service/IDatabaseObjectService.java new file mode 100644 index 0000000000000000000000000000000000000000..73591965e7e340e461465e1087a96196eb322e1a --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/service/IDatabaseObjectService.java @@ -0,0 +1,99 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.service; + +import io.iec.edp.caf.databaseobject.api.entity.AbstractDatabaseObject; +import io.iec.edp.caf.databaseobject.api.entity.DBInfo; +import io.iec.edp.caf.databaseobject.api.entity.DatabaseObjectInfo; +import io.iec.edp.caf.databaseobject.api.entity.DatabaseObjectTable; + +import java.util.List; + +/** + * BDO服务接口 + * + * @author zhaoleitr + */ +public interface IDatabaseObjectService { + /** + * 根据全路径获取数据库对象详细信息 + * + * @param fullPath 全路径 + * @return 数据库对象详细信息 + */ + AbstractDatabaseObject getDatabaseObject(String fullPath); + + /** + * 根据全路径获取数据库对象详细信息列表 + * + * @param fullPath 全路径 + * @return 数据库对象详细信息列表 + */ + List getDatabaseObjectListRecursivly(String fullPath); + + + /** + * 根据文件夹路径获取所有dbo + * + * @param fullPath 文件夹路径 + * @return dbo列表 + */ + List getDatabaseObjectList(String fullPath); + + /** + * 保存DBO + * + * @param fullPath 完整路径 + * @param databaseObject dbo实体 + */ + void saveDatabaseObjectTableWithoutFileName(String fullPath, DatabaseObjectTable databaseObject); + + /** + * 判断dbo是否存在 + * + * @param fullPath 完整路径 + * @param code code + * @param dboId id + * @return 是否 + */ + boolean isExistDatabaseObject(String fullPath, String code, String dboId); + + /** + * 获取DBO文件相关信息,不存在返回null + * + * @param fullPath 完整路径 + * @param code code + * @param dboId id + * @return DBO文件存储信息 + */ + DatabaseObjectInfo getDatabaseObjectInfo(String fullPath, String code, String dboId); + + /** + * 根据路径和id获取dbo实体 + * + * @param fullPath 完整路径 + * @param databaseObjectId id + * @return dbo实体 + */ + AbstractDatabaseObject getDatabaseObjectById(String fullPath, String databaseObjectId); + + /** + * 获取当前环境数据库信息 + * + * @return 当前环境的数据库信息 + */ + DBInfo getDbInfo(); + +} diff --git a/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/service/IDatabaseObjectTempTableService.java b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/service/IDatabaseObjectTempTableService.java new file mode 100644 index 0000000000000000000000000000000000000000..0b454bb80d4d10fb996d671e86c6bdaa4e9bf5ae --- /dev/null +++ b/caf-database-object-api/src/main/java/io/iec/edp/caf/databaseobject/api/service/IDatabaseObjectTempTableService.java @@ -0,0 +1,43 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.api.service; + +import io.iec.edp.caf.databaseobject.api.entity.ScopeType; +import io.iec.edp.caf.databaseobject.api.entity.TempTableContext; +import io.iec.edp.caf.database.Database; + +/** + * @author liu_wei + */ +public interface IDatabaseObjectTempTableService { + + /** + * 创建固定列临时表 + * @param database 数据库连接 + * @param type 临时表类型 + * @param dboCode dboCode + * @return 临时表信息 + */ + TempTableContext createFixedTable(Database database, ScopeType type, String dboCode); + + /** + * 创建非固定列临时表 + * @param database 数据库连接 + * @param type 临时表类型 + * @param dboCode dboCode + * @return 临时表信息 + */ + TempTableContext createNoFixedTable(Database database, ScopeType type, String dboCode); +} diff --git a/caf-database-object-api/src/test/java/ConfigurationgLoaderTest.java b/caf-database-object-api/src/test/java/ConfigurationgLoaderTest.java new file mode 100644 index 0000000000000000000000000000000000000000..1753d04498d2d82ff4d4e32dbac2eb3e66847a56 --- /dev/null +++ b/caf-database-object-api/src/test/java/ConfigurationgLoaderTest.java @@ -0,0 +1,27 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +import org.junit.Test; + +public class ConfigurationgLoaderTest { + @Test + public void GetMaxLengthConfigTest() { +// try { +// ObjectNameMaxLengthLoader.GetDatabaseObjectConfiguration(); +// } c +// atch (IOException e) { +// e.printStackTrace(); +// }printStackTrace + } +} diff --git a/caf-database-object-spi/pom.xml b/caf-database-object-spi/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..4ca23993991f73ba6e1a959cb53e553f33c0d285 --- /dev/null +++ b/caf-database-object-spi/pom.xml @@ -0,0 +1,36 @@ + + + + + + caf-database-object + io.iec.edp + 0.2.10 + + 4.0.0 + jar + caf-database-object-spi + + + io.iec.edp + caf-database-object-api + ${project.version} + + + + + diff --git a/caf-database-object-spi/src/main/java/io/iec/edp/caf/databaseobject/spi/ITableNameRuleManager.java b/caf-database-object-spi/src/main/java/io/iec/edp/caf/databaseobject/spi/ITableNameRuleManager.java new file mode 100644 index 0000000000000000000000000000000000000000..b9f601f80db36d7246965a9cf74f1b61d84c0bf2 --- /dev/null +++ b/caf-database-object-spi/src/main/java/io/iec/edp/caf/databaseobject/spi/ITableNameRuleManager.java @@ -0,0 +1,32 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.databaseobject.spi; + +import io.iec.edp.caf.databaseobject.api.entity.DBOTableNameRule; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @author liu_wei + */ +public interface ITableNameRuleManager { + + String getTableName(String tableName, DBOTableNameRule rule, Map dimensionInfo); + + + List getTableNames(String tableName, DBOTableNameRule rule, Map> dimensioinInfo); +} diff --git a/caf-dimension-api/pom.xml b/caf-dimension-api/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..0c6e80cc4588217c8d513dead24674d2402fa003 --- /dev/null +++ b/caf-dimension-api/pom.xml @@ -0,0 +1,29 @@ + + + + + + caf-database-object + io.iec.edp + 0.2.10 + + 4.0.0 + jar + caf-dimension-api + + + diff --git a/caf-dimension-api/src/main/java/io/iec/edp/caf/dimension/api/entity/DimensionEntity.java b/caf-dimension-api/src/main/java/io/iec/edp/caf/dimension/api/entity/DimensionEntity.java new file mode 100644 index 0000000000000000000000000000000000000000..ae929f09529a7bf28e423b0bf32ac69df9479c4a --- /dev/null +++ b/caf-dimension-api/src/main/java/io/iec/edp/caf/dimension/api/entity/DimensionEntity.java @@ -0,0 +1,41 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.dimension.api.entity; + + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author liu_wei + */ +@Data +public class DimensionEntity implements Serializable { + private String Id; + + private String Code; + + private String Name; + + @Override + public Object clone() { + DimensionEntity dimension = new DimensionEntity(); + dimension.setId(this.getId()); + dimension.setCode(this.getCode()); + dimension.setName(this.getName()); + return dimension; + } +} diff --git a/mvnw b/mvnw new file mode 100644 index 0000000000000000000000000000000000000000..5551fde8e7dba1e37a1821e8b26374893e2a9e2e --- /dev/null +++ b/mvnw @@ -0,0 +1,286 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + wget "$jarUrl" -O "$wrapperJarPath" + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + curl -o "$wrapperJarPath" "$jarUrl" + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000000000000000000000000000000000000..e5cfb0ae9eab80c314b7d79c164d4a00772824b8 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,161 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" +FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + echo Found %WRAPPER_JAR% +) else ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" + echo Finished downloading %WRAPPER_JAR% +) +@REM End of extension + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..05037860a9da1dbe83164e372aff4eb563405523 --- /dev/null +++ b/pom.xml @@ -0,0 +1,65 @@ + + + + + 4.0.0 + + caf-database-object-api + caf-dimension-api + caf-database-object-spi + + + + io.iec.edp + caf-boot-parent + 0.3.7 + + + caf-database-object + pom + 0.2.10 + + + + + org.openclover + clover-maven-plugin + + false + + + + org.codehaus.mojo + versions-maven-plugin + + false + + + + + + + + caf-snapshots-repo + https://repos.iec.io/repository/maven-caf-snapshots/ + + + caf-releases-repo + https://repos.iec.io/repository/maven-caf-releases/ + + + +