/*
* Copyright 2006-2023 www.anyline.org
*
* 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 org.anyline.data.adapter.init;
import org.anyline.adapter.DataReader;
import org.anyline.adapter.DataWriter;
import org.anyline.adapter.EntityAdapter;
import org.anyline.adapter.KeyAdapter;
import org.anyline.data.adapter.DriverActuator;
import org.anyline.data.adapter.DriverAdapter;
import org.anyline.data.cache.PageLazyStore;
import org.anyline.data.entity.Join;
import org.anyline.data.listener.DDListener;
import org.anyline.data.listener.DMListener;
import org.anyline.data.metadata.TypeMetadataAlias;
import org.anyline.data.param.Config;
import org.anyline.data.param.ConfigParser;
import org.anyline.data.param.ConfigStore;
import org.anyline.data.param.init.DefaultConfigStore;
import org.anyline.data.prepare.*;
import org.anyline.data.prepare.auto.TablePrepare;
import org.anyline.data.prepare.auto.TextPrepare;
import org.anyline.data.prepare.auto.init.DefaultTablePrepare;
import org.anyline.data.prepare.auto.init.DefaultTextPrepare;
import org.anyline.data.prepare.auto.init.VirtualTablePrepare;
import org.anyline.data.prepare.xml.XMLPrepare;
import org.anyline.data.run.*;
import org.anyline.data.runtime.DataRuntime;
import org.anyline.data.util.CommandParser;
import org.anyline.data.util.DataSourceUtil;
import org.anyline.entity.*;
import org.anyline.entity.authorize.Privilege;
import org.anyline.entity.authorize.Role;
import org.anyline.entity.authorize.User;
import org.anyline.entity.generator.GeneratorConfig;
import org.anyline.entity.generator.PrimaryGenerator;
import org.anyline.exception.AnylineException;
import org.anyline.exception.CommandException;
import org.anyline.exception.CommandQueryException;
import org.anyline.exception.CommandUpdateException;
import org.anyline.metadata.*;
import org.anyline.metadata.graph.EdgeTable;
import org.anyline.metadata.graph.VertexTable;
import org.anyline.metadata.refer.MetadataFieldRefer;
import org.anyline.metadata.refer.MetadataReferHolder;
import org.anyline.metadata.type.DatabaseType;
import org.anyline.metadata.type.TypeMetadata;
import org.anyline.metadata.type.init.StandardTypeMetadata;
import org.anyline.proxy.CacheProxy;
import org.anyline.proxy.ConvertProxy;
import org.anyline.proxy.EntityAdapterProxy;
import org.anyline.proxy.InterceptorProxy;
import org.anyline.util.*;
import org.anyline.util.regular.Regular;
import org.anyline.util.regular.RegularUtil;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.util.*;
/**
* SQL生成 子类主要实现与分页相关的SQL 以及delimiter
*/
public abstract class AbstractDriverAdapter implements DriverAdapter {
protected DMListener dmListener;
protected DDListener ddListener;
protected PrimaryGenerator primaryGenerator;
protected DriverActuator actuator;
protected DMListener getListener() {
return dmListener;
}
public void setListener(DMListener listener) {
this.dmListener = listener;
}
public DMListener getDMListener() {
return this.dmListener;
}
public void setListener(DDListener listener) {
this.ddListener = listener;
}
public DDListener getDDListener() {
return this.ddListener;
}
public void setGenerator(PrimaryGenerator generator) {
this.primaryGenerator = generator;
}
public PrimaryGenerator getPrimaryGenerator() {
return primaryGenerator;
}
protected String delimiterFr = "";
protected String delimiterTo = "";
//拼写兼容 下划线空格兼容
protected static Map<String, String> spells = new HashMap<>();
protected Map<Class<?>, MetadataFieldRefer> refers = new HashMap<>();
//根据名称定位数据类型
protected LinkedHashMap<String, TypeMetadata> alias = new LinkedHashMap();
static {
for(StandardTypeMetadata type: StandardTypeMetadata.values()) {
String name = type.name().toUpperCase();//变量名
String standard = type.getName().toUpperCase(); //标准SQL类型名
spells.put(name, standard);
if(name.contains(" ")) {
spells.put(name.replace(" ", "_"), standard);
}
if(name.contains("_")) {
spells.put(name.replace("_", " "), standard);
}
if(standard.contains(" ")) {
spells.put(standard.replace(" ", "_"), standard);
}
if(standard.contains("_")) {
spells.put(standard.replace("_", " "), standard);
}
}
}
@Override
public void setActuator(DriverActuator actuator) {
this.actuator = actuator;
}
@Override
public DriverActuator getActuator() {
return actuator;
}
@Override
public String getDelimiterFr() {
return this.delimiterFr;
}
@Override
public String getDelimiterTo() {
return this.delimiterTo;
}
@Override
public void setDelimiter(String delimiter) {
if(BasicUtil.isNotEmpty(delimiter)) {
delimiter = delimiter.replaceAll("\\s","");
if(delimiter.length() == 1) {
this.delimiterFr = delimiter;
this.delimiterTo = delimiter;
}else{
this.delimiterFr = delimiter.substring(0,1);
this.delimiterTo = delimiter.substring(1,2);
}
}
}
/**
* 对应的兼容模式,有些数据库会兼容oracle或pg,需要分别提供两个JDBCAdapter或者直接依赖oracle/pg的adapter
* 参考DefaultJDBCAdapterUtil定位adapter的方法
* @return DatabaseType
*/
@Override
public DatabaseType compatible() {
return null;
}
public AbstractDriverAdapter() {
//当前数据库支持的数据类型,子类根据情况覆盖
for(StandardTypeMetadata type: StandardTypeMetadata.values()) {
reg(type, type.config());
List<DatabaseType> dbs = type.databaseTypes();
for(DatabaseType db:dbs) {
if(db == this.type()) {
//column type支持当前db
alias(type.getName(), type);
alias(type.name(), type);
break;
}
}
}
MetadataReferHolder.reg(type(), TypeMetadata.CATEGORY.CHAR, new TypeMetadata.Refer(0, 1, 1));
MetadataReferHolder.reg(type(), TypeMetadata.CATEGORY.TEXT, new TypeMetadata.Refer(1, 1, 1));
MetadataReferHolder.reg(type(), TypeMetadata.CATEGORY.BOOLEAN, new TypeMetadata.Refer( 1,1, 1));
MetadataReferHolder.reg(type(), TypeMetadata.CATEGORY.BYTES, new TypeMetadata.Refer(0, 1, 1));
MetadataReferHolder.reg(type(), TypeMetadata.CATEGORY.BLOB, new TypeMetadata.Refer(1,1,1));
MetadataReferHolder.reg(type(), TypeMetadata.CATEGORY.INT, new TypeMetadata.Refer(1, 1, 1));
MetadataReferHolder.reg(type(), TypeMetadata.CATEGORY.FLOAT, new TypeMetadata.Refer(1, 0, 0));
MetadataReferHolder.reg(type(), TypeMetadata.CATEGORY.DATE, new TypeMetadata.Refer(1, 1, 1));
MetadataReferHolder.reg(type(), TypeMetadata.CATEGORY.TIME, new TypeMetadata.Refer(1, 1, 1));
MetadataReferHolder.reg(type(), TypeMetadata.CATEGORY.DATETIME, new TypeMetadata.Refer( 1, 1, 1));
MetadataReferHolder.reg(type(), TypeMetadata.CATEGORY.TIMESTAMP, new TypeMetadata.Refer(1, 1, 1));
Java程序员-张凯
- 粉丝: 1w+
- 资源: 7527
最新资源
- [COMSOL针-板正流注放电模型]采用流体方程,包含光电离过程,有需要的可以拿去作为参考
- 分布式系统迭代过程中范数与误差演化的数值分析及组件值变化研究
- asdddddddddddddddddddddddddddd
- 高维数据分析作业:图理论与矩阵范数应用(网络分析与社区检测)
- 基于双层优化的电动汽车优化调度研究 标价即原价 参考文档:《考虑大规模电动汽车接入电网的双层优化调度策略-胡文平》中文版 A bi-layer optimization based tempora
- 基于Matlab与simulink搭建的六自由度水下机器人运动模型,采用了滑模控制,实现了轨迹无差度跟踪效果,用S-function和Matlab function搭建的,可以互相替使用,有大量的注释
- 基于滑膜控制的永磁同步电机转速环控制 曲线图中图一为转速的控制效果,图二为电磁转矩随负载变化曲线
- 锂电池soc BMS 2-RC模型 MATLAB Simulink仿真 算法精度 均衡模型 BMS硬件电路PCB
- Al 原生数据库 Infinity 系统架构与 RAG 技术实践-张颖峰.pdf
- 西交利物浦大学并行计算基础课程个人评估作业:基于MPI和另一种并行化技术的图像模糊效果实验及性能分析
- 变步长扰动观察法PO仿真模型,采用了s-function模块,可以随光强的变化,时刻做到最大功率跟踪
- 复刻人工智能技术应用如何影响企业创新(2007-2023年).txt
- Simulink 锂离子电池模型 主要功能是使电池以设定的功率进行充电和放电,并监测电池在工作过程中实时电压、电流、温度和SOC 还附带模型的使用说明
- Java毕业设计-基于springboot的上课考勤系统源码+说明文档.zip文件
- 双馈永磁风电机组并网仿真模型,kw级别永磁同步机PMSG并网仿真模型 机端由6台1.5MW双馈风机构成9MW风电场,风电场容量可调,出口电压690v,经升压变压器及线路阻抗连接至120kv交流电网
- 基于SpringBoot+MySQL的上课考勤系统源码+说明文档.zip文件
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈