懒人配置动特殊数据权限,dom4j解析元数据

dom4j下载:http://sourceforge.net/projects/dom4j/files/latest/download?source=files

上一篇要配置特殊数据权限

http://xy0792.iteye.com/blog/1592637

需要一直找单据全路径和bosType

<special-data-permission>
            <name>com.kingdee.eas.fi.gl.app.Voucher</name>
            <type>2652E01E</type>
 </special-data-permission>

 

如果单据很多,就写一个代码处理,读取实体文件,以下是读取文件,不读取分录,不解析基础资料,只对单据做特殊数据权限,需要导入dom4j,解析元数据。

import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class Main {

	/**
	 * @param args
	 * @throws DocumentException
	 */
	public static void main(String[] args) throws DocumentException {
		File f = new File(
				"E:\\workspace\\Shine\\metadata\\com\\kingdee\\eas\\shine");
		List<File> lstFiles = lstFiles(f, null);
		SAXReader reader = new SAXReader();

		for (Iterator iterator = lstFiles.iterator(); iterator.hasNext();) {
			File file = (File) iterator.next();
			Document xmlDoc = reader.read(file);
			Element root = xmlDoc.getRootElement();
			String strpackage = root.element("package").getData().toString();
			if (strpackage.indexOf("basedata") <= 0) {
				String fullName = strpackage + "."
						+ root.element("name").getData().toString();
				String bosType = root.element("bosType").getData().toString();
				System.out.println("\t\t<special-data-permission>");
				System.out.println("\t\t<name>" + fullName + "</name>");
				System.out.println("\t\t<type>" + bosType + "</type>");
				System.out.println("\t\t</special-data-permission>");
			}
		}
	}

	public static List<File> lstFiles(File f, List<File> fs) {
		if (fs == null) {
			fs = new ArrayList<File>();
		}
		if (f.isDirectory()) {
			File[] files = f.listFiles();
			if (files != null) {
				String lastName = null;
				for (int i = 0; i < files.length; i++) {
					File file = files[i];
					if (file.isDirectory()) {
						lstFiles(files[i], fs);
					} else {
						String name = file.getName();
						if (name.endsWith(".entity")) {
							name = name.substring(0, name.indexOf("."));
							if (lastName != null) {
								if (!name.startsWith(lastName)) {
									fs.add(file);
									lastName = name;
								}
							} else {
								fs.add(file);
								lastName = name;
							}

						}
					}
				}
			}
		} else {
			String name = f.getName();
			if (name.endsWith(".entity")) {
				fs.add(f);
			}
		}
		return fs;
	}
}
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值