package com.vci.client.bof;
|
|
import java.awt.Graphics;
|
import java.awt.Image;
|
import java.awt.image.BufferedImage;
|
import java.io.BufferedReader;
|
import java.io.File;
|
import java.io.FileReader;
|
import java.io.IOException;
|
import java.io.UnsupportedEncodingException;
|
import java.net.URLEncoder;
|
import java.util.ArrayList;
|
import java.util.List;
|
import javax.imageio.ImageIO;
|
|
import junit.framework.Assert;
|
|
import org.junit.After;
|
import org.junit.AfterClass;
|
import org.junit.Before;
|
import org.junit.BeforeClass;
|
import org.junit.Test;
|
|
import com.vci.corba.omd.atm.AttribItem;
|
import com.vci.corba.omd.btm.BtmItem;
|
import com.vci.corba.omd.lcm.TransitionVO;
|
import com.vci.mw.InvocationUtility;
|
import com.vci.client.LogonApplication;
|
import com.vci.client.common.objects.UserEntityObject;
|
import com.vci.client.common.objects.UserObject;
|
import com.vci.client.omd.provider.BtmProvider;
|
import com.vci.client.ui.exception.VCIException;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.common.data.VCIInvocationInfo;
|
|
|
public class BOFClientTest {
|
|
ClientBusinessObjectOperation operation = new ClientBusinessObjectOperation();
|
@BeforeClass
|
public static void setUpBeforeClass() throws Exception {
|
}
|
|
@AfterClass
|
public static void tearDownAfterClass() throws Exception {
|
}
|
|
@Before
|
public void setUp() throws Exception {
|
UserEntityObject ueo = new UserEntityObject();
|
ueo.setIp("192.168.0.50");
|
ueo.setUserName("1");
|
LogonApplication.userEntityObject = ueo;
|
|
VCIInvocationInfo info = InvocationUtility.initInvocationInfo();
|
info.clientIPInfo = "192.168.0.44";
|
info.userName = "eddie";
|
}
|
|
@After
|
public void tearDown() throws Exception {
|
}
|
|
@Test
|
public void testSelect() throws VCIError {
|
try {
|
ClientBusinessObject ccbo = operation.readBusinessObjectById("023028CC-E08F-81A0-CF93-600A67FE0A80", "folder");
|
System.out.println(ccbo.getRevisionRule());
|
|
String[] links = new String[1];
|
links[0] = "EBOM";
|
ClientBusinessObject rcbo = operation.revisionBusinessObject(ccbo, links, true, true, true, false);
|
// System.out.println(ccbo.getRevisionValue() + " " + ccbo.getRevisionSeq() + " " + ccbo.getVersionValue() + " " + ccbo.getVersionSeq());
|
// ClientBusinessObject rcbo = operation.(ccbo, new ClientLinkObject[0], true, true, false, false);
|
// System.out.println(rcbo.getRevisionValue() + " " + rcbo.getRevisionSeq() + " " + rcbo.getVersionValue() + " " + rcbo.getVersionSeq());
|
// operation.saveRevisionBuinessObject(rcbo);
|
// ClientBusinessObject vcbo = operation.createBusinessObjectVersion(ccbo);
|
// System.out.println(vcbo.getRevisionValue() + " " + vcbo.getRevisionSeq() + " " + vcbo.getVersionValue() + " " + vcbo.getVersionSeq());
|
// operation.saveVersionBuinessObject(vcbo);
|
System.out.println(rcbo.getLcStatus());
|
} catch (VCIError e) {
|
System.out.println(e.code);
|
}
|
}
|
|
@Test
|
public void testSelectLastRevObj() throws VCIError {
|
try {
|
ClientBusinessObject[] ccbo = operation.getLastRevisionBusinessObject("CF425923-1B0C-4F98-4FB7-5E707C59AA14", "part");
|
System.out.println(ccbo.length);
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
}
|
|
@Test
|
public void testClone() throws VCIError {
|
try {
|
ClientBusinessObject cbo = operation.readBusinessObjectById("30430FAE-370E-935A-4143-A25CEB264B61", "part");
|
ClientBusinessObject cbo2 = operation.cloneBusinessObject(cbo);
|
System.out.println(cbo2.getLcStatus());
|
} catch (VCIError e) {
|
System.out.println(e.code);
|
}
|
}
|
|
@Test
|
public void testInitBO(){
|
// ClientBusinessObject cbo = operation.initBusinessObject("equipment");
|
// cbo.setAttributeValue("code", "test6");
|
try {
|
ClientBusinessObject saveCbo = operation.readBusinessObjectById("BA8686B0-2B55-A9B8-D97C-0279A853CBB2", "part");
|
System.out.println(saveCbo.getAttributeValue("code"));
|
|
ClientBusinessObject revisonObj = operation.revisionBusinessObject(saveCbo, new ClientLinkObject[0], true, true, true, false);
|
System.out.println(revisonObj.getAttributeValue("code"));
|
} catch (VCIError e) {
|
System.out.println(e.code);
|
}
|
|
// ClientBusinessObject vsionObj = operation.revisionBusinessObject(revisonObj, new ClientLinkObject[0], false, true, false, false);
|
// System.out.println(vsionObj.getAttributeValue("code"));
|
}
|
|
@Test
|
public void testRevisionBO() {
|
try {
|
ClientBusinessObject cbo = operation.readBusinessObjectById("F41298E3-CA0D-CD9C-EE58-84EA7E7730DB", "datamodule");
|
ClientBusinessObject cbo2 = operation.revisionBusinessObject(cbo, new ClientLinkObject[0] , false, true, false, false);
|
System.out.println(cbo.getIsFirstR() + " " + cbo.getIsLastR());
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
}
|
|
@Test
|
public void testCreatObject() {
|
|
try {
|
ClientBusinessObject cbo = operation.createBusinessObject("photograph");
|
cbo.setName("test-006");
|
cbo.setAttributeValue("filepath", "http://192.168.0.31:8080/PlatformBS2.0/abc-6.jpg");
|
// cbo.setAttributeValue("sender", "1");
|
// cbo.setAttributeValue("sendstatus", "2");
|
// cbo.setAttributeValue("receivers", "user:1");
|
// cbo.setAttributeValue("messagetitle", "test4");
|
// cbo.setAttributeValue("messagecontent", "testddd4");
|
// cbo.setAttributeValue("receivestatus", "1");
|
// cbo.setAttributeValue("receiver", "1");
|
// cbo.setAttributeValue("messageoid", "CC303DB4-EE9E-C654-DA7E-C0E4F4C0B816");
|
// File f = new File("C:/Users/liudi/Desktop/a.html");
|
// BufferedReader in = new BufferedReader(new FileReader(f));
|
//
|
// StringBuffer s= new StringBuffer();
|
// String ss;
|
// while((ss=in.readLine())!=null){
|
// System.out.print(ss);
|
// s.append(ss);
|
// }
|
// in.close();
|
// cbo.setAttributeValue("TESTCLOB".toLowerCase(),s.toString());
|
// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
// String str = df.format(new java.util.Date());
|
// cbo.setAttributeValue("starttime", str);
|
// cbo.setAttributeValue("affiliatedrole", "B336CC22-7BCD-AE17-20A8-07D78405A2E5");
|
// cbo.setAttributeValue("twoclsf", "采用标准目录");
|
// cbo.setAttributeValue("twoclsf", "标准体系表");
|
// cbo.setAttributeValue("twoclsf", "产品技术规范");
|
// cbo.setAttributeValue("twoclsf", "标准");
|
// plm.bs.bom.common.AttributeValue[] attrVals = cbo.getBusinessObject().newAttrValList;
|
// List<AttributeValue> attrList = new ArrayList<AttributeValue>();
|
// for (int i = 0; i < attrVals.length; i++) {
|
// attrList.add(attrVals[i]);
|
// }
|
// AttributeValue av = new AttributeValue();
|
// av.attrName = "twoclsf";
|
// av.attrVal = "采用标准目录";
|
// attrList.add(av);
|
// cbo.getBusinessObject().newAttrValList = attrList.toArray(new AttributeValue[0]);
|
// cbo.setAttributeValue("partfile", "442E356E-524C-49F3-B194-E571868C0093");
|
// cbo.setAttributeValue("muser", "0EB2AF20-3D6B-4CFF-9D10-0A379BED1E12");
|
|
ClientBusinessObject ccbo = operation.saveCreateBuinessObject(cbo);
|
System.out.println(ccbo);
|
// System.out.println(ccbo.getRevisionValue() + " " + ccbo.getRevisionSeq() + " " + ccbo.getVersionValue() + " " + ccbo.getVersionSeq());
|
// ClientBusinessObject rcbo = operation.reviseBusinessObject(ccbo, "");
|
// System.out.println(rcbo.getRevisionValue() + " " + rcbo.getRevisionSeq() + " " + rcbo.getVersionValue() + " " + rcbo.getVersionSeq());
|
// ClientBusinessObject vcbo = operation.createBusinessObjectVersion(ccbo);
|
// System.out.println(vcbo.getRevisionValue() + " " + vcbo.getRevisionSeq() + " " + vcbo.getVersionValue() + " " + vcbo.getVersionSeq());
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
VCIException exp = new VCIException(e.code, e.messages);
|
System.out.println(e.messages[1]);
|
e.printStackTrace();
|
} catch (Throwable e) {
|
e.printStackTrace();
|
}
|
}
|
|
@Test
|
public void testBatchCreateFileObject() {
|
try {
|
String fileName = "D:\\apache-tomcat-7.0.42\\wtpwebapps\\PlatformBS2.0\\upload\\";
|
String sfileName = "D:\\apache-tomcat-7.0.42\\wtpwebapps\\PlatformBS2.0\\upload\\Photo\\";
|
List<String> pathlist = new ArrayList<String>();
|
List<String> namelist = new ArrayList<String>();
|
getAllFileNames(sfileName, pathlist, namelist);
|
for (int i = 0; i < pathlist.size(); i++) {
|
ClientBusinessObject cbo = operation.createBusinessObject("photograph");
|
cbo.setName(namelist.get(i).substring(0, namelist.get(i).lastIndexOf(".")));
|
String cfilePath = pathlist.get(i).substring(fileName.length()).replace("\\", "/");
|
cbo.setAttributeValue("filepath", cfilePath);
|
cbo.setAttributeValue("tfilepath", "t" + cfilePath);
|
|
ClientBusinessObject ccbo = operation.saveCreateBuinessObject(cbo);
|
System.out.println(
|
pathlist.get(i).substring(fileName.length()) + " - " + namelist.get(i).substring(0, namelist.get(i).lastIndexOf(".")));
|
}
|
} catch (Throwable e) {
|
e.printStackTrace();
|
}
|
}
|
|
private void getAllFileNames(String fileName, List<String> pathlist, List<String> nameList) {
|
File file = new File(fileName);
|
File[] files = file.listFiles();
|
for (File f : files) {
|
if (f.isDirectory()) {
|
getAllFileNames(f.getAbsolutePath(), pathlist, nameList);
|
} else {
|
pathlist.add(f.getAbsolutePath());
|
nameList.add(f.getName());
|
}
|
}
|
}
|
|
@Test
|
public void testBatchScaleFileObject() {
|
try {
|
String fileName = "D:\\apache-tomcat-7.0.42\\wtpwebapps\\PlatformBS2.0\\upload\\";
|
List<String> pathlist = new ArrayList<String>();
|
List<String> namelist = new ArrayList<String>();
|
getAllFileNames(fileName, pathlist, namelist);
|
for (int i = 0; i < pathlist.size(); i++) {
|
String cPath = pathlist.get(i).replace("Photo", "tPhoto");
|
String cfolderPath = cPath.substring(0, cPath.length() - namelist.get(i).length());
|
File cfolder = new File(cfolderPath);
|
if (!cfolder.exists()) {
|
cfolder.mkdirs();
|
}
|
String format = namelist.get(i).substring(namelist.get(i).lastIndexOf(".") + 1);
|
scale(pathlist.get(i), cPath, format);
|
// ClientBusinessObject cbo = operation.createBusinessObject("photograph");
|
// cbo.setName(namelist.get(i).substring(0, namelist.get(i).lastIndexOf(".")));
|
// cbo.setAttributeValue("filepath", pathlist.get(i).substring(fileName.length() + 1).replace("\\", "/"));
|
// ClientBusinessObject ccbo = operation.saveCreateBuinessObject(cbo);
|
System.out.println(
|
pathlist.get(i).substring(fileName.length() + 1) + " - " + namelist.get(i).substring(0, namelist.get(i).lastIndexOf(".")));
|
}
|
} catch (Throwable e) {
|
e.printStackTrace();
|
}
|
}
|
|
private void scale(String srcImageFile, String result, String format) {
|
try {
|
BufferedImage src = ImageIO.read(new File(srcImageFile)); // 读入文件
|
int width = src.getWidth(); // 得到源图宽
|
int height = src.getHeight(); // 得到源图长
|
width = 110 * 4;
|
height = 150 * 4;
|
Image image = src.getScaledInstance(width, height, Image.SCALE_DEFAULT);
|
BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
Graphics g = tag.getGraphics();
|
g.drawImage(image, 0, 0, null); // 绘制缩小后的图
|
g.dispose();
|
ImageIO.write(tag, format, new File(result));// 输出到文件流
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
|
@Test
|
public void testQuery() {
|
// TableDataUtil util = new TableDataUtil();
|
// List<Map<String, String>> dataModel = null;
|
// String qtName = "currentUserMsgUnReadQuery";
|
// Map<String, String> replaceMap = new HashMap<String, String>();
|
// replaceMap.put("CURRENTUSER.NAME", "1");
|
//
|
// Map<String, String> queryColumnsMap = new HashMap<String, String>();
|
// queryColumnsMap.put("messageoid.messagetitle", "标题");
|
//
|
// try {
|
// dataModel = util.getObjectDataList(qtName, replaceMap,
|
// new HashMap<String, String>() , null, null, "vcireceivemessage",
|
// queryColumnsMap, null, null);
|
// System.out.println(dataModel.size());
|
// } catch (VCIError e) {
|
// // TODO Auto-generated catch block
|
// e.printStackTrace();
|
// } catch (DocumentException e) {
|
// // TODO Auto-generated catch block
|
// e.printStackTrace();
|
// }
|
}
|
|
@Test
|
public void testBatchCreateObjWithLink() {
|
try {
|
|
|
ClientLinkObjectOperation cloperation = new ClientLinkObjectOperation();
|
ClientBusinessObject[] cbos = new ClientBusinessObject[8000];
|
ClientLinkObject[] los = new ClientLinkObject[4000];
|
|
ClientBusinessObject workitem = operation.createBusinessObject("workitem");
|
BtmItem workItemType = null;
|
AttribItem[] workItemItems = BtmProvider.getInstance().getBtAbItems("workitem");
|
ClientBusinessObject part = operation.createBusinessObject("part");
|
BtmItem partType = null;
|
AttribItem[] partItems = BtmProvider.getInstance().getBtAbItems("part");
|
long start = System.currentTimeMillis();
|
System.out.println("start time: " + start);
|
for (int i = 0; i < 4000; i++) {
|
cbos[i] = operation.cloneBusinessObject(workitem, workItemType, workItemItems, true, "1");
|
cbos[4000 + i] = operation.cloneBusinessObject(part, partType, partItems, true, "1");
|
los[i] = cloperation.createLinkObject("input");
|
los[i].setFromBO(cbos[i]);
|
los[i].setToBO(cbos[4000 + i]);
|
}
|
long end = System.currentTimeMillis();
|
System.out.println("end time: " + end);
|
long duration = end - start;
|
System.out.println("save time is: " + duration);
|
// ClientBusinessObject[] cbos = new ClientBusinessObject[1];
|
// cbos[0] = operation.createBusinessObject("engine");
|
start = System.currentTimeMillis();
|
System.out.println("start time: " + start);
|
operation.batchSaveCreateBuinessObject(cbos, new ClientLinkObject[0]);
|
end = System.currentTimeMillis();
|
System.out.println("end time: " + end);
|
duration = end - start;
|
System.out.println("save time is: " + duration);
|
|
start = System.currentTimeMillis();
|
System.out.println("start time: " + start);
|
operation.batchSaveCreateBuinessObject(new ClientBusinessObject[0], los);
|
end = System.currentTimeMillis();
|
System.out.println("end time: " + end);
|
duration = end - start;
|
System.out.println("save time is: " + duration);
|
} catch (VCIError e) {
|
e.printStackTrace();
|
} catch (Throwable e) {
|
e.printStackTrace();
|
}
|
}
|
|
@Test
|
public void testCreatObjectWithLink() {
|
|
try {
|
// ClientBusinessObject[] bos = new ClientBusinessObject[7];
|
// ClientBusinessObject bo1 = operation.createBusinessObject("part");
|
// bo1.setAttributeValue("code", "LCQ10");
|
// bos[0] = bo1;
|
//
|
// ClientBusinessObject bo2 = operation.createBusinessObject("part");
|
// bo2.setAttributeValue("code", "LCQ20");
|
// bos[1] = bo2;
|
//
|
// ClientBusinessObject bo3 = operation.createBusinessObject("part");
|
// bo3.setAttributeValue("code", "LCQ21");
|
// bos[2] = bo3;
|
//
|
// ClientBusinessObject bo4 = operation.createBusinessObject("part");
|
// bo4.setAttributeValue("code", "LCQ30");
|
// bos[3] = bo4;
|
//
|
// ClientBusinessObject bo5 = operation.createBusinessObject("part");
|
// bo5.setAttributeValue("code", "LCQ31");
|
// bos[4] = bo5;
|
//
|
// ClientBusinessObject bo6 = operation.createBusinessObject("part");
|
// bo6.setAttributeValue("code", "LCQ32");
|
// bos[5] = bo6;
|
//
|
// ClientBusinessObject bo7 = operation.createBusinessObject("part");
|
// bo7.setAttributeValue("code", "LCQ33");
|
// bos[6] = bo7;
|
//
|
// List<ClientLinkObject> linkList = new ArrayList<ClientLinkObject>();
|
//
|
// ClientLinkObjectOperation coperation = new ClientLinkObjectOperation();
|
// ClientLinkObject lo = coperation.createLinkObject("EBOM");
|
// lo.setFromBO(bo1);
|
// lo.setToBO(bo2);
|
// linkList.add(lo);
|
//
|
// lo = coperation.createLinkObject("EBOM");
|
// lo.setFromBO(bo1);
|
// lo.setToBO(bo3);
|
// linkList.add(lo);
|
//
|
// lo = coperation.createLinkObject("EBOM");
|
// lo.setFromBO(bo2);
|
// lo.setToBO(bo4);
|
// linkList.add(lo);
|
//
|
// lo = coperation.createLinkObject("EBOM");
|
// lo.setFromBO(bo2);
|
// lo.setToBO(bo5);
|
// linkList.add(lo);
|
//
|
// lo = coperation.createLinkObject("EBOM");
|
// lo.setFromBO(bo3);
|
// lo.setToBO(bo6);
|
// linkList.add(lo);
|
//
|
// lo = coperation.createLinkObject("EBOM");
|
// lo.setFromBO(bo3);
|
// lo.setToBO(bo7);
|
// linkList.add(lo);
|
//
|
// lo = coperation.createLinkObject("PBOM");
|
// lo.setFromBO(bo1);
|
// lo.setToBO(bo2);
|
// linkList.add(lo);
|
//
|
// lo = coperation.createLinkObject("PBOM");
|
// lo.setFromBO(bo1);
|
// lo.setToBO(bo3);
|
// linkList.add(lo);
|
//
|
// lo = coperation.createLinkObject("PBOM");
|
// lo.setFromBO(bo2);
|
// lo.setToBO(bo4);
|
// linkList.add(lo);
|
//
|
// lo = coperation.createLinkObject("PBOM");
|
// lo.setFromBO(bo2);
|
// lo.setToBO(bo5);
|
// linkList.add(lo);
|
//
|
// lo = coperation.createLinkObject("PBOM");
|
// lo.setFromBO(bo3);
|
// lo.setToBO(bo6);
|
// linkList.add(lo);
|
//
|
// lo = coperation.createLinkObject("PBOM");
|
// lo.setFromBO(bo3);
|
// lo.setToBO(bo7);
|
// linkList.add(lo);
|
//
|
ClientBusinessObject[] bos = new ClientBusinessObject[2];
|
ClientBusinessObject bo1 = operation.createBusinessObject("part");
|
bo1.setAttributeValue("id", "lzm-009", true);
|
bos[0] = bo1;
|
|
ClientBusinessObject bo2 = operation.createBusinessObject("part");
|
bo2.setAttributeValue("id", "lzm-010", true);
|
bos[1] = bo2;
|
|
List<ClientLinkObject> linkList = new ArrayList<ClientLinkObject>();
|
|
ClientLinkObjectOperation coperation = new ClientLinkObjectOperation();
|
ClientLinkObject lo = coperation.createLinkObject("EBOM");
|
lo.setFromBO(bo1);
|
lo.setToBO(bo2);
|
linkList.add(lo);
|
operation.batchSaveCreateBuinessObject(bos, linkList.toArray(new ClientLinkObject[0]));
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
}
|
|
@Test
|
public void testCUDObject() {
|
|
try {
|
ClientBusinessObject[] bos = new ClientBusinessObject[2];
|
ClientBusinessObject bo1 = operation.createBusinessObject("part");
|
bo1.setAttributeValue("id", "lzm-005", true);
|
bos[0] = bo1;
|
|
ClientBusinessObject bo2 = operation.createBusinessObject("part");
|
bo1.setAttributeValue("id", "lzm-006", true);
|
bos[1] = bo2;
|
|
List<ClientLinkObject> linkList = new ArrayList<ClientLinkObject>();
|
|
ClientLinkObjectOperation coperation = new ClientLinkObjectOperation();
|
ClientLinkObject lo = coperation.createLinkObject("EBOM");
|
lo.setFromBO(bo1);
|
lo.setToBO(bo2);
|
linkList.add(lo);
|
|
ClientBusinessObject ucbo1 = operation.readBusinessObjectById("6B7D84EC-244F-C769-CCCC-2C2C79B7D028", "part");
|
ucbo1.setAttributeValue("name", "lzm-002");
|
ClientBusinessObject ucbo2 = operation.readBusinessObjectById("54990B02-1B01-1D04-9C85-EF8A14612230", "part");
|
ucbo2.setAttributeValue("name", "lzm-003");
|
|
ClientBusinessObject[] updatecbos = new ClientBusinessObject[2];
|
updatecbos[0] = ucbo1;
|
updatecbos[1] = ucbo2;
|
|
ClientLinkObject ulo = coperation.readLinkObjectById("F3A2C786-895A-5707-FE7E-D64D190EEA98", "EBOM");
|
ulo.setAttributeValue("sequence", "3");
|
ClientLinkObject[] ulos = new ClientLinkObject[1];
|
ulos[0] = ulo;
|
|
ClientBusinessObject dcbo1 = operation.readBusinessObjectById("FB5D19BA-B521-6951-C6F8-B25A10730489", "part");
|
ClientBusinessObject dcbo2 = operation.readBusinessObjectById("5F667F84-B8B3-9B01-7775-3D4AF920CB9C", "part");
|
|
ClientBusinessObject[] dpdatecbos = new ClientBusinessObject[2];
|
dpdatecbos[0] = dcbo1;
|
dpdatecbos[1] = dcbo2;
|
|
ClientLinkObject dlo = coperation.readLinkObjectById("CB442ECE-B832-E67C-C9BC-EFBC8932FAA4", "EBOM");
|
ClientLinkObject[] dlos = new ClientLinkObject[1];
|
dlos[0] = dlo;
|
|
operation.batchCUDBOLO(bos, linkList.toArray(new ClientLinkObject[0]), updatecbos, ulos, dpdatecbos, dlos);
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
}
|
|
@Test
|
public void testUpdateBO() {
|
boolean rs = false;
|
try {
|
ClientBusinessObject cbo = operation.readBusinessObjectById("C433B01F-F878-9EFE-83A0-C0C68DC398B2", "testclob");
|
File f = new File("C:/Users/liudi/Desktop/a.html");
|
BufferedReader in = new BufferedReader(new FileReader(f));
|
|
StringBuffer s= new StringBuffer();
|
String ss;
|
while((ss=in.readLine())!=null){
|
System.out.print(ss);
|
s.append(ss);
|
}
|
in.close();
|
cbo.setAttributeValue("TESTCLOB".toLowerCase(),s.toString());
|
// cbo.setAttributeValue(BusinessConstants.SELECT_DESCRIPTION, "特色太太太太太太");
|
/* plm.bs.bom.common.AttributeValue[] attrVals = cbo.getBusinessObject().newAttrValList;
|
List<AttributeValue> attrList = new ArrayList<AttributeValue>();
|
for (int i = 0; i < attrVals.length; i++) {
|
attrList.add(attrVals[i]);
|
}
|
AttributeValue av = new AttributeValue();
|
av.attrName = "twoclsf";
|
av.attrVal = "采用标准目录";
|
attrList.add(av);
|
cbo.getBusinessObject().newAttrValList = attrList.toArray(new AttributeValue[0]);*/
|
rs = operation.updateBuinessObject(cbo);
|
System.out.println(rs);
|
} catch (VCIError e) {
|
e.printStackTrace();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
Assert.assertTrue(rs);
|
}
|
|
@Test
|
public void testReadManyObjectById() {
|
try {
|
String[] oids = {"0336E18E-94BF-E892-CF43-2BBD4C9380B5"};
|
ClientBusinessObject[] cbos = operation.readBusinessObjectById(oids, "Filetest");
|
System.out.println(cbos.length);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
@Test
|
public void testDeleteBO() {
|
boolean rs = false;
|
try {
|
ClientBusinessObject cbo = operation.readBusinessObjectById("CF58736E-152A-7EF8-73FA-AC135A536E18", "ChangeClsf");
|
rs = operation.deleteBuinessObject(cbo);
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
Assert.assertTrue(rs);
|
}
|
|
@Test
|
public void testCheckinBO() throws VCIError {
|
ClientBusinessObject cbo = operation.readBusinessObjectById("E8E01F66-4572-1318-A136-7A6EBCD73919", "part");
|
boolean rs = operation.checkinBusinessObject(cbo);
|
Assert.assertTrue(true);
|
}
|
|
|
@Test
|
public void testCheckoutBO() throws VCIError {
|
ClientBusinessObject cbo = operation.readBusinessObjectById("E8E01F66-4572-1318-A136-7A6EBCD73919", "part");
|
boolean rs = operation.checkoutBusinessObject(cbo);
|
Assert.assertTrue(rs);
|
}
|
|
@Test
|
public void testTransferBO() throws VCIError {
|
ClientBusinessObject cbo = operation.readBusinessObjectById("37F926A1-C470-42D2-B17D-B8E35CBAFDF8", "part");
|
|
TransitionVO vo = new TransitionVO();
|
vo.id = "";
|
// vo.source = "Working";
|
// vo.destination = "Auditing";
|
vo.source = "Auditing";
|
vo.destination = "Published";
|
|
// TransitionVOEvent[] events = new TransitionVOEvent[2];
|
// TransitionVOEvent event = new TransitionVOEvent();
|
// event.id = "ttt";
|
// event.name = "plm.EventTest";
|
// events[0] = event;
|
//
|
// TransitionVOEvent event2 = new TransitionVOEvent();
|
// event2.id = "ttt2";
|
// event2.name = "plm.EventTest2";
|
// events[1] = event2;
|
|
// vo.transitionVOEvents = events;
|
boolean rs = operation.transferBusinessObject(cbo, vo, "Released");
|
Assert.assertTrue(rs);
|
}
|
|
@Test
|
public void testBatchTransferBO() throws VCIError {
|
ClientBusinessObject[] cbos = new ClientBusinessObject[2];
|
cbos[0] = operation.readBusinessObjectById("8B9C37C0-933D-4D3B-95E7-9F85E60FE1B5", "part");
|
cbos[1] = operation.readBusinessObjectById("1ABC8C12-7EF5-3140-CF35-D6579C603F76", "part");
|
|
TransitionVO[] vos = new TransitionVO[2];
|
TransitionVO vo1 = new TransitionVO();
|
vo1.id = "";
|
// vo.source = "Working";
|
// vo.destination = "Auditing";
|
vo1.source = "Auditing";
|
vo1.destination = "Released";
|
|
TransitionVO vo2 = new TransitionVO();
|
vo2.id = "";
|
// vo.source = "Working";
|
// vo.destination = "Auditing";
|
vo2.source = "Auditing";
|
vo2.destination = "Released";
|
vos[0] = vo1;
|
vos[1] = vo2;
|
|
// TransitionVOEvent[] events = new TransitionVOEvent[2];
|
// TransitionVOEvent event = new TransitionVOEvent();
|
// event.id = "ttt";
|
// event.name = "plm.EventTest";
|
// events[0] = event;
|
//
|
// TransitionVOEvent event2 = new TransitionVOEvent();
|
// event2.id = "ttt2";
|
// event2.name = "plm.EventTest2";
|
// events[1] = event2;
|
|
// vo.transitionVOEvents = events;
|
String[] status = new String[2];
|
status[0] = "Released";
|
status[1] = "Released";
|
boolean rs = operation.batchTransferBusinessObject(cbos, vos, status);
|
Assert.assertTrue(rs);
|
}
|
|
@Test
|
public void testUndoCheckOutBO() throws VCIError {
|
ClientBusinessObject cbo = operation.readBusinessObjectById("E5433746-04DE-D7B1-927E-9F4EF6C742D9", "ChangeClsf");
|
boolean rs = operation.undoCheckOutBusinessObject(cbo);
|
Assert.assertTrue(rs);
|
}
|
|
@Test
|
public void testChangeBOOwner() throws VCIError {
|
ClientBusinessObject cbo = operation.readBusinessObjectById("E5433746-04DE-D7B1-927E-9F4EF6C742D9", "ChangeClsf");
|
UserObject uo = new UserObject();
|
uo.setId("eddieliu111");
|
boolean rs = operation.changeBusinessObjectOwner(cbo, uo);
|
Assert.assertTrue(true);
|
}
|
|
@Test
|
public void testBatchRevision() {
|
String[] oids = new String[3];
|
oids[0] = "CB832B90-F993-1C76-9886-9734A2D1E56F";
|
oids[1] = "D3054ABB-B8B8-2189-3801-25AD7CCDB856";
|
oids[2] = "DFA37B8B-304B-F9FA-588A-DB4BC58B20C3";
|
String btmName = "Document";
|
boolean rs = false;
|
try {
|
rs = operation.batchRevisonBusinessObject(oids, btmName);
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
Assert.assertTrue(rs);
|
}
|
|
@Test
|
public void testEnoce() {
|
try {
|
String str = "Photo\\云南之旅-刘革辛\\刘革辛_16.jpg";
|
str = str.replace("\\", "/");
|
System.out.println(str);
|
String[] strs = str.split("/");
|
String cStr = "";
|
for (int i = 0; i< strs.length; i++) {
|
strs[i] = URLEncoder.encode(strs[i],"utf-8");
|
System.out.println(strs[i]);
|
cStr += "/" + strs[i];
|
}
|
System.out.println(cStr);
|
} catch (UnsupportedEncodingException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
}
|
}
|