码迷,mamicode.com
首页 > 其他好文 > 详细

两个任务的总结

时间:2017-05-25 17:16:50      阅读:307      评论:0      收藏:0      [点我收藏+]

标签:framework   iter   XML   ict   bool   ase   insert   list   data   

1.在制定路径下添加文件夹并命名

package com.efounder.finereport.plugin;

import com.efounder.bz.service.ServicePluginAdapter;
import com.efounder.mdm.server.MDMContext;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import com.core.xml.StubObject;
import com.efounder.builder.base.data.EFDataSet;
import com.efounder.builder.base.data.EFRowSet;
import com.efounder.builder.base.util.ESPContext;
import com.efounder.builder.base.util.ESPServerContext;
import com.efounder.builder.config.ConfigDataManager;
import com.efounder.builder.meta.MetaDataManager;
import com.efounder.builder.meta.dctmodel.DCTMetaData;
import com.efounder.bz.service.ServicePluginAdapter;
import com.efounder.db.DBTools;
import com.efounder.dbc.data.DataItem;
import com.efounder.eai.EAI;
import com.efounder.eai.data.JParamObject;
import com.efounder.eai.data.JResponseObject;
import com.efounder.eai.service.dal.DBUtils;
import com.efounder.mdm.EFMDMDataModel;
import com.efounder.mdm.server.MDMContext;
import com.efounder.mdm.server.resolver.util.DICTSaveDataUtils;
import com.efounder.sql.JConnection;
import com.pansoft.esp.datamanager.pub.DictUtilClt;
import com.pansoft.esp.datamanager.server.creater.CreaterUtil;
import com.pansoft.esp.datamanager.server.creater.plugin.CreateContext;
public class FineReportModuleProcessPlugins extends ServicePluginAdapter {
public FineReportModuleProcessPlugins(){

}
public Object processMDMLoader(MDMContext mdmContext,EFMDMDataModel mdmDataModel) throws Exception {
// 获取元数据
DCTMetaData dctMetaData = mdmContext.getDCTMetaData();
if ( dctMetaData == null ) return null;
JParamObject PO = mdmContext.getParamObject();
EFDataSet updateDataSet = mdmDataModel.getDataSet(mdmDataModel.getDCT_ID()+"_UPDATE");
EFDataSet insertDataSet = mdmDataModel.getDataSet(mdmDataModel.getDCT_ID()+"_INSERT");
EFDataSet deleteDataSet = mdmDataModel.getDataSet(mdmDataModel.getDCT_ID()+"_DELETE");
// updateFlie(updateDataSet);
insertFlie(insertDataSet);
deleteFlie(deleteDataSet);                          //两个方法,方法不能写在方法里面,但是可以通过传递方法名与参数调用方法
return null;
}
//重命名
public static void updateFlie(EFDataSet updateDataSet){
String fileName="";
for(int i=0;i<updateDataSet.getRowCount();i++){
EFRowSet rowset = updateDataSet.getRowSet(i);                     //.getRowSet(i),遍历一下     
fileName = rowset.getString("MODULE_BH", "");
//得到enterprisesever
String eaiRoot = EAI.LocalUserHome;                            //得到根节点也就是enterprisesever
//创建斜杠
String Separator = System.getProperty("file.separator");
if (eaiRoot.endsWith("/") || eaiRoot.endsWith("\\")) {
eaiRoot = eaiRoot.substring(0, eaiRoot.length() - 1);
eaiRoot = eaiRoot + Separator + "WEB-INF" + Separator + "reportlets";     //enterprisesever/WEB-INF/reportlets

}
File file = new File(eaiRoot);
if (file.exists()) {
file.renameTo(new File(fileName));
}
}
}

//新建
public static boolean insertFlie(EFDataSet insertDataSet){
String fileName="";
for(int i=0;i<insertDataSet.getRowCount();i++){
EFRowSet rowset = insertDataSet.getRowSet(i);
fileName = rowset.getString("MODULE_BH", "");
String eaiRoot = EAI.LocalUserHome;
String Separator = System.getProperty("file.separator");
if (eaiRoot.endsWith("/") || eaiRoot.endsWith("\\")) {
eaiRoot = eaiRoot.substring(0, eaiRoot.length() - 1);
eaiRoot = eaiRoot + Separator + "WEB-INF" + Separator + "reportlets";
}
File file = new File(eaiRoot+Separator+fileName);                                         //注意这种写法,
//如果文件夹不存在则创建
if(!file.exists()&&!file.isDirectory()){
file .mkdir();                                                                                   //创建文件夹的时候废了大劲了,就是这么一句话file .mkdir(); 
}else {
System.out.println("//目录存在");
}
}
return false;
}

//删除
public static boolean deleteFlie(EFDataSet deleteDataSet){
String fileName="";
boolean flag=false;
for(int i=0;i<deleteDataSet.getRowCount();i++){
EFRowSet rowset = deleteDataSet.getRowSet(i);
fileName = rowset.getString("MODULE_BH", "");                                //getString(key),得到key的值
}
String eaiRoot = EAI.LocalUserHome;
String Separator = System.getProperty("file.separator");
if (eaiRoot.endsWith("/") || eaiRoot.endsWith("\\")) {
eaiRoot = eaiRoot.substring(0, eaiRoot.length() - 1);
eaiRoot = eaiRoot + Separator + "WEB-INF" + Separator + "reportlets";

}
File file = new File(eaiRoot+Separator+fileName);
// 路径为文件且不为空则进行删除
if (file.isDirectory() && file.exists()) {
file.delete();
flag = true;
}
return flag;

}

------------------------------------------------------------------------------------------------------------------------------------------------------

2.检索出该人名下对应的模块(不同的人有不同的模块)

package com.efounder.finereport.server;

import java.io.File;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.efounder.eai.EAI;
import com.efounder.eai.data.JParamObject;
import com.efounder.eai.data.JResponseObject;
import com.efounder.eai.framework.JActiveObject;
import com.efounder.sql.JConnection;

 


public class ESPFineReportDAL extends JActiveObject {
private static final String GUID = "ESPFineReportDAL";


public ESPFineReportDAL() {
setObjectGUID(GUID);
}

/**
* 获取某个文件夹下的子文件夹
*
* @param o1
* @param o2
* @param o3
* @param o4
* @return
* @throws Exception
*/


public Object getChildFolder(Object o1, Object o2, Object o3, Object o4) throws Exception {
JParamObject PO = (JParamObject)o1;
String userName = PO.GetValueByParamName("UserName");
List moduleList = processModule(PO,userName);                                                //从下面的方法传过来的,方法名和参数
JResponseObject RO = new JResponseObject();
List list = new ArrayList();
String eaiRoot = EAI.LocalUserHome;
if (eaiRoot.endsWith("/") || eaiRoot.endsWith("\\")) {
eaiRoot = eaiRoot.substring(0, eaiRoot.length() - 1);
}
String Separator = System.getProperty("file.separator");
eaiRoot = eaiRoot + Separator + "WEB-INF" + Separator + "reportlets"
+ Separator;
File file = new File(eaiRoot);
File[] tempList = file.listFiles();
for (int i = 0; i < tempList.length; i++) {
if (tempList[i].isDirectory()&&moduleList.contains(tempList[i])) {
System.out.println(tempList[i].getName());
list.add(tempList[i].getName());
}
}
RO.setResponseObject(list);
return RO;
}
private List processModule(JParamObject PO, String userName) throws Exception {
JConnection conn = JConnection.getInstance(PO);
List Modulelist = new ArrayList();
try {
String sql = "select MODULE_ID from FR_RY_MODULE_GXB WHERE MODULE_BH=userName";
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(sql);                                                                                             //注意这里,以后能用到
while (rs.next()) {
String Namelist = rs.getString("MODULE_ID");
Modulelist.add(Namelist);
}
conn.close(); //关闭数据库连接
} catch (SQLException e) {
System.out.println("查询数据失败");
}
return Modulelist;                                                                   //只有return了Modulelist,前面才能使用                                                                   
}


}

 

两个任务的总结

标签:framework   iter   XML   ict   bool   ase   insert   list   data   

原文地址:http://www.cnblogs.com/thomasbc/p/6904810.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!