|
@@ -32,6 +32,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity> |
|
|
|
|
|
|
|
|
private long prj_id;//所属项目 |
|
|
private long prj_id;//所属项目 |
|
|
private int type;//查询类型:0-目录;1-表定义;2-页面定义 |
|
|
private int type;//查询类型:0-目录;1-表定义;2-页面定义 |
|
|
|
|
|
private boolean exc_empty;//排除空目录,type非目录时有效 |
|
|
|
|
|
|
|
|
private ModelCatalogTreeHelper mcTreeHelper = null; |
|
|
private ModelCatalogTreeHelper mcTreeHelper = null; |
|
|
|
|
|
|
|
@@ -40,6 +41,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity> |
|
|
super.init(params, us); |
|
|
super.init(params, us); |
|
|
type = params.readInt("type"); |
|
|
type = params.readInt("type"); |
|
|
prj_id = params.readLong("prj_id"); |
|
|
prj_id = params.readLong("prj_id"); |
|
|
|
|
|
exc_empty = params.readBool("exc_empty"); |
|
|
mcTreeHelper = (ModelCatalogTreeHelper) TreeHelper.getTreeHelper(ModelCatalog.ENTITY_NAME, ModelCatalogTreeHelper.class); |
|
|
mcTreeHelper = (ModelCatalogTreeHelper) TreeHelper.getTreeHelper(ModelCatalog.ENTITY_NAME, ModelCatalogTreeHelper.class); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -84,8 +86,12 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity> |
|
|
@Override |
|
|
@Override |
|
|
protected List<DefaultEntity> getChildren(long id) { |
|
|
protected List<DefaultEntity> getChildren(long id) { |
|
|
List<ModelCatalog> list = mcTreeHelper.getChildren(id, prj_id, (o1, o2) -> CommUtil.chineseCompare(o1.getName(), o2.getName())); |
|
|
List<ModelCatalog> list = mcTreeHelper.getChildren(id, prj_id, (o1, o2) -> CommUtil.chineseCompare(o1.getName(), o2.getName())); |
|
|
|
|
|
|
|
|
List<DefaultEntity> listRet = new ArrayList<>(list); |
|
|
|
|
|
|
|
|
List<DefaultEntity> listRet; |
|
|
|
|
|
if (type != TYPE_CATALOG && exc_empty) {//排除空目录 |
|
|
|
|
|
listRet = cleanEmpty(list); |
|
|
|
|
|
} else { |
|
|
|
|
|
listRet = new ArrayList<>(list); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
switch (type) { |
|
|
switch (type) { |
|
|
case TYPE_TABLE: |
|
|
case TYPE_TABLE: |
|
@@ -99,6 +105,41 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity> |
|
|
return listRet; |
|
|
return listRet; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 去掉没有叶子的空目录 |
|
|
|
|
|
* @param list |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
private List<DefaultEntity> cleanEmpty(List<ModelCatalog> list) { |
|
|
|
|
|
if (list.isEmpty()) return new ArrayList<>(list); |
|
|
|
|
|
List<DefaultEntity> lret = new ArrayList<>(); |
|
|
|
|
|
for (ModelCatalog mc: list) { |
|
|
|
|
|
if (hasChildren(mc)) lret.add(mc); |
|
|
|
|
|
} |
|
|
|
|
|
return lret; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//递归判断,目录是否有儿子 |
|
|
|
|
|
private boolean hasChildren(ModelCatalog mc) { |
|
|
|
|
|
List<DefaultEntity> listRet = new ArrayList<>(); |
|
|
|
|
|
switch (type) { |
|
|
|
|
|
case TYPE_TABLE: |
|
|
|
|
|
addTableChildren(listRet, mc.getId()); |
|
|
|
|
|
break; |
|
|
|
|
|
case TYPE_PAGE: |
|
|
|
|
|
case TYPE_WIDGET: |
|
|
|
|
|
case TYPE_FORM: |
|
|
|
|
|
addPageChildren(listRet, mc.getId(), type); |
|
|
|
|
|
} |
|
|
|
|
|
if (!listRet.isEmpty()) return true; |
|
|
|
|
|
List<ModelCatalog> list = mcTreeHelper.getChildren(mc.getId(), prj_id, null); |
|
|
|
|
|
if (list == null || list.isEmpty()) return false; |
|
|
|
|
|
for (ModelCatalog c: list) { |
|
|
|
|
|
if (hasChildren(c)) return true; |
|
|
|
|
|
} |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//增加表 |
|
|
//增加表 |
|
|
private void addTableChildren(List<DefaultEntity> listRet, long mcid) { |
|
|
private void addTableChildren(List<DefaultEntity> listRet, long mcid) { |
|
|
Collection<ModelTable> set = ModelTableCache.getInstance().getTablesByMc(mcid, (o1, o2) -> CommUtil.chineseCompare(o1.getName(), o2.getName())); |
|
|
Collection<ModelTable> set = ModelTableCache.getInstance().getTablesByMc(mcid, (o1, o2) -> CommUtil.chineseCompare(o1.getName(), o2.getName())); |
|
|