| | |
| | | package com.vci.ubcs.code.util; |
| | | |
| | | import com.alibaba.cloud.commons.lang.StringUtils; |
| | | import com.thoughtworks.xstream.XStream; |
| | | import com.thoughtworks.xstream.io.xml.DomDriver; |
| | | import com.vci.ubcs.code.vo.webserviceModel.attrmap.LibraryDO; |
| | | import com.vci.ubcs.starter.util.LocalFileUtil; |
| | | import com.vci.ubcs.webservice.config.AttributeMapConfig; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import java.util.Map; |
| | | |
| | | public class gennerAttrMapUtil { |
| | | @Autowired(required = false) |
| | | private AttributeMapConfig attributeMapConfig; |
| | | private static String fileName=""; |
| | | private static gennerAttrMapUtil newInstance=null; |
| | | public static gennerAttrMapUtil getNewInstance() { |
| | | if(newInstance==null){ |
| | | newInstance=new gennerAttrMapUtil(); |
| | | } |
| | | return newInstance; |
| | | } |
| | | |
| | | /**** |
| | | * 获取 |
| | | * @param systemId |
| | | */ |
| | | public LibraryDO gennerAttrMapBySystem(String systemId, Map<String, String> system_attrmap) throws Throwable{ |
| | | if(StringUtils.isBlank(systemId)){ |
| | | throw new Throwable("系统标识为空"); |
| | | } |
| | | LibraryDO rootDataVO=new LibraryDO(); |
| | | if(system_attrmap.containsKey(systemId)){ |
| | | String path=system_attrmap.get(systemId); |
| | | String attributeMapData= LocalFileUtil.readContentForFile(path); |
| | | XStream xStream = new XStream(new DomDriver()); |
| | | xStream.processAnnotations(LibraryDO.class); |
| | | xStream.autodetectAnnotations(true); |
| | | rootDataVO = (LibraryDO) xStream.fromXML(attributeMapData); |
| | | |
| | | } |
| | | return rootDataVO; |
| | | } |
| | | |
| | | } |