Commit 6c9addfd authored by zhengfunan's avatar zhengfunan

修改方法更新

parent 41dfaa78
...@@ -17,9 +17,7 @@ public class AppConfigurationSamples { ...@@ -17,9 +17,7 @@ public class AppConfigurationSamples {
RemoteSaAuthHandler rsh = new RemoteSaAuthHandler("guantiantian","q1w2e3r4","121.199.160.117",9000); RemoteSaAuthHandler rsh = new RemoteSaAuthHandler("guantiantian","q1w2e3r4","121.199.160.117",9000);
rsh.loginGetSaToken(); rsh.loginGetSaToken();
rsh.serverIP ="150.158.75.213"; rsh.setAppInstance("150.158.75.213",8080,"TXPIMDB");
rsh.serverPort=8080;
rsh.dbName="TXPIMDB";
System.out.println("登录数据"+rsh.toString()); System.out.println("登录数据"+rsh.toString());
//初始化远程查询对象 //初始化远程查询对象
RemoteTdPimHelper rqh = new RemoteTdPimHelper(rsh); RemoteTdPimHelper rqh = new RemoteTdPimHelper(rsh);
...@@ -41,45 +39,45 @@ public class AppConfigurationSamples { ...@@ -41,45 +39,45 @@ public class AppConfigurationSamples {
// ); // );
// System.out.println("查询返回结果:"+ remoteAppConfiguration.getId()+"/"+remoteAppConfiguration.getLabel()+"/"+remoteAppConfiguration.getDesc()); // System.out.println("查询返回结果:"+ remoteAppConfiguration.getId()+"/"+remoteAppConfiguration.getLabel()+"/"+remoteAppConfiguration.getDesc());
List<CatalogRoot> catalogList=rqh.queryAssetByCatalog(id,"CatalogAppView-1129455551755845632"); // List<CatalogRoot> catalogList=rqh.queryAssetByCatalog(id,"CatalogAppView-1129455551755845632");
System.out.println(
"-------------------------------------------" + "\n" +
"SDK queryAssetByCatalog:" + "\n" +
"-------------------------------------------"
);
System.out.println("查询目录资产结果:"+catalogList.toString());
// String re=rqh.deleteAppConfig(id);
// System.out.println( // System.out.println(
// "-------------------------------------------" + "\n" + // "-------------------------------------------" + "\n" +
// "SDK deleteAppConfig:" + "\n" + // "SDK queryAssetByCatalog:" + "\n" +
// "-------------------------------------------" // "-------------------------------------------"
// ); // );
// System.out.println("返回结果:"+re); // System.out.println("查询目录资产结果:"+catalogList.toString());
// CatalogItem catalogItem=new CatalogItem(); // String re=rqh.deleteAppConfig(id);
// catalogItem.setId("Team2-1125463491344334848");
// catalogItem.setAssetID("Product-1126119026813042688");
// String re=rqh.removeAssetFromApp(catalogItem);
// System.out.println( // System.out.println(
// "-------------------------------------------" + "\n" + // "-------------------------------------------" + "\n" +
// "SDK removeAssetFromApp:" + "\n" + // "SDK deleteAppConfig:" + "\n" +
// "-------------------------------------------" // "-------------------------------------------"
// ); // );
// System.out.println("资源移除返回结果:"+re); // System.out.println("返回结果:"+re);
CatalogItem catalogItem=new CatalogItem(); CatalogItem catalogItem=new CatalogItem();
catalogItem.setId("Team2-1125463491344334848"); catalogItem.setId("Team2-1125463491344334848");
catalogItem.setAssetID("Product-1126119026813042688"); catalogItem.setAssetID("Product-1126119026813042688");
catalogItem.setCatalogID("CatalogAppView-1126118732670697472"); String re=rqh.removeAssetFromApp(catalogItem);
String re=rqh.addAssetRefToAppConfig(JSONObject.parseObject(removeAppConfig, CatalogItem.class));
System.out.println( System.out.println(
"-------------------------------------------" + "\n" + "-------------------------------------------" + "\n" +
"SDK addAssetRefToAppConfig:" + "\n" + "SDK removeAssetFromApp:" + "\n" +
"-------------------------------------------" "-------------------------------------------"
); );
System.out.println("资产加入业务返回结果:"+re); System.out.println("资源移除返回结果:"+re);
// CatalogItem catalogItem=new CatalogItem();
// catalogItem.setId("Team2-1125463491344334848");
// catalogItem.setAssetID("Product-1126119026813042688");
// catalogItem.setCatalogID("CatalogAppView-1126118732670697472");
// String re=rqh.addAssetRefToAppConfig(JSONObject.parseObject(removeAppConfig, CatalogItem.class));
// System.out.println(
// "-------------------------------------------" + "\n" +
// "SDK addAssetRefToAppConfig:" + "\n" +
// "-------------------------------------------"
// );
// System.out.println("资产加入业务返回结果:"+re);
} }
......
...@@ -15,9 +15,7 @@ public class AssetSamples { ...@@ -15,9 +15,7 @@ public class AssetSamples {
public static void main(String[] args) { public static void main(String[] args) {
RemoteSaAuthHandler rsh = new RemoteSaAuthHandler("guantiantian","q1w2e3r4","121.199.160.117",9000); RemoteSaAuthHandler rsh = new RemoteSaAuthHandler("guantiantian","q1w2e3r4","121.199.160.117",9000);
rsh.loginGetSaToken(); rsh.loginGetSaToken();
rsh.serverIP ="150.158.75.213"; rsh.setAppInstance("150.158.75.213",8080,"TXPIMDB");
rsh.serverPort=8080;
rsh.dbName="TXPIMDB";
System.out.println("登录数据"+rsh.toString()); System.out.println("登录数据"+rsh.toString());
//初始化远程查询对象 //初始化远程查询对象
RemoteTdPimHelper rqh = new RemoteTdPimHelper(rsh); RemoteTdPimHelper rqh = new RemoteTdPimHelper(rsh);
...@@ -30,9 +28,15 @@ public class AssetSamples { ...@@ -30,9 +28,15 @@ public class AssetSamples {
); );
System.out.println("创建返回结果:"+id); System.out.println("创建返回结果:"+id);
RemoteAsset remoteAsset=rqh.fetchAsset(id);
System.out.println(
"-------------------------------------------" + "\n" +
"SDK fetchAsset:" + "\n" +
"-------------------------------------------"
);
System.out.println("查询资产:"+ remoteAsset.getId()+"/"+remoteAsset.getLabel()+"/"+remoteAsset.getDesc());
//修改资产的数值 //修改资产的数值
AssetVo assetVo=new AssetVo();
assetVo.setId(id);
AssetVo.AssetField assetField=new AssetVo.AssetField(); AssetVo.AssetField assetField=new AssetVo.AssetField();
assetField.setKey("td_data_center"); assetField.setKey("td_data_center");
assetField.setMode("tdpim.dict.system.metadata.mode.single.select.value"); assetField.setMode("tdpim.dict.system.metadata.mode.single.select.value");
...@@ -41,9 +45,8 @@ public class AssetSamples { ...@@ -41,9 +45,8 @@ public class AssetSamples {
//添加修改项,可以多个 //添加修改项,可以多个
list.add(assetField); list.add(assetField);
assetVo.setFields(list);
//执行修改 //执行修改
String re=rqh.updateAssetValues(assetVo); String re = remoteAsset.updateAssetValues(list);
System.out.println( System.out.println(
"-------------------------------------------" + "\n" + "-------------------------------------------" + "\n" +
...@@ -52,13 +55,7 @@ public class AssetSamples { ...@@ -52,13 +55,7 @@ public class AssetSamples {
); );
System.out.println("修改返回结果:"+re); System.out.println("修改返回结果:"+re);
RemoteAsset remoteAsset=rqh.fetchAsset(id);
System.out.println(
"-------------------------------------------" + "\n" +
"SDK fetchAsset:" + "\n" +
"-------------------------------------------"
);
System.out.println("查询资产:"+ remoteAsset.getId()+"/"+remoteAsset.getLabel()+"/"+remoteAsset.getDesc());
re=rqh.deleteAsset(id); re=rqh.deleteAsset(id);
System.out.println( System.out.println(
......
...@@ -14,10 +14,8 @@ public class DocumentSamples { ...@@ -14,10 +14,8 @@ public class DocumentSamples {
public static void main(String[] args) { public static void main(String[] args) {
RemoteSaAuthHandler rsh = new RemoteSaAuthHandler("guantiantian","q1w2e3r4","121.199.160.117",9000); RemoteSaAuthHandler rsh = new RemoteSaAuthHandler("guantiantian","q1w2e3r4","121.199.160.117",9000);
rsh.loginGetSaToken(); rsh.loginGetSaToken();
// rsh.serverIP ="127.0.0.1"; System.out.println("登录数据"+rsh.toString());
rsh.serverIP ="150.158.75.213"; rsh.setAppInstance("150.158.75.213",8080,"TXPIMDB");
rsh.serverPort=8080;
rsh.dbName="TXPIMDB";
//初始化远程查询对象 //初始化远程查询对象
RemoteTdPimHelper rqh = new RemoteTdPimHelper(rsh); RemoteTdPimHelper rqh = new RemoteTdPimHelper(rsh);
...@@ -39,8 +37,6 @@ public class DocumentSamples { ...@@ -39,8 +37,6 @@ public class DocumentSamples {
System.out.println("查询文档:"+ remoteDocument.getId()+"/"+remoteDocument.getLabel()+"/"+remoteDocument.getDesc()); System.out.println("查询文档:"+ remoteDocument.getId()+"/"+remoteDocument.getLabel()+"/"+remoteDocument.getDesc());
// //
AssetVo assetVo=new AssetVo();
assetVo.setId(id);
AssetVo.AssetField assetField=new AssetVo.AssetField(); AssetVo.AssetField assetField=new AssetVo.AssetField();
assetField.setKey("td_asset_number"); assetField.setKey("td_asset_number");
assetField.setMode("tdpim.dict.system.metadata.mode.single.value"); assetField.setMode("tdpim.dict.system.metadata.mode.single.value");
...@@ -48,9 +44,8 @@ public class DocumentSamples { ...@@ -48,9 +44,8 @@ public class DocumentSamples {
List<AssetVo.AssetField> list=new LinkedList<>(); List<AssetVo.AssetField> list=new LinkedList<>();
//添加修改项,可以多个 //添加修改项,可以多个
list.add(assetField); list.add(assetField);
assetVo.setFields(list);
//执行修改 //执行修改
String re=rqh.updateDocumentValues(assetVo); String re=remoteDocument.updateDocumentValues(list);
System.out.println( System.out.println(
"-------------------------------------------" + "\n" + "-------------------------------------------" + "\n" +
"SDK updateDocumentValues:" + "\n" + "SDK updateDocumentValues:" + "\n" +
......
...@@ -10,9 +10,7 @@ public class LoginSamples { ...@@ -10,9 +10,7 @@ public class LoginSamples {
rsh.loginGetSaToken(); rsh.loginGetSaToken();
rsh.serverIP ="150.158.75.213"; rsh.setAppInstance("150.158.75.213",8080,"TXPIMDB");
rsh.serverPort=8080;
rsh.dbName="TXPIMDB";
System.out.println(rsh); System.out.println(rsh);
......
...@@ -17,9 +17,7 @@ public class QuerySamples { ...@@ -17,9 +17,7 @@ public class QuerySamples {
RemoteSaAuthHandler rsh = new RemoteSaAuthHandler("guantiantian","q1w2e3r4","121.199.160.117",9000); RemoteSaAuthHandler rsh = new RemoteSaAuthHandler("guantiantian","q1w2e3r4","121.199.160.117",9000);
rsh.loginGetSaToken(); rsh.loginGetSaToken();
rsh.serverIP ="150.158.75.213"; rsh.setAppInstance("150.158.75.213",8080,"TXPIMDB");
rsh.serverPort=8080;
rsh.dbName="TXPIMDB";
//初始化远程查询对象 //初始化远程查询对象
RemoteTdPimHelper rqh = new RemoteTdPimHelper(rsh); RemoteTdPimHelper rqh = new RemoteTdPimHelper(rsh);
......
...@@ -8,13 +8,12 @@ import com.tongda.tdpimssdk.resultVo.vo.AssetVo; ...@@ -8,13 +8,12 @@ import com.tongda.tdpimssdk.resultVo.vo.AssetVo;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
public class NewSample { public class UpdateSample {
public static void main(String[] args) { public static void main(String[] args) {
RemoteSaAuthHandler rsh = new RemoteSaAuthHandler("guantiantian","q1w2e3r4","121.199.160.117",9000); RemoteSaAuthHandler rsh = new RemoteSaAuthHandler("guantiantian","q1w2e3r4","121.199.160.117",9000);
rsh.setAppInstance("150.158.75.213",8080,"TXPIMDB"); rsh.setAppInstance("150.158.75.213",8080,"TXPIMDB");
rsh.loginGetSaToken(); rsh.loginGetSaToken();
//初始化远程查询对象 //初始化远程查询对象
RemoteTdPimHelper rqh = new RemoteTdPimHelper(rsh); RemoteTdPimHelper rqh = new RemoteTdPimHelper(rsh);
RemoteAsset ra = rqh.fetchAsset("Product-1125789659889139712"); RemoteAsset ra = rqh.fetchAsset("Product-1125789659889139712");
...@@ -32,5 +31,11 @@ public class NewSample { ...@@ -32,5 +31,11 @@ public class NewSample {
System.out.println(ret); System.out.println(ret);
} }
} }
package com.tongda.tdpimssdk.remote; package com.tongda.tdpimssdk.remote;
import com.alibaba.fastjson.JSONObject;
import com.tongda.tdpimssdk.entities.Resource; import com.tongda.tdpimssdk.entities.Resource;
import com.tongda.tdpimssdk.http.PimHttpUtil;
import com.tongda.tdpimssdk.resultVo.vo.AssetVo;
import lombok.Data;
import java.util.List;
import static com.tongda.tdpimssdk.http.PimHttpUtil.resultUtil;
@Data
public class RemoteDocument extends Resource { public class RemoteDocument extends Resource {
protected RemoteSaAuthHandler rsh;
public String updateDocumentValues(List<AssetVo.AssetField> fields){
AssetVo assetVo=new AssetVo();
assetVo.setId(this.id);
assetVo.setFields(fields);
String url="http://"+ this.rsh.serverIP +":"+ this.rsh.serverPort+"/pims/asset/document/field?dbName="+this.rsh.dbName;
String response= PimHttpUtil.sendPut(this.rsh.saToken,url,(JSONObject)JSONObject.toJSON(assetVo));
String s= resultUtil(response);
return s;
}
} }
...@@ -16,7 +16,8 @@ import java.util.List; ...@@ -16,7 +16,8 @@ import java.util.List;
import static com.tongda.tdpimssdk.http.PimHttpUtil.resultUtil; import static com.tongda.tdpimssdk.http.PimHttpUtil.resultUtil;
public class RemoteTdPimHelper { public class
RemoteTdPimHelper {
RemoteSaAuthHandler rsh; RemoteSaAuthHandler rsh;
public RemoteTdPimHelper(RemoteSaAuthHandler rsh){ public RemoteTdPimHelper(RemoteSaAuthHandler rsh){
...@@ -169,7 +170,9 @@ public class RemoteTdPimHelper { ...@@ -169,7 +170,9 @@ public class RemoteTdPimHelper {
String url="http://"+ this.rsh.serverIP +":"+this.rsh.serverPort+"/pims/document/content?dbName="+this.rsh.dbName+"&id="+id; String url="http://"+ this.rsh.serverIP +":"+this.rsh.serverPort+"/pims/document/content?dbName="+this.rsh.dbName+"&id="+id;
String response= PimHttpUtil.sendGet(this.rsh.saToken,url); String response= PimHttpUtil.sendGet(this.rsh.saToken,url);
String s= resultUtil(response); String s= resultUtil(response);
return JSONObject.parseArray(s,RemoteDocument.class).get(0); RemoteDocument remoteDocument=JSONObject.parseArray(s,RemoteDocument.class).get(0);
remoteDocument.setRsh(rsh);
return remoteDocument;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment