123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369 |
- package com.sysmodel.configLoader;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.Map;
- import java.util.Set;
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
- import com.sysmodel.XFormModel;
- import com.sysmodel.collectmodel.xmlmanager.CollectXMLSave;
- import com.sysmodel.collectmodel.xmlmodel.able.FormCollection;
- import com.sysmodel.collectmodel.xmlmodel.impl.FormCollectionImpl;
- import com.sysmodel.listmodel.xmlmanager.ListXMLSave;
- import com.sysmodel.listmodel.xmlmodel.able.FormList;
- import com.sysmodel.listmodel.xmlmodel.impl.FormListImpl;
- import com.sysmodel.xformmodel.able.DojoInputType;
- import com.sysmodel.xformmodel.able.RegExp;
- import com.sysmodel.xformmodel.impl.DojoInputTypeImpl;
- import com.sysmodel.xformmodel.impl.JsFunctionImpl;
- import com.sysmodel.xformmodel.impl.RegExpImpl;
- import com.sysmodel.xformmodel.impl.TbEtymaImpl;
- public class XFormModelImpl implements XFormModel{
- private static final Log log = LogFactory.getLog(Object.class);
- /**
- * 采集页面配置存储容器
- */
- private Map<String, FormCollection> FormCollections = new HashMap<String, FormCollection>();
- /**
- * 列表页面配置存储容器
- */
- private Map<String, FormList> FormLists = new HashMap<String, FormList>();
- /**
- * 加载的文件路径
- */
- public Map<String, String> fileLoadPath = null;
- /**
- * 采集列表页面引用的CSS配置路径
- */
- private String filePathOfCss = "";
- /**
- * WEB-INF/PageResouce.xml pageCss存储容器
- */
- @SuppressWarnings("rawtypes")
- private Map pageCssMap = new HashMap();
- /**
- * js 正则表达式存放集合
- */
- private ArrayList<RegExpImpl> regExps = new ArrayList<RegExpImpl>();
- /**
- * JS函数存放集合
- */
- private ArrayList<JsFunctionImpl> jsFunctions = new ArrayList<JsFunctionImpl>();
- /**
- * JS函数存放集合
- */
- private ArrayList<DojoInputTypeImpl> dojoInuptTypes = new ArrayList<DojoInputTypeImpl>();
- /**
- * 数据库表词根存放集合
- */
- private ArrayList<TbEtymaImpl> tbEtymas = new ArrayList<TbEtymaImpl>();
- /**
- * 静态私有化构造函数
- */
- private static XFormModelImpl XFormModel = null;
- public XFormModelImpl() {
- }
- public static XFormModelImpl getInstance() {
- return XFormModel;
- }
- public static XFormModelImpl getInstance(Map<String, String> fileLoadPath) {
- if (XFormModel == null) {
- XFormModel = new XFormModelImpl();
- } else {
- XFormModel.clear();
- }
- XFormModel.fileLoadPath = fileLoadPath;
- String LoadPath = fileLoadPath.get("PageCollection").toString();
- CollectXMLLoader reader = new CollectXMLLoader();
- if (reader.readConfigFile(LoadPath)) {
- log.info("load PageCollection.xml success");
- }
- LoadPath = fileLoadPath.get("PageList").toString();
- ListXMLLoader FormListReader = new ListXMLLoader();
- if (FormListReader.readConfigFile(LoadPath)) {
- log.info("load PageList.xml success");
- }
- LoadPath = fileLoadPath.get("PageResouce").toString();
- ResourceXMLLoader ResouceLoader = new ResourceXMLLoader();
- if (ResouceLoader.readResource(LoadPath)) {
- log.info("load PageResouce.xml success");
- }
- return XFormModel;
- }
- private void clear() {
- this.FormCollections.clear();
- this.FormLists.clear();
- this.pageCssMap.clear();
- }
- /**
- * 根据配置编号找到FormCollection Parameters:pageid Returns:FormCollection
- */
- public FormCollection getFormCollection(String pageid) {
- Object obj = FormCollections.get(pageid);
- if (obj == null)
- return null;
- else
- return (FormCollection) obj;
- }
- /**
- * 根据配置编号找到FormList Parameters:listid Returns:FormList
- */
- public FormList getFormList(String listid) {
- Object obj = FormLists.get(listid);
- if (obj == null)
- return null;
- else
- return (FormList) obj;
- }
- /**
- * 返回所有的FormCollection配置集合 Returns:FormCollection 集合
- */
- @SuppressWarnings("rawtypes")
- public ArrayList<FormCollection> getFormCollections() {
- ArrayList<FormCollection> list = new ArrayList<FormCollection>();
- Set set = this.FormCollections.entrySet();
- Iterator iterator = set.iterator();
- while (iterator.hasNext()) {
- Map.Entry mapentry = ((Map.Entry) iterator.next());
- list.add((FormCollection) mapentry.getValue());
- }
- return list;
- }
- /**
- * 根据CSS配置的名称获得CSS的配置信息 Parameters:name Returns:
- */
- public String getCSSValue(String key) {
- return (String) pageCssMap.get(key);
- }
- /**
- * 返回所有的指定模块下的FormList配置集合 Returns:FormList 集合
- */
- @SuppressWarnings({ "rawtypes" })
- public ArrayList<FormListImpl> getFormLists() {
- ArrayList<FormListImpl> list = new ArrayList<FormListImpl>();
- Set set = this.FormLists.entrySet();
- Iterator iterator = set.iterator();
- while (iterator.hasNext()) {
- Map.Entry mapentry = (Map.Entry) iterator.next();
- list.add((FormListImpl) mapentry.getValue());
- }
- return list;
- }
- /**
- * 返回所有的指定模块下的FormList配置集合 Parameters:type 模块编号 Returns:FormList 集合
- */
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public ArrayList getFormListByType(String type) {
- ArrayList<FormList> list = new ArrayList<FormList>();
- Set set = this.FormLists.entrySet();
- Iterator iterator = set.iterator();
- while (iterator.hasNext()) {
- Map.Entry mapentry = (Map.Entry) iterator.next();
- FormListImpl FormList = (FormListImpl) mapentry.getValue();
- if (FormList.getType().equals(type))
- list.add(FormList);
- }
- return list;
- }
- /**
- * 返回所有的指定模块下的FormCollection配置集合 Parameters:type 模块编号 Returns:FormCollection
- * 集合
- */
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public ArrayList getFormCollectionsByType(String type) {
- ArrayList<FormCollection> list = new ArrayList<FormCollection>();
- Set set = this.FormCollections.entrySet();
- Iterator iterator = set.iterator();
- while (iterator.hasNext()) {
- Map.Entry mapentry = (Map.Entry) iterator.next();
- FormCollectionImpl FormCollection = (FormCollectionImpl) mapentry.getValue();
- if (FormCollection.getType().equals(type))
- list.add(FormCollection);
- }
- return list;
- }
- /**
- * 根据配置KEY获得配置信息 Parameters:key Returns:
- */
- public String getPropertyValue(String key) {
- return (String) pageCssMap.get(key);
- }
- /**
- * 根据指定的路径保存配置文件 其中包括: PageCollection.xml PageList.xml PageResouce.xml
- * Parameters:savePath Returns:
- */
- public boolean saveXFormModelToFiles() {
- CollectXMLSave CollectXMLSave = new CollectXMLSave();
- ListXMLSave ListXMLSave = new ListXMLSave();
- ListXMLSave.saveToXMLFile(fileLoadPath.get("PageList").toString());
- CollectXMLSave.saveToXMLFile(fileLoadPath.get("PageCollection").toString());
- return true;
- }
- /**
- * 在内存重增加一个采集页面
- *
- * @param pageid
- * @param FormCollection
- */
- public void addFormCollection(String pageid, FormCollection FormCollection) {
- FormCollections.put(pageid, FormCollection);
- }
- /**
- * 在内存重删除一个采集页面
- *
- * @param pageid
- */
- public void deleteFormCollection(String pageid) {
- FormCollections.remove(pageid);
- }
- /**
- * 在内存重增加一个列表多项
- *
- * @param listid
- * @param FormList
- */
- public void addFormList(String listid, FormList FormList) {
- FormLists.put(listid, FormList);
- }
- /**
- * 在内存重删除一个列表多项
- *
- * @param listid
- */
- public void deleteFormList(String listid) {
- FormLists.remove(listid);
- }
- @SuppressWarnings("rawtypes")
- public Map getPageCssMap() {
- return pageCssMap;
- }
- public String getFilePathOfCss() {
- return filePathOfCss;
- }
- public void setFilePathOfCss(String filePathOfCss) {
- this.filePathOfCss = filePathOfCss;
- }
- @SuppressWarnings({ "rawtypes" })
- public ArrayList getJsFunctions() {
- return jsFunctions;
- }
- public String getJsFunctionByCode(String code) {
- String value = "";
- for (int i = 0; i < jsFunctions.size(); i++) {
- JsFunctionImpl JsFunctionImpl = (JsFunctionImpl) jsFunctions.get(i);
- if (JsFunctionImpl.getCode().equals(code)) {
- value = JsFunctionImpl.getValue();
- }
- }
- return value;
- }
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public void setJsFunctions(ArrayList jsFunctions) {
- this.jsFunctions = jsFunctions;
- }
- @SuppressWarnings("rawtypes")
- public ArrayList getRegExps() {
- return regExps;
- }
- public RegExp getRegExpByCode(String code) {
- for (int i = 0; i < regExps.size(); i++) {
- RegExp tempRegExpObj = (RegExp) regExps.get(i);
- if (tempRegExpObj.getCode().equals(code))
- return tempRegExpObj;
- }
- return null;
- }
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void setRegExps(ArrayList regExps) {
- this.regExps = regExps;
- }
- @SuppressWarnings("rawtypes")
- public void setPageCssMap(Map pageCssMap) {
- this.pageCssMap = pageCssMap;
- }
- public ArrayList<DojoInputTypeImpl> getDojoInuptTypes() {
- return dojoInuptTypes;
- }
- public void setDojoInuptTypes(ArrayList<DojoInputTypeImpl> dojoInuptTypes) {
- this.dojoInuptTypes = dojoInuptTypes;
- }
- public ArrayList<TbEtymaImpl> getTbEtymas() {
- return tbEtymas;
- }
- public void setTbEtymas(ArrayList<TbEtymaImpl> tbEtymas) {
- this.tbEtymas = tbEtymas;
- }
- public DojoInputType getDojoInputTypeByCode(String code) {
- for (int i = 0; i < dojoInuptTypes.size(); i++) {
- DojoInputType tempTypeObj = (DojoInputType) dojoInuptTypes.get(i);
- if (tempTypeObj.getCode().equals(code))
- return tempTypeObj;
- }
- return null;
- }
- /**
- * 根据构件类型获得DOJO校验的类新集合
- *
- * @param type
- * @return
- */
- public ArrayList<DojoInputType> getDojoInuptTypesByType(String type) {
- ArrayList<DojoInputType> result = new ArrayList<DojoInputType>();
- for (int i = 0; i < dojoInuptTypes.size(); i++) {
- DojoInputType tempTypeObj = (DojoInputType) dojoInuptTypes.get(i);
- if (type.equals(tempTypeObj.getType()))
- result.add(tempTypeObj);
- }
- return result;
- }
- }
|