Skip to content

Commit

Permalink
headless
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangshibin committed Jun 9, 2019
1 parent e9c6264 commit 1d607ce
Show file tree
Hide file tree
Showing 83 changed files with 1,870 additions and 632 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ build/env.js
maven_temp/
temp_output/
*.db
.DS_Store
.DS_Store
code_output/
tableModel/
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.shareyi.molicode.common.filter

import com.shareyi.molicode.common.utils.LogHelper
import org.apache.commons.collections.CollectionUtils
import org.apache.commons.lang3.StringUtils

Expand Down Expand Up @@ -62,22 +63,27 @@ class FileNameExpressionFilter implements FileNameFilter {
}


public void initNameFilter() {
void initNameFilter() {
if (StringUtils.isEmpty(nameExpression) || initialed) {
return;
}
if (nameExpression.charAt(0) == '^') {
nameExpression = nameExpression.substring(1).trim();
if (nameExpression.charAt(0) == '(' || nameExpression.charAt(0) == '') {

try {
if (nameExpression.charAt(0) == '^') {
nameExpression = nameExpression.substring(1).trim();
if (nameExpression.charAt(0) == '(' || nameExpression.charAt(0) == '') {
nameExpression = nameExpression.substring(1).trim();
}
if (nameExpression.endsWith(")") || nameExpression.endsWith("")) {
nameExpression = nameExpression.substring(0, nameExpression.length() - 1).trim();
}
not = true;
}
if (nameExpression.endsWith(")") || nameExpression.endsWith("")) {
nameExpression = nameExpression.substring(0, nameExpression.length() - 1).trim();
}
not = true;
String[] filters = nameExpression.split("[,,\n]+");
filterTypes = NameFilterType.getNameFilterType(filters);
} catch (Exception e) {
LogHelper.EXCEPTION.error("文件名称表达式过滤器失败,exp={}", nameExpression, e)
}
String[] filters = nameExpression.split("[,,\n]+");
filterTypes = NameFilterType.getNameFilterType(filters);
initialed = true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package com.shareyi.molicode.common.vo.code

import com.alibaba.fastjson.annotation.JSONField
import com.shareyi.molicode.common.filter.impl.PKFilter
import com.shareyi.molicode.common.utils.TableNameUtil;
import org.apache.commons.collections.CollectionUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.shareyi.molicode.common.utils.TableNameUtil
import org.apache.commons.collections.CollectionUtils

/**
* 表定义信息
Expand Down Expand Up @@ -37,6 +34,7 @@ class TableDefineVo {
/**
* 列map,方便通过key获取
*/
@JSONField(serialize = false)
Map<String, ColumnVo> columnMap;
/**
* 所有列
Expand All @@ -45,6 +43,7 @@ class TableDefineVo {
/**
* 主键列
*/
@JSONField(serialize = false)
private List<ColumnVo> pkColumns;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.shareyi.molicode.common.vo.code

import com.alibaba.fastjson.annotation.JSONField
import com.shareyi.molicode.common.constants.MoliCodeConstant
import org.apache.commons.collections.CollectionUtils
import org.apache.commons.lang3.StringUtils
Expand Down Expand Up @@ -27,6 +28,7 @@ class TableModelVo {
/**
* 字段List, 转换为List,方便获取
*/
@JSONField(serialize = false)
Map<String, List<String>> fieldListMap = new HashMap<String, List<String>>();

/**
Expand Down Expand Up @@ -142,6 +144,7 @@ class TableModelVo {
* @return
*/
@Deprecated
@JSONField(serialize = false)
List<String> getSearchKeyList() {
return getColumnNameList(MoliCodeConstant.BIZ_FIELDS_KEY_SEARCHKEY);
}
Expand All @@ -166,12 +169,14 @@ class TableModelVo {
/**
* 获取创建时间字段
*/
@JSONField(serialize = false)
String getCreateTime() {
return bizFieldsMap.get(MoliCodeConstant.BIZ_FIELDS_KEY_CREATETIME)
}
/**
* 获取更新时间字段
*/
@JSONField(serialize = false)
String getUpdateTime() {
return bizFieldsMap.get(MoliCodeConstant.BIZ_FIELDS_KEY_UPDATETIME)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class TableModelPageVo {
* 智能标识
*/
int smartFlag = 1
/**
* 模型类型
*/
String modelType


@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.shareyi.molicode.common.enums.DirTransType;
import com.shareyi.molicode.common.enums.TouchFileType;
import com.shareyi.molicode.common.utils.LogHelper;
import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
Expand Down Expand Up @@ -99,31 +100,36 @@ public static TouchFile parseExpression(String expression) {
return null;
}

TouchFile touchFile = new TouchFile();
touchFile.setExpression(expression);
touchFile.setOriginExpression(expSplit[0]);
touchFile.setTargetExpression(expSplit[1]);
try {
TouchFile touchFile = new TouchFile();
touchFile.setExpression(expression);
touchFile.setOriginExpression(expSplit[0]);
touchFile.setTargetExpression(expSplit[1]);

String[] orgPath = touchFile.getOriginExpression().split("/");
String[] tarPath = touchFile.getTargetExpression().split("/");
String[] orgPath = touchFile.getOriginExpression().split("/");
String[] tarPath = touchFile.getTargetExpression().split("/");

touchFile.setOriginPathList(parseStrArr2List(orgPath));
touchFile.setTargetPathList(parseStrArr2List(tarPath));
//如果为空,直接返回nuLl
if (touchFile.getOriginPathList().isEmpty() || touchFile.getTargetPathList().isEmpty()) {
return null;
}
touchFile.setOriginPathList(parseStrArr2List(orgPath));
touchFile.setTargetPathList(parseStrArr2List(tarPath));
//如果为空,直接返回nuLl
if (touchFile.getOriginPathList().isEmpty() || touchFile.getTargetPathList().isEmpty()) {
return null;
}

if (orgPath.length < tarPath.length) {
touchFile.setTouchFileType(TouchFileType.EXTEND_DIR);
} else if (orgPath.length > tarPath.length) {
touchFile.setTouchFileType(TouchFileType.SHORTEN_DIR);
} else {
touchFile.setTouchFileType(TouchFileType.EXCHANGE_DIR);
}
touchFile.parseDirTrans();
if (orgPath.length < tarPath.length) {
touchFile.setTouchFileType(TouchFileType.EXTEND_DIR);
} else if (orgPath.length > tarPath.length) {
touchFile.setTouchFileType(TouchFileType.SHORTEN_DIR);
} else {
touchFile.setTouchFileType(TouchFileType.EXCHANGE_DIR);
}
touchFile.parseDirTrans();

return touchFile;
return touchFile;
} catch (Exception e) {
LogHelper.EXCEPTION.error("解析touchFile表达式失败,exp={}", expression, e);
}
return null;
}


Expand Down Expand Up @@ -172,92 +178,6 @@ public void parseDirTrans() {
dirTransList.add(dirTrans);
}
}

/* if(originPathList.size()==targetPathList.size()){
for(int i=0;i<originPathList.size();i++){
String originName=originPathList.get(i);
String targetName=targetPathList.get(i);
DirTrans dirTrans=new DirTrans();
dirTrans.setOriginDirName(originPathList.get(i));
if(originName.equals(targetName)){
dirTrans.setDirTransType(DirTransType.NONE);
}else{
dirTrans.setDirTransType(DirTransType.NAME_CHANGE);
}
dirTrans.setTargetDirName(targetPathList.get(i));
dirTransList.add(dirTrans);
}
return;
}*/

/* for(int i=0;i<originPathList.size();i++){
String originName=originPathList.get(i);
//如果还没有超过目标文件夹的size
if(i<targetPathList.size()){
String targetName=targetPathList.get(i);
if(originName.equals(targetName)){
//如果最后一个也相等,通过前面一个判断可以得出 源目录比目标目录短,则需要做扩展处理
if(i==originPathList.size()-1){
doTransPathChange(i);
break;
}
DirTrans dirTrans=new DirTrans();
dirTrans.setOriginDirName(originPathList.get(i));
dirTrans.setDirTransType(DirTransType.NONE);
dirTrans.setTargetDirName(targetPathList.get(i));
dirTransList.add(dirTrans);
}else{
doTransPathChange(i);
break;
}
}else{ //前面全部匹配上,后续为空,表明是删除后面的目录移动到上级目录功能
DirTrans dirTrans=new DirTrans();
dirTrans.setOriginDirName(originPathList.get(i));
dirTrans.setDirTransType(DirTransType.SHORTEN_DIR);
dirTransList.add(dirTrans);
}
}*/
}


/**
* 处理文件路径开始变得不同的数据,
* 第一版本有从不同的位置,做文件内容聚合后,延长文件夹的算法;
* 现在该成按位置匹配,直接文件匹配即可,如果要恢复,需要放开上面的注释
*
* @param index
*/
private void doTransPathChange(int index) {

//从不同的地方开始,所有的目录都是先缩短为1个如, com/jd/ka=com/shareyi/myprj/soso [jd/ka] 缩为一个目录,再扩展成,shareyi/myprj/soso
//以上等价于, ka目录下文件先移到 jd,然后删除ka, 在进行转换 jd=shareyi/myprj/soso

if (index == (targetPathList.size() - 1)) { //即只剩下一个,直接重命名本目录即可
DirTrans dirTrans = new DirTrans();
dirTrans.setOriginDirName(originPathList.get(index));
dirTrans.setTargetDirName(targetPathList.get(index));
dirTrans.setDirTransType(DirTransType.NAME_CHANGE);
dirTransList.add(dirTrans);
} else {
DirTrans dirTrans = new DirTrans();
dirTrans.setOriginDirName(originPathList.get(index));
dirTrans.setDirTransType(DirTransType.EXTEND_DIR);
for (int tarIndex = index; tarIndex < targetPathList.size(); tarIndex++) {
dirTrans.addTargetDir(targetPathList.get(tarIndex));
}
dirTransList.add(dirTrans);
}

//把上一个index先给累加了
index++;
for (; index < originPathList.size(); index++) {
DirTrans dirTrans = new DirTrans();
dirTrans.setOriginDirName(originPathList.get(index));
dirTrans.setDirTransType(DirTransType.SHORTEN_DIR);
dirTransList.add(dirTrans);
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,24 @@ public class CommonConstant {
*/
public static final String DEFAULT_SYS_OWNER = "admin";


/**
* 标准YES_NO 是
*/
public static final String STD_YN_YES_STR ="1";
public static final int STD_YN_YES = 1;
/**
* 标准YES_NO 否
*/
public static final String STD_YN_NO_STR ="2";
public static final int STD_YN_NO = 2;

/**
* 标准YES_NO 是
*/
public static final String STD_YN_YES_STR = "1";
/**
* 标准YES_NO 否
*/
public static final String STD_YN_NO_STR = "2";

public static final String LINE_STR = "\n";
public static final String BROWSER_PASS_KEY = "browserPassKey";
Expand All @@ -31,6 +41,8 @@ public class CommonConstant {
/**
* 逗号分隔
*/
public static final String COMMA= ",";
public static final String COMMA = ",";
public static final String LOCAL_HOST_IP = "127.0.0.1";

public static final String MODEL_TYPE_JSON = "json";
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public class MoliCodeConstant {
* autoCode.xml的解析模型
*/
public static final String CTX_KEY_AUTO_MAKE = "autoMake";
/**
* zip输出目录
*/
public static final String CODE_OUTPUT_ZIP_NAME = "code_output/zip/";

/**
* 原始数据
Expand All @@ -33,18 +37,17 @@ public class MoliCodeConstant {
*/
public static String CTX_KEY_DEF_DATA = "data";

/**
* 保存的压缩文件目录
*/
public static String CTX_KEY_ZIP_FILE_NAME = "zipFileName";

/**
* 参数key 是否trim
*/
public static String PARAM_KEY_TRIM_TYPE = "trimType";







/**
* 创建时间
*/
Expand Down Expand Up @@ -122,8 +125,21 @@ public class MoliCodeConstant {
*/
BIZ_FIELDS_DEF_EXP_MAP.put(BIZ_FIELDS_KEY_ALLCOLUMN, "");


}


/**
* 结果信息
*/
public class ResultInfo {
/**
* 起始时间
*/
public static final String START_TIME_KEY = "startTime";
/**
* 耗时
*/
public static final String COST_TIME_KEY = "costTime";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
public enum BrowserWindowEnum implements EnumCode<String>{

SWING("swing","swing窗口"),
JX_BROWSER("jxBrowser","JXBrowser");
JX_BROWSER("jxBrowser","JXBrowser"),
HEADLESS("headless","无窗口");

String code,desc;

Expand Down
Loading

0 comments on commit 1d607ce

Please sign in to comment.