Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
TDPIMS-SDK
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhengfunan
TDPIMS-SDK
Commits
a953e9fe
Commit
a953e9fe
authored
Sep 11, 2023
by
zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
82f7ad21
Show whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
1396 additions
and
1797 deletions
+1396
-1797
AssetAbstract.java
...ain/java/com/tongda/tdpimssdk/entities/AssetAbstract.java
+12
-219
Product.java
src/main/java/com/tongda/tdpimssdk/entities/Product.java
+2
-403
Resource.java
src/main/java/com/tongda/tdpimssdk/entities/Resource.java
+1
-10
Role.java
src/main/java/com/tongda/tdpimssdk/entities/common/Role.java
+3
-3
Team2.java
...main/java/com/tongda/tdpimssdk/entities/common/Team2.java
+2
-0
AppConfigurationSamples.java
...om/tongda/tdpimssdk/examples/AppConfigurationSamples.java
+0
-102
AssetSamples.java
...main/java/com/tongda/tdpimssdk/examples/AssetSamples.java
+0
-427
DocumentSamples.java
...n/java/com/tongda/tdpimssdk/examples/DocumentSamples.java
+0
-114
LoginSamples.java
...main/java/com/tongda/tdpimssdk/examples/LoginSamples.java
+0
-18
NewAssetSample.java
...in/java/com/tongda/tdpimssdk/examples/NewAssetSample.java
+132
-0
NewDocumentSample.java
...java/com/tongda/tdpimssdk/examples/NewDocumentSample.java
+131
-0
NewTeamSample.java
...ain/java/com/tongda/tdpimssdk/examples/NewTeamSample.java
+131
-0
QuerySamples.java
...main/java/com/tongda/tdpimssdk/examples/QuerySamples.java
+0
-93
UpdateSample.java
...main/java/com/tongda/tdpimssdk/examples/UpdateSample.java
+0
-41
PimHttpUtil.java
src/main/java/com/tongda/tdpimssdk/http/PimHttpUtil.java
+6
-5
RemoteAppConfiguration.java
...a/com/tongda/tdpimssdk/remote/RemoteAppConfiguration.java
+0
-9
RemoteAsset.java
src/main/java/com/tongda/tdpimssdk/remote/RemoteAsset.java
+0
-27
RemoteDocument.java
...main/java/com/tongda/tdpimssdk/remote/RemoteDocument.java
+0
-27
RemoteSaAuthHandler.java
...java/com/tongda/tdpimssdk/remote/RemoteSaAuthHandler.java
+2
-1
RemoteTdPimHelper.java
...n/java/com/tongda/tdpimssdk/remote/RemoteTdPimHelper.java
+0
-292
RemoteAbstractEntity.java
.../tongda/tdpimssdk/remote/common/RemoteAbstractEntity.java
+35
-0
RemoteAbstractTeam.java
...om/tongda/tdpimssdk/remote/common/RemoteAbstractTeam.java
+20
-0
RemoteMetadataMode.java
...om/tongda/tdpimssdk/remote/common/RemoteMetadataMode.java
+10
-0
RemoteAsset.java
.../java/com/tongda/tdpimssdk/remote/entity/RemoteAsset.java
+68
-0
RemoteDocument.java
...va/com/tongda/tdpimssdk/remote/entity/RemoteDocument.java
+81
-0
RemoteTeam.java
...n/java/com/tongda/tdpimssdk/remote/entity/RemoteTeam.java
+79
-0
AssetParamSet.java
...a/com/tongda/tdpimssdk/remote/paramset/AssetParamSet.java
+414
-0
TeamParamSet.java
...va/com/tongda/tdpimssdk/remote/paramset/TeamParamSet.java
+197
-0
AssetVo.java
src/main/java/com/tongda/tdpimssdk/resultVo/vo/AssetVo.java
+70
-6
No files found.
src/main/java/com/tongda/tdpimssdk/entities/AssetAbstract.java
View file @
a953e9fe
package
com
.
tongda
.
tdpimssdk
.
entities
;
import
com.tongda.tdpimssdk.entities.common.*
;
import
lombok.Data
;
import
java.math.BigInteger
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlAttribute
;
import
javax.xml.bind.annotation.XmlElement
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
javax.xml.bind.annotation.XmlType
;
@Data
public
class
AssetAbstract
{
...
...
@@ -32,226 +34,17 @@ public class AssetAbstract {
protected
BigInteger
version
;
/**
* Gets the value of the field property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the field property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getField().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Field }
*
*
*/
public
List
<
Field
>
getField
()
{
if
(
field
==
null
)
{
field
=
new
ArrayList
<
Field
>();
}
return
this
.
field
;
}
/**
* 获取id属性的值。
*
* @return
* possible object is
* {@link String }
*
*/
public
String
getId
()
{
return
id
;
}
/**
* 设置id属性的值。
*
* @param value
* allowed object is
* {@link String }
*
*/
public
void
setId
(
String
value
)
{
this
.
id
=
value
;
}
/**
* 获取dbHash属性的值。
*
* @return
* possible object is
* {@link String }
*
*/
public
String
getDbHash
()
{
return
dbHash
;
}
/**
* 设置dbHash属性的值。
*
* @param value
* allowed object is
* {@link String }
*
*/
public
void
setDbHash
(
String
value
)
{
this
.
dbHash
=
value
;
}
/**
* 获取label属性的值。
*
* @return
* possible object is
* {@link String }
*
*/
public
String
getLabel
()
{
return
label
;
}
/**
* 设置label属性的值。
*
* @param value
* allowed object is
* {@link String }
*
*/
public
void
setLabel
(
String
value
)
{
this
.
label
=
value
;
}
/**
* 获取template属性的值。
*
* @return
* possible object is
* {@link String }
*
*/
public
String
getTemplate
()
{
return
template
;
}
/**
* 设置template属性的值。
*
* @param value
* allowed object is
* {@link String }
*
*/
public
void
setTemplate
(
String
value
)
{
this
.
template
=
value
;
}
/**
* 获取status属性的值。
*
* @return
* possible object is
* {@link String }
*
*/
public
String
getStatus
()
{
return
status
;
}
@XmlElement
(
name
=
"MetadataGroup"
,
required
=
true
)
protected
MetadataGroup
metadataGroup
;
/**
* 设置status属性的值。
*
* @param value
* allowed object is
* {@link String }
*
*/
public
void
setStatus
(
String
value
)
{
this
.
status
=
value
;
}
@XmlElement
(
name
=
"Permission"
,
required
=
true
)
protected
Permission
permission
;
/**
* 获取lcRef属性的值。
*
* @return
* possible object is
* {@link String }
*
*/
public
String
getLcRef
()
{
return
lcRef
;
}
@XmlElement
(
name
=
"Desc"
,
required
=
true
)
protected
Desc
desc
;
/**
* 设置lcRef属性的值。
*
* @param value
* allowed object is
* {@link String }
*
*/
public
void
setLcRef
(
String
value
)
{
this
.
lcRef
=
value
;
}
/**
* 获取lcStatus属性的值。
*
* @return
* possible object is
* {@link String }
*
*/
public
String
getLcStatus
()
{
return
lcStatus
;
}
/**
* 设置lcStatus属性的值。
*
* @param value
* allowed object is
* {@link String }
*
*/
public
void
setLcStatus
(
String
value
)
{
this
.
lcStatus
=
value
;
}
/**
* 获取version属性的值。
*
* @return
* possible object is
* {@link BigInteger }
*
*/
public
BigInteger
getVersion
()
{
return
version
;
}
/**
* 设置version属性的值。
*
* @param value
* allowed object is
* {@link BigInteger }
*
*/
public
void
setVersion
(
BigInteger
value
)
{
this
.
version
=
value
;
}
@XmlElement
(
name
=
"History"
,
required
=
true
)
protected
History
history
;
/**
...
...
src/main/java/com/tongda/tdpimssdk/entities/Product.java
View file @
a953e9fe
package
com
.
tongda
.
tdpimssdk
.
entities
;
import
com.tongda.tdpimssdk.entities.common.Desc
;
import
com.tongda.tdpimssdk.entities.common.History
;
import
com.tongda.tdpimssdk.entities.common.Permission
;
import
com.tongda.tdpimssdk.entities.common.TSVariableDef
;
import
lombok.Data
;
import
java.math.BigInteger
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlAttribute
;
import
javax.xml.bind.annotation.XmlElement
;
import
javax.xml.bind.annotation.XmlType
;
...
...
@@ -52,6 +45,7 @@ import javax.xml.bind.annotation.XmlType;
*
*/
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
@Data
@XmlType
(
name
=
"Product"
,
propOrder
=
{
"permission"
,
"desc"
,
...
...
@@ -62,403 +56,8 @@ import javax.xml.bind.annotation.XmlType;
})
public
class
Product
extends
AssetAbstract
{
@XmlElement
(
name
=
"Permission"
,
required
=
true
)
protected
Permission
permission
;
@XmlElement
(
name
=
"Desc"
,
required
=
true
)
protected
Desc
desc
;
@XmlElement
(
name
=
"History"
,
required
=
true
)
protected
History
history
;
@XmlElement
(
name
=
"MetadataGroup"
,
required
=
true
)
protected
MetadataGroup
metadataGroup
;
@XmlElement
(
name
=
"ResourceCatalog"
,
required
=
true
)
protected
ResourceCatalog
resourceCatalog
;
@XmlElement
(
name
=
"TSVariableDefGroup"
,
required
=
true
)
protected
TSVariableDefGroup
tsVariableDefGroup
;
@XmlAttribute
(
name
=
"id"
)
protected
String
id
;
@XmlAttribute
(
name
=
"dbHash"
)
protected
String
dbHash
;
@XmlAttribute
(
name
=
"label"
)
protected
String
label
;
@XmlAttribute
(
name
=
"template"
)
protected
String
template
;
@XmlAttribute
(
name
=
"lcRef"
)
protected
String
lcRef
;
@XmlAttribute
(
name
=
"lcStatus"
)
protected
String
lcStatus
;
@XmlAttribute
(
name
=
"version"
)
protected
BigInteger
version
;
/**
* 获取permission属性的值。
*
* @return
* possible object is
* {@link Permission }
*
*/
public
Permission
getPermission
()
{
return
permission
;
}
/**
* 设置permission属性的值。
*
* @param value
* allowed object is
* {@link Permission }
*
*/
public
void
setPermission
(
Permission
value
)
{
this
.
permission
=
value
;
}
/**
* 获取desc属性的值。
*
* @return
* possible object is
* {@link Desc }
*
*/
public
Desc
getDesc
()
{
return
desc
;
}
/**
* 设置desc属性的值。
*
* @param value
* allowed object is
* {@link Desc }
*
*/
public
void
setDesc
(
Desc
value
)
{
this
.
desc
=
value
;
}
/**
* 获取history属性的值。
*
* @return
* possible object is
* {@link History }
*
*/
public
History
getHistory
()
{
return
history
;
}
/**
* 设置history属性的值。
*
* @param value
* allowed object is
* {@link History }
*
*/
public
void
setHistory
(
History
value
)
{
this
.
history
=
value
;
}
/**
* 获取metadataGroup属性的值。
*
* @return
* possible object is
* {@link MetadataGroup }
*
*/
public
MetadataGroup
getMetadataGroup
()
{
return
metadataGroup
;
}
/**
* 设置metadataGroup属性的值。
*
* @param value
* allowed object is
* {@link MetadataGroup }
*
*/
public
void
setMetadataGroup
(
MetadataGroup
value
)
{
this
.
metadataGroup
=
value
;
}
/**
* 获取resourceCatalog属性的值。
*
* @return
* possible object is
* {@link ResourceCatalog }
*
*/
public
ResourceCatalog
getResourceCatalog
()
{
return
resourceCatalog
;
}
/**
* 设置resourceCatalog属性的值。
*
* @param value
* allowed object is
* {@link ResourceCatalog }
*
*/
public
void
setResourceCatalog
(
ResourceCatalog
value
)
{
this
.
resourceCatalog
=
value
;
}
/**
* 获取tsVariableDefGroup属性的值。
*
* @return
* possible object is
* {@link TSVariableDefGroup }
*
*/
public
TSVariableDefGroup
getTSVariableDefGroup
()
{
return
tsVariableDefGroup
;
}
/**
* 设置tsVariableDefGroup属性的值。
*
* @param value
* allowed object is
* {@link TSVariableDefGroup }
*
*/
public
void
setTSVariableDefGroup
(
TSVariableDefGroup
value
)
{
this
.
tsVariableDefGroup
=
value
;
}
/**
* 获取id属性的值。
*
* @return
* possible object is
* {@link String }
*
*/
public
String
getId
()
{
return
id
;
}
/**
* 设置id属性的值。
*
* @param value
* allowed object is
* {@link String }
*
*/
public
void
setId
(
String
value
)
{
this
.
id
=
value
;
}
/**
* 获取dbHash属性的值。
*
* @return
* possible object is
* {@link String }
*
*/
public
String
getDbHash
()
{
return
dbHash
;
}
/**
* 设置dbHash属性的值。
*
* @param value
* allowed object is
* {@link String }
*
*/
public
void
setDbHash
(
String
value
)
{
this
.
dbHash
=
value
;
}
/**
* 获取label属性的值。
*
* @return
* possible object is
* {@link String }
*
*/
public
String
getLabel
()
{
return
label
;
}
/**
* 设置label属性的值。
*
* @param value
* allowed object is
* {@link String }
*
*/
public
void
setLabel
(
String
value
)
{
this
.
label
=
value
;
}
/**
* 获取template属性的值。
*
* @return
* possible object is
* {@link String }
*
*/
public
String
getTemplate
()
{
return
template
;
}
/**
* 设置template属性的值。
*
* @param value
* allowed object is
* {@link String }
*
*/
public
void
setTemplate
(
String
value
)
{
this
.
template
=
value
;
}
/**
* 获取lcRef属性的值。
*
* @return
* possible object is
* {@link String }
*
*/
public
String
getLcRef
()
{
return
lcRef
;
}
/**
* 设置lcRef属性的值。
*
* @param value
* allowed object is
* {@link String }
*
*/
public
void
setLcRef
(
String
value
)
{
this
.
lcRef
=
value
;
}
/**
* 获取lcStatus属性的值。
*
* @return
* possible object is
* {@link String }
*
*/
public
String
getLcStatus
()
{
return
lcStatus
;
}
/**
* 设置lcStatus属性的值。
*
* @param value
* allowed object is
* {@link String }
*
*/
public
void
setLcStatus
(
String
value
)
{
this
.
lcStatus
=
value
;
}
/**
* 获取version属性的值。
*
* @return
* possible object is
* {@link BigInteger }
*
*/
public
BigInteger
getVersion
()
{
return
version
;
}
/**
* 设置version属性的值。
*
* @param value
* allowed object is
* {@link BigInteger }
*
*/
public
void
setVersion
(
BigInteger
value
)
{
this
.
version
=
value
;
}
/**
* <p>anonymous complex type的 Java 类。
*
* <p>以下模式片段指定包含在此类中的预期内容。
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element ref="{}TSVariableDef" maxOccurs="unbounded" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
@XmlType
(
name
=
""
,
propOrder
=
{
"tsVariableDef"
})
public
static
class
TSVariableDefGroup
{
@XmlElement
(
name
=
"TSVariableDef"
)
protected
List
<
TSVariableDef
>
tsVariableDef
;
/**
* Gets the value of the tsVariableDef property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the tsVariableDef property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getTSVariableDef().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link TSVariableDef }
*
*
*/
public
List
<
TSVariableDef
>
getTSVariableDef
()
{
if
(
tsVariableDef
==
null
)
{
tsVariableDef
=
new
ArrayList
<
TSVariableDef
>();
}
return
this
.
tsVariableDef
;
}
}
}
src/main/java/com/tongda/tdpimssdk/entities/Resource.java
View file @
a953e9fe
...
...
@@ -47,16 +47,7 @@ import javax.xml.bind.annotation.XmlType;
"history"
,
"metadataGroup"
})
public
class
Resource
extends
AbstractDBEntity
{
@XmlElement
(
name
=
"Permission"
,
required
=
true
)
protected
Permission
permission
;
@XmlElement
(
name
=
"Desc"
,
required
=
true
)
protected
Desc
desc
;
@XmlElement
(
name
=
"History"
,
required
=
true
)
protected
History
history
;
@XmlElement
(
name
=
"MetadataGroup"
,
required
=
true
)
protected
MetadataGroup
metadataGroup
;
public
class
Resource
extends
AssetAbstract
{
@XmlAttribute
(
name
=
"href"
)
protected
String
href
;
@XmlAttribute
(
name
=
"mediatype"
)
...
...
src/main/java/com/tongda/tdpimssdk/entities/common/Role.java
View file @
a953e9fe
...
...
@@ -49,7 +49,7 @@ public class Role {
@XmlAttribute
(
name
=
"label"
)
protected
String
label
;
@XmlAttribute
(
name
=
"roleCode"
)
protected
S
hort
roleCode
;
protected
S
tring
roleCode
;
/**
* 获取permDef属性的值。
...
...
@@ -155,7 +155,7 @@ public class Role {
* {@link Short }
*
*/
public
S
hort
getRoleCode
()
{
public
S
tring
getRoleCode
()
{
return
roleCode
;
}
...
...
@@ -167,7 +167,7 @@ public class Role {
* {@link Short }
*
*/
public
void
setRoleCode
(
S
hort
value
)
{
public
void
setRoleCode
(
S
tring
value
)
{
this
.
roleCode
=
value
;
}
...
...
src/main/java/com/tongda/tdpimssdk/entities/common/Team2.java
View file @
a953e9fe
...
...
@@ -138,6 +138,8 @@ public class Team2 {
protected
RelationList
relationList
;
@XmlElement
(
name
=
"AssetCatalog"
,
required
=
true
)
protected
AssetCatalog
assetCatalog
;
@XmlAttribute
(
name
=
"id"
)
protected
String
id
;
@XmlAttribute
(
name
=
"label"
)
...
...
src/main/java/com/tongda/tdpimssdk/examples/AppConfigurationSamples.java
deleted
100644 → 0
View file @
82f7ad21
package
com
.
tongda
.
tdpimssdk
.
examples
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tongda.tdpimssdk.entities.common.Catalog
;
import
com.tongda.tdpimssdk.entities.common.CatalogRoot
;
import
com.tongda.tdpimssdk.remote.RemoteAppConfiguration
;
import
com.tongda.tdpimssdk.remote.RemoteSaAuthHandler
;
import
com.tongda.tdpimssdk.remote.RemoteTdPimHelper
;
import
com.tongda.tdpimssdk.resultVo.vo.AssetVo
;
import
com.tongda.tdpimssdk.resultVo.vo.CatalogItem
;
import
com.tongda.tdpimssdk.resultVo.vo.TeamVo
;
import
java.util.List
;
public
class
AppConfigurationSamples
{
public
static
void
main
(
String
[]
args
)
{
RemoteSaAuthHandler
rsh
=
new
RemoteSaAuthHandler
(
"guantiantian"
,
"q1w2e3r4"
,
"121.199.160.117"
,
9000
);
rsh
.
loginGetSaToken
();
rsh
.
setAppInstance
(
"150.158.75.213"
,
8080
,
"TXPIMDB"
);
System
.
out
.
println
(
"登录数据"
+
rsh
.
toString
());
//初始化远程查询对象
RemoteTdPimHelper
rqh
=
new
RemoteTdPimHelper
(
rsh
);
String
id
;
// id=rqh.createAppConfig(JSONObject.parseObject(createAppConfig, TeamVo.class));
// System.out.println(
// "-------------------------------------------" + "\n" +
// "SDK createAppConfig:" + "\n" +
// "-------------------------------------------"
// );
// System.out.println("创建返回结果:"+id);
id
=
"Team2-1131290597932400640"
;
// RemoteAppConfiguration remoteAppConfiguration=rqh.fetchAppConfig(id);
// System.out.println(
// "-------------------------------------------" + "\n" +
// "SDK fetchAppConfig:" + "\n" +
// "-------------------------------------------"
// );
// System.out.println("查询返回结果:"+ remoteAppConfiguration.getId()+"/"+remoteAppConfiguration.getLabel()+"/"+remoteAppConfiguration.getDesc());
// 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(
// "-------------------------------------------" + "\n" +
// "SDK deleteAppConfig:" + "\n" +
// "-------------------------------------------"
// );
// System.out.println("返回结果:"+re);
CatalogItem
catalogItem
=
new
CatalogItem
();
catalogItem
.
setId
(
"Team2-1125463491344334848"
);
catalogItem
.
setAssetID
(
"Product-1126119026813042688"
);
String
re
=
rqh
.
removeAssetFromApp
(
catalogItem
);
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK removeAssetFromApp:"
+
"\n"
+
"-------------------------------------------"
);
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);
}
public
static
String
removeAppConfig
=
"{\n"
+
" \"id\": \"Team2-1125463491344334848\",\n"
+
" \"assetID\": \"Product-1126119026813042688\"\n"
+
"}"
;
public
static
String
createAppConfig
=
"{\n"
+
" \"userId\": \"EndUser-1128343251971997696\",\n"
+
" \"label\": \"test16\",\n"
+
" \"desc\": \"test\",\n"
+
" \"lifecycleID\": \"TDLifeCycleDefinition-Common\"\n"
+
"}"
;
public
static
String
updateAppConfig
=
"{\n"
+
" \"userId\": \"EndUser-1128343251971997696\",\n"
+
" \"label\": \"test16\",\n"
+
" \"desc\": \"test\",\n"
+
" \"lifecycleID\": \"TDLifeCycleDefinition-Common\"\n"
+
"}"
;
}
src/main/java/com/tongda/tdpimssdk/examples/AssetSamples.java
deleted
100644 → 0
View file @
82f7ad21
package
com
.
tongda
.
tdpimssdk
.
examples
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tongda.tdpimssdk.entities.AssetAbstract
;
import
com.tongda.tdpimssdk.remote.RemoteAsset
;
import
com.tongda.tdpimssdk.remote.RemoteSaAuthHandler
;
import
com.tongda.tdpimssdk.remote.RemoteTdPimHelper
;
import
com.tongda.tdpimssdk.resultVo.vo.AssetVo
;
import
java.util.LinkedList
;
import
java.util.List
;
public
class
AssetSamples
{
public
static
void
main
(
String
[]
args
)
{
RemoteSaAuthHandler
rsh
=
new
RemoteSaAuthHandler
(
"guantiantian"
,
"q1w2e3r4"
,
"121.199.160.117"
,
9000
);
rsh
.
loginGetSaToken
();
rsh
.
setAppInstance
(
"150.158.75.213"
,
8080
,
"TXPIMDB"
);
System
.
out
.
println
(
"登录数据"
+
rsh
.
toString
());
//初始化远程查询对象
RemoteTdPimHelper
rqh
=
new
RemoteTdPimHelper
(
rsh
);
//创建资产
String
id
=
rqh
.
createAsset
(
JSONObject
.
parseObject
(
createAsset
,
AssetVo
.
class
));
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK createAsset:"
+
"\n"
+
"-------------------------------------------"
);
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
.
AssetField
assetField
=
new
AssetVo
.
AssetField
();
assetField
.
setKey
(
"td_data_center"
);
assetField
.
setMode
(
"tdpim.dict.system.metadata.mode.single.select.value"
);
assetField
.
setValue
(
"北京一区"
);
List
<
AssetVo
.
AssetField
>
list
=
new
LinkedList
<>();
//添加修改项,可以多个
list
.
add
(
assetField
);
//执行修改
String
re
=
remoteAsset
.
updateAssetValues
(
list
);
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK updateAssetValues:"
+
"\n"
+
"-------------------------------------------"
);
System
.
out
.
println
(
"修改返回结果:"
+
re
);
re
=
rqh
.
deleteAsset
(
id
);
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK deleteAsset:"
+
"\n"
+
"-------------------------------------------"
);
System
.
out
.
println
(
"删除资产:"
+
re
);
}
public
static
String
updateAsset
=
"{\n"
+
" \"id\": \"Product-1129487294932189184\",\n"
+
" \"fields\": [\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_data_center\",\n"
+
" \"value\": \"北京一区\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" }\n"
+
" ]\n"
+
"}"
;
public
static
String
createAsset
=
"{\n"
+
" \"templateID\": \"ProductTemplate-1110986502562643968\",\n"
+
" \"label\": \"安全设备\",\n"
+
" \"fields\": [\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_number\",\n"
+
" \"value\": \"test\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_name\",\n"
+
" \"value\": \"test\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_subtype\",\n"
+
" \"value\": \"安全设备\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_serial_number\",\n"
+
" \"value\": \"test\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_belong_project\",\n"
+
" \"value\": \"test\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_desc\",\n"
+
" \"value\": \"test\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_data_center\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_brand\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_device_manufacturer\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_model\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"tdpim.dict.custom.uom.power.watt\",\n"
+
" \"key\": \"rated_total_power\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"tdpim.dict.custom.uom.quantity.u\",\n"
+
" \"key\": \"device_u\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_usage\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"asset_ownership_epartment\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"responsible_department\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"responsible_person_name\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"responsible_person_phone\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"responsible_person_email\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_procurement_get_method\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_purchase_quantity\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"tdpim.dict.custom.uom.td_currency.cny.yuan\",\n"
+
" \"key\": \"td_purchase_price\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"tdpim.dict.custom.uom.td_currency.cny.yuan\",\n"
+
" \"key\": \"td_purchase_amount\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"acquisition_date\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"original_contact_person\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"original_contact_factory\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"original_contact_phone\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"storage_warehouse\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"aircraft_building\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"machine_room\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"cabinet_number\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"service_area\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"service_start_date\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"operating_system\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"firmware_version\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"in_band_ip\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"out_band_ip\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"business_ip\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" }\n"
+
" ]\n"
+
"}"
;
}
src/main/java/com/tongda/tdpimssdk/examples/DocumentSamples.java
deleted
100644 → 0
View file @
82f7ad21
package
com
.
tongda
.
tdpimssdk
.
examples
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tongda.tdpimssdk.remote.RemoteDocument
;
import
com.tongda.tdpimssdk.remote.RemoteSaAuthHandler
;
import
com.tongda.tdpimssdk.remote.RemoteTdPimHelper
;
import
com.tongda.tdpimssdk.resultVo.vo.AssetVo
;
import
java.io.File
;
import
java.util.LinkedList
;
import
java.util.List
;
public
class
DocumentSamples
{
public
static
void
main
(
String
[]
args
)
{
RemoteSaAuthHandler
rsh
=
new
RemoteSaAuthHandler
(
"guantiantian"
,
"q1w2e3r4"
,
"121.199.160.117"
,
9000
);
rsh
.
loginGetSaToken
();
System
.
out
.
println
(
"登录数据"
+
rsh
.
toString
());
rsh
.
setAppInstance
(
"150.158.75.213"
,
8080
,
"TXPIMDB"
);
//初始化远程查询对象
RemoteTdPimHelper
rqh
=
new
RemoteTdPimHelper
(
rsh
);
String
id
=
rqh
.
createDocument
(
JSONObject
.
parseObject
(
createDocument
,
AssetVo
.
class
));
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK createAsset:"
+
"\n"
+
"-------------------------------------------"
);
System
.
out
.
println
(
"创建返回结果:"
+
id
);
RemoteDocument
remoteDocument
=
rqh
.
fetchDocument
(
id
);
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK fetchDocument:"
+
"\n"
+
"-------------------------------------------"
);
System
.
out
.
println
(
"查询文档:"
+
remoteDocument
.
getId
()+
"/"
+
remoteDocument
.
getLabel
()+
"/"
+
remoteDocument
.
getDesc
());
//
AssetVo
.
AssetField
assetField
=
new
AssetVo
.
AssetField
();
assetField
.
setKey
(
"td_asset_number"
);
assetField
.
setMode
(
"tdpim.dict.system.metadata.mode.single.value"
);
assetField
.
setValue
(
"test1234"
);
List
<
AssetVo
.
AssetField
>
list
=
new
LinkedList
<>();
//添加修改项,可以多个
list
.
add
(
assetField
);
//执行修改
String
re
=
remoteDocument
.
updateDocumentValues
(
list
);
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK updateDocumentValues:"
+
"\n"
+
"-------------------------------------------"
);
System
.
out
.
println
(
"修改文档:"
+
re
);
re
=
rqh
.
deleteDocument
(
id
);
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK deleteDocument:"
+
"\n"
+
"-------------------------------------------"
);
System
.
out
.
println
(
"删除文档:"
+
re
);
File
file
=
new
File
(
"C:\\Users\\zfn\\Desktop\\新建 文本文档1.txt"
);
re
=
rqh
.
uploadBinary
(
"Resource-1131278751615680512"
,
file
);
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK uploadBinary:"
+
"\n"
+
"-------------------------------------------"
);
System
.
out
.
println
(
"上传文档:"
+
re
);
}
public
static
String
updateDocumentValues
=
"{\n"
+
" \"id\": \"Resource-1129783425285226496\",\n"
+
" \"fields\": [\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_number\",\n"
+
" \"value\": \"test1234\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" }\n"
+
" ]\n"
+
"}"
;
public
static
String
createDocument
=
"{\n"
+
" \"templateID\": \"ResourceTemplate-1125740648473821184\",\n"
+
" \"label\": \"测试7\",\n"
+
" \"fields\": [\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_number\",\n"
+
" \"value\": \"test123456789\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_subtype\",\n"
+
" \"value\": \"安全设备\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" }\n"
+
" ]\n"
+
"}"
;
}
src/main/java/com/tongda/tdpimssdk/examples/LoginSamples.java
deleted
100644 → 0
View file @
82f7ad21
package
com
.
tongda
.
tdpimssdk
.
examples
;
import
com.tongda.tdpimssdk.remote.RemoteSaAuthHandler
;
public
class
LoginSamples
{
public
static
void
main
(
String
[]
args
)
{
RemoteSaAuthHandler
rsh
=
new
RemoteSaAuthHandler
(
"guantiantian"
,
"q1w2e3r4"
,
"121.199.160.117"
,
9000
);
rsh
.
loginGetSaToken
();
rsh
.
setAppInstance
(
"150.158.75.213"
,
8080
,
"TXPIMDB"
);
System
.
out
.
println
(
rsh
);
}
}
src/main/java/com/tongda/tdpimssdk/examples/NewAssetSample.java
0 → 100644
View file @
a953e9fe
package
com
.
tongda
.
tdpimssdk
.
examples
;
import
com.alibaba.fastjson.JSON
;
import
com.tongda.tdpimssdk.entities.common.MetadataEntry
;
import
com.tongda.tdpimssdk.remote.entity.RemoteAsset
;
import
com.tongda.tdpimssdk.remote.paramset.AssetParamSet
;
import
com.tongda.tdpimssdk.remote.RemoteSaAuthHandler
;
public
class
NewAssetSample
{
public
static
String
reSetMetadataValue
(
RemoteSaAuthHandler
rsa
)
{
String
id
=
"AST_1133043289746833408"
;
System
.
out
.
println
(
"1: 读取原始资产信息:"
+
id
);
RemoteAsset
remoteAsset
=
RemoteAsset
.
doFetchAsset
(
rsa
,
id
);
System
.
out
.
println
(
remoteAsset
);
String
mdk
=
"MDET_td_asset_number"
;
System
.
out
.
println
(
"2: 读取元数据信息: "
+
mdk
);
MetadataEntry
mde
=
remoteAsset
.
getMetadataEntryByKey
(
mdk
);
System
.
out
.
println
(
JSON
.
toJSONString
(
mde
));
String
mdk1
=
"MDET_td_asset_name"
;
String
mdk2
=
"MDET_responsible_department"
;
System
.
out
.
println
(
"3: 设置元数据信息:"
);
System
.
out
.
println
(
mdk
);
System
.
out
.
println
(
mdk1
);
System
.
out
.
println
(
mdk2
);
remoteAsset
.
prepareMetadataUpdate
()
.
setAssetField
(
new
AssetParamSet
.
AssetField
(
mdk
,
"SN328333892323008"
))
.
setAssetField
(
new
AssetParamSet
.
AssetField
(
mdk1
,
"新的资产11名称"
))
.
setAssetField
(
new
AssetParamSet
.
AssetField
(
mdk2
,
"产品部"
))
.
doAction
();
System
.
out
.
println
(
"4:重新读取资产对象,输入元数据信息"
);
RemoteAsset
remoteAsset1
=
RemoteAsset
.
doFetchAsset
(
rsa
,
id
);
MetadataEntry
mde1
=
remoteAsset1
.
getMetadataEntryByKey
(
mdk
);
MetadataEntry
mde2
=
remoteAsset1
.
getMetadataEntryByKey
(
mdk1
);
MetadataEntry
mde3
=
remoteAsset1
.
getMetadataEntryByKey
(
mdk2
);
System
.
out
.
println
(
JSON
.
toJSONString
(
mde1
));
System
.
out
.
println
(
JSON
.
toJSONString
(
mde2
));
System
.
out
.
println
(
JSON
.
toJSONString
(
mde3
));
return
"Done"
;
}
public
static
String
createAsset
(
RemoteSaAuthHandler
rsa
){
String
ret
=
RemoteAsset
.
prepareToCreateAsset
(
rsa
,
"ASTT_1112005016249434112"
,
"第二个创建的资产"
,
"EndUser-1128343251971997696"
)
.
setAssetField
(
new
AssetParamSet
.
AssetField
(
"MDET_td_asset_number"
,
"资产编号987"
))
.
setAssetField
(
new
AssetParamSet
.
AssetField
(
"MDET_td_data_center"
,
"北京一区"
))
.
doAction
();
return
ret
;
}
public
static
void
deleteAsset
(
RemoteSaAuthHandler
rsa
){
String
ret
=
RemoteAsset
.
doDeleteAsset
(
rsa
,
"AST-1149408193365934080"
);
System
.
out
.
println
(
ret
);
}
public
static
void
assetUpgrade
(
RemoteSaAuthHandler
rsa
){
String
id
=
"AST_1133043289746833408"
;
RemoteAsset
remoteAsset
=
RemoteAsset
.
doFetchAsset
(
rsa
,
id
);
String
s
=
remoteAsset
.
prepareUpgradeVersion
()
.
setParamDesc
(
"dddd"
)
.
doAction
();
System
.
out
.
println
(
"升级版本:"
+
s
);
}
public
static
void
changeLifeCycleStatus
(
RemoteSaAuthHandler
rsa
){
String
id
=
"AST_1133043289746833408"
;
RemoteAsset
remoteAsset
=
RemoteAsset
.
doFetchAsset
(
rsa
,
id
);
String
ret
=
remoteAsset
.
prepareChangeLifeCycleStatus
()
.
setParamLifeCycleEvent
(
"Edit"
)
.
doAction
();
System
.
out
.
println
(
"生命周期: "
+
ret
);
}
public
static
String
id
=
"AST-1149381238067298304"
;
public
static
void
main
(
String
[]
args
)
{
RemoteSaAuthHandler
rsa
=
new
RemoteSaAuthHandler
(
"guantiantian"
,
"q1w2e3r4"
,
"192.168.1.204"
,
9000
);
rsa
.
loginGetSaToken
();
rsa
.
setAppInstance
(
"192.168.1.204"
,
8080
,
"TXPIMDB"
);
System
.
out
.
println
(
"登录数据"
+
rsa
.
toString
());
RemoteAsset
remoteAsset
=
RemoteAsset
.
doFetchAsset
(
rsa
,
id
);
System
.
out
.
println
(
remoteAsset
);
/** Todo
* 创建资产
*/
// createAsset(rsa);
/** Todo
* 修改资产元数据
*/
// reSetMetadataValue(rsa);
/** Todo
* 删除资产
*/
//deleteAsset(rsa);
/** Todo
* 变更生命周期
*/
//changeLifeCycleStatus(rsa);
/** Todo
* 升级版本
*/
//assetUpgrade(rsa);
}
}
src/main/java/com/tongda/tdpimssdk/examples/NewDocumentSample.java
0 → 100644
View file @
a953e9fe
package
com
.
tongda
.
tdpimssdk
.
examples
;
import
com.alibaba.fastjson.JSON
;
import
com.tongda.tdpimssdk.entities.common.MetadataEntry
;
import
com.tongda.tdpimssdk.remote.entity.RemoteDocument
;
import
com.tongda.tdpimssdk.remote.RemoteSaAuthHandler
;
import
com.tongda.tdpimssdk.remote.paramset.AssetParamSet
;
import
java.io.FileNotFoundException
;
public
class
NewDocumentSample
{
public
static
void
reSetMetadataValue
(
RemoteSaAuthHandler
rsa
){
String
id
=
"RES_1138885623029956608"
;
RemoteDocument
remoteDocument
=
RemoteDocument
.
doFetchDocument
(
rsa
,
id
);
MetadataEntry
mde
=
remoteDocument
.
getMetadataEntryByKey
(
"MDET_td_asset_number"
);
System
.
out
.
println
(
JSON
.
toJSONString
(
mde
));
remoteDocument
.
prepareMetadataUpdate
()
.
setAssetField
(
new
AssetParamSet
.
AssetField
(
"MDET_td_asset_number"
,
"222"
))
.
doAction
();
RemoteDocument
remoteDocument1
=
RemoteDocument
.
doFetchDocument
(
rsa
,
id
);
MetadataEntry
mde1
=
remoteDocument1
.
getMetadataEntryByKey
(
"MDET_td_asset_number"
);
System
.
out
.
println
(
JSON
.
toJSONString
(
mde1
));
}
public
static
String
createAsset
(
RemoteSaAuthHandler
rsa
){
String
ret
=
RemoteDocument
.
prepareToCreateDocument
(
rsa
,
"REST_1133463032148525056"
,
"第二个创建的文档"
,
"EndUser-1128343251971997696"
)
.
setAssetField
(
new
AssetParamSet
.
AssetField
(
"MDET_responsible_person_name"
,
"刘晓光"
))
.
setAssetField
(
new
AssetParamSet
.
AssetField
(
"MDET_operating_system"
,
"Windows"
))
.
doAction
();
return
ret
;
}
public
static
void
uploadBinary
(
RemoteSaAuthHandler
rsa
){
String
id
=
"RES_1133469381007769600"
;
String
filePath
=
"D:/video/DVR00564.MP4"
;
RemoteDocument
remoteDocument
=
RemoteDocument
.
doFetchDocument
(
rsa
,
id
);
try
{
String
s
=
remoteDocument
.
prepareUploadBinary
()
.
setParamUploadFilePath
(
filePath
)
.
setParamMediaType
(
""
)
.
doAction
();
System
.
out
.
println
(
s
);
}
catch
(
FileNotFoundException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
public
static
String
deleteDocument
(
RemoteSaAuthHandler
rsa
){
String
ret
=
RemoteDocument
.
doDeleteDocument
(
rsa
,
"RES-1149411645559144448"
);
return
ret
;
}
public
static
String
changeLifeCycleStatus
(
RemoteSaAuthHandler
rsa
){
// String id = "RES_1133469381007769600";
String
id
=
"RES-1143952915883360256"
;
RemoteDocument
remoteDocument
=
RemoteDocument
.
doFetchDocument
(
rsa
,
id
);
String
ret
=
remoteDocument
.
prepareChangeLifeCycleStatus
()
.
setParamLifeCycleEvent
(
"Edit"
)
.
doAction
();
return
ret
;
}
public
static
void
upgradeDocument
(
RemoteSaAuthHandler
rsa
){
String
id
=
"RES_1133469381007769600"
;
RemoteDocument
remoteDocument
=
RemoteDocument
.
doFetchDocument
(
rsa
,
id
);
String
s
=
remoteDocument
.
prepareUpgradeVersion
()
.
setParamDesc
(
"dddd"
)
.
doAction
();
System
.
out
.
println
(
"升级版本:"
+
s
);
}
public
static
void
main
(
String
[]
args
)
{
RemoteSaAuthHandler
rsa
=
new
RemoteSaAuthHandler
(
"guantiantian"
,
"q1w2e3r4"
,
"192.168.1.204"
,
9000
);
rsa
.
loginGetSaToken
();
rsa
.
setAppInstance
(
"192.168.1.204"
,
8080
,
"TXPIMDB"
);
System
.
out
.
println
(
"登录数据"
+
rsa
.
toString
());
RemoteDocument
rd
=
RemoteDocument
.
doFetchDocument
(
rsa
,
"RES_1138887220686487552"
);
System
.
out
.
println
(
JSON
.
toJSONString
(
rd
));
/** Todo
* 创建文档
*/
//createAsset(rsa);
/** Todo
* 修改元数据
*/
//reSetMetadataValue(rsa);
/** Todo
* 上载文件
*/
//uploadBinary(rsa);
/** Todo
* 删除文档
*/
//deleteDocument(rsa);
/** Todo
* 变更生命周期
*/
//changeLifeCycleStatus(rsa);
/** Todo
* 升级版本
*/
//upgradeDocument(rsa);
}
}
src/main/java/com/tongda/tdpimssdk/examples/NewTeamSample.java
0 → 100644
View file @
a953e9fe
package
com
.
tongda
.
tdpimssdk
.
examples
;
import
com.tongda.tdpimssdk.remote.RemoteSaAuthHandler
;
import
com.tongda.tdpimssdk.remote.entity.RemoteTeam
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
NewTeamSample
{
public
static
void
createTeam
(
RemoteSaAuthHandler
rsa
){
String
ret
=
RemoteTeam
.
prepareToCreateTeam
(
rsa
,
"一个业务名称"
,
"EndUser-1128343251971997696"
)
.
setParamDesc
(
"dfdf"
)
.
setParamLifecycleID
(
"TDLifeCycleDefinition-Common"
)
.
doAction
();
System
.
out
.
println
(
ret
);
}
public
static
void
upgradeVersion
(
RemoteSaAuthHandler
rsa
){
String
id
=
"Team2-1149734807001890816"
;
RemoteTeam
remoteTeam
=
RemoteTeam
.
doFetchTeam
(
rsa
,
id
);
String
ret
=
remoteTeam
.
prepareUpgradeVersion
()
.
setParamDesc
(
"ddd"
)
.
doAction
();
System
.
out
.
println
(
ret
);
}
public
static
void
changeLifeCycle
(
RemoteSaAuthHandler
rsa
){
String
id
=
"Team2-1149734807001890816"
;
RemoteTeam
remoteTeam
=
RemoteTeam
.
doFetchTeam
(
rsa
,
id
);
String
ret
=
remoteTeam
.
prepareChangeLifeCycleStatus
()
.
setParamLcEvent
(
"Edit"
)
.
doAction
();
System
.
out
.
println
(
"changeLifeCycle:"
+
ret
);
}
public
static
void
addAssetRefToTeam
(
RemoteSaAuthHandler
rsa
){
String
id
=
"Team2-1149751594825285632"
;
RemoteTeam
remoteTeam
=
RemoteTeam
.
doFetchTeam
(
rsa
,
id
);
List
<
String
>
asl
=
new
ArrayList
<>();
asl
.
add
(
"AST-1149381713307107328"
);
String
ret
=
remoteTeam
.
prepareAddAssetRef
()
.
setParamAssetListToAdd
(
asl
)
.
doAction
();
System
.
out
.
println
(
"addAssetRefToTeam:"
+
ret
);
}
public
static
void
removeAssetRefToTeam
(
RemoteSaAuthHandler
rsa
){
String
id
=
"Team2-1149751594825285632"
;
RemoteTeam
remoteTeam
=
RemoteTeam
.
doFetchTeam
(
rsa
,
id
);
String
ret
=
remoteTeam
.
prepareRemoveAssetRef
()
.
setParamAssetToRemove
(
"AST-1149381238067298304"
)
.
doAction
();
System
.
out
.
println
(
"removeAssetRefToTeam:"
+
ret
);
}
public
static
void
deleteTeam
(
RemoteSaAuthHandler
rsa
){
String
ret
=
RemoteTeam
.
doDeleteTeam
(
rsa
,
"TEM_1138448201645293568"
);
System
.
out
.
println
(
"deleteTeam:"
+
ret
);
}
public
static
void
main
(
String
[]
args
)
{
RemoteSaAuthHandler
rsa
=
new
RemoteSaAuthHandler
(
"guantiantian"
,
"q1w2e3r4"
,
"192.168.1.204"
,
9000
);
rsa
.
loginGetSaToken
();
rsa
.
setAppInstance
(
"192.168.1.204"
,
8080
,
"TXPIMDB"
);
System
.
out
.
println
(
"登录数据"
+
rsa
.
toString
());
//初始化远程查询对象
// RemoteTDDamHelper rqh = new RemoteTDDamHelper(rsa);
// RemoteTeam remoteTeam = rqh.fetchTeam("TEM_1129497138993037312");
RemoteTeam
remoteTeam
=
RemoteTeam
.
doFetchTeam
(
rsa
,
"TEM_1129497138993037312"
);
System
.
out
.
println
(
remoteTeam
);
/** Todo
* 创建业务
*/
//createTeam(rqh);
/** Todo
* 添加资产/文档
*/
//addAssetRefToTeam(rqh);
/** Todo
* 移除资产/文档
*/
//removeAssetRefToTeam(rqh);
/** Todo
* 变更生命周期
*/
//changeLifeCycle(rqh);
/** Todo
* 提升版本
*/
//upgradeVersion(rqh);
/** Todo
* 删除业务
*/
//deleteTeam(rqh);
}
}
src/main/java/com/tongda/tdpimssdk/examples/QuerySamples.java
deleted
100644 → 0
View file @
82f7ad21
package
com
.
tongda
.
tdpimssdk
.
examples
;
import
com.tongda.tdpimssdk.entities.AssetAbstract
;
import
com.tongda.tdpimssdk.entities.Entity
;
import
com.tongda.tdpimssdk.entities.common.Catalog
;
import
com.tongda.tdpimssdk.entities.common.CatalogRoot
;
import
com.tongda.tdpimssdk.remote.RemoteTdPimHelper
;
import
com.tongda.tdpimssdk.remote.RemoteSaAuthHandler
;
import
com.tongda.tdpimssdk.resultVo.vo.GeneralPagerVo
;
import
java.util.List
;
public
class
QuerySamples
{
public
static
void
main
(
String
[]
args
)
{
RemoteSaAuthHandler
rsh
=
new
RemoteSaAuthHandler
(
"guantiantian"
,
"q1w2e3r4"
,
"121.199.160.117"
,
9000
);
rsh
.
loginGetSaToken
();
rsh
.
setAppInstance
(
"150.158.75.213"
,
8080
,
"TXPIMDB"
);
//初始化远程查询对象
RemoteTdPimHelper
rqh
=
new
RemoteTdPimHelper
(
rsh
);
CatalogRoot
cr
=
rqh
.
fetchAssetTemplates
();
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK queryAssetTemplates:"
+
"\n"
+
"-------------------------------------------"
);
for
(
int
i
=
0
;
i
<
cr
.
getCatalog
().
size
();
i
++){
Catalog
c
=
cr
.
getCatalog
().
get
(
i
);
System
.
out
.
println
(
c
.
getLabel
());
for
(
int
j
=
0
;
j
<
c
.
getCatalog
().
size
();
j
++){
Catalog
t
=
c
.
getCatalog
().
get
(
j
);
System
.
out
.
println
(
"\t"
+
t
.
getLabel
()
+
", "
+
t
.
getIdRef
());
}
}
CatalogRoot
cr1
=
rqh
.
fetchDocumentTemplates
();
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK queryDocumentTemplates:"
+
"\n"
+
"-------------------------------------------"
);
for
(
int
i
=
0
;
i
<
cr1
.
getCatalog
().
size
();
i
++){
Catalog
c
=
cr1
.
getCatalog
().
get
(
i
);
System
.
out
.
println
(
c
.
getLabel
());
for
(
int
j
=
0
;
j
<
c
.
getCatalog
().
size
();
j
++){
Catalog
t
=
c
.
getCatalog
().
get
(
j
);
System
.
out
.
println
(
"\t"
+
t
.
getLabel
()
+
", "
+
t
.
getIdRef
()
+
", "
+
t
.
getId
());
}
}
List
<
Entity
>
le
=
rqh
.
fetchAppConfigList
(
""
);
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK getAppServiceList:"
+
"\n"
+
"-------------------------------------------"
);
for
(
int
i
=
0
;
i
<
le
.
size
();
i
++){
Entity
e
=
le
.
get
(
i
);
System
.
out
.
println
(
"\t"
+
e
.
getLabel
()
+
", "
+
e
.
getId
());
}
GeneralPagerVo
<
AssetAbstract
>
ac
=
rqh
.
fetchAssetByTemplate
(
"ProductTemplate-1125744743611891712"
,
1
,
20
);
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK queryAssetByTemplate:"
+
"\n"
+
"-------------------------------------------"
);
System
.
out
.
println
(
"total: "
+
ac
.
getTotal
());
for
(
int
i
=
0
;
i
<
ac
.
getData
().
size
();
i
++){
AssetAbstract
a
=
ac
.
getData
().
get
(
i
);
System
.
out
.
println
(
"\t"
+
a
.
getLabel
()
+
", "
+
a
.
getId
());
}
List
<
Entity
>
le2
=
rqh
.
fetchAssetAppViewPath
(
"Product-1126119026813042688"
);
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK queryAssetAppViewPath:"
+
"\n"
+
"-------------------------------------------"
);
for
(
int
i
=
0
;
i
<
le2
.
size
();
i
++){
Entity
e
=
le2
.
get
(
i
);
System
.
out
.
println
(
"\t"
+
e
.
getLabel
()
+
", "
+
e
.
getId
()
+
", "
+
e
.
getInfo
());
}
}
}
src/main/java/com/tongda/tdpimssdk/examples/UpdateSample.java
deleted
100644 → 0
View file @
82f7ad21
package
com
.
tongda
.
tdpimssdk
.
examples
;
import
com.tongda.tdpimssdk.remote.RemoteAsset
;
import
com.tongda.tdpimssdk.remote.RemoteSaAuthHandler
;
import
com.tongda.tdpimssdk.remote.RemoteTdPimHelper
;
import
com.tongda.tdpimssdk.resultVo.vo.AssetVo
;
import
java.util.LinkedList
;
import
java.util.List
;
public
class
UpdateSample
{
public
static
void
main
(
String
[]
args
)
{
RemoteSaAuthHandler
rsh
=
new
RemoteSaAuthHandler
(
"guantiantian"
,
"q1w2e3r4"
,
"121.199.160.117"
,
9000
);
rsh
.
setAppInstance
(
"150.158.75.213"
,
8080
,
"TXPIMDB"
);
rsh
.
loginGetSaToken
();
//初始化远程查询对象
RemoteTdPimHelper
rqh
=
new
RemoteTdPimHelper
(
rsh
);
RemoteAsset
ra
=
rqh
.
fetchAsset
(
"Product-1125789659889139712"
);
AssetVo
.
AssetField
assetField
=
new
AssetVo
.
AssetField
();
assetField
.
setKey
(
"td_data_center"
);
assetField
.
setMode
(
"tdpim.dict.system.metadata.mode.single.select.value"
);
assetField
.
setValue
(
"北京一区"
);
List
<
AssetVo
.
AssetField
>
list
=
new
LinkedList
<>();
//添加修改项,可以多个
list
.
add
(
assetField
);
String
ret
=
ra
.
updateAssetValues
(
list
);
System
.
out
.
println
(
ret
);
}
}
src/main/java/com/tongda/tdpimssdk/http/PimHttpUtil.java
View file @
a953e9fe
...
...
@@ -98,12 +98,12 @@ public class PimHttpUtil {
CloseableHttpResponse
response
=
client
.
execute
(
httpGet
);
//获取Response状态码
int
statusCode
=
response
.
getStatusLine
().
getStatusCode
();
System
.
out
.
println
(
statusCode
);
//
System.out.println(statusCode);
//获取响应实体, 响应内容
HttpEntity
entity
=
response
.
getEntity
();
//通过EntityUtils中的toString方法将结果转换为字符串
String
str
=
EntityUtils
.
toString
(
entity
);
System
.
out
.
println
(
str
);
//
System.out.println(str);
response
.
close
();
client
.
close
();
...
...
@@ -231,6 +231,7 @@ public class PimHttpUtil {
httpPut
.
setHeader
(
"Content-Type"
,
"application/json"
);
httpPut
.
setConfig
(
requestConfig
);
StringEntity
entity
=
new
StringEntity
(
jsonObject
.
toString
(),
Consts
.
UTF_8
);
httpPut
.
setEntity
(
entity
);
//执行请求
CloseableHttpResponse
response
=
client
.
execute
(
httpPut
);
...
...
@@ -274,7 +275,7 @@ public class PimHttpUtil {
CloseableHttpResponse
response
=
client
.
execute
(
httpDelete
);
//获取Response状态码
int
statusCode
=
response
.
getStatusLine
().
getStatusCode
();
System
.
out
.
println
(
statusCode
);
//
System.out.println(statusCode);
//获取响应实体, 响应内容
HttpEntity
entity
=
response
.
getEntity
();
//通过EntityUtils中的toString方法将结果转换为字符串
...
...
@@ -294,6 +295,7 @@ public class PimHttpUtil {
}
}
public
static
String
sendDeleteBody
(
String
token
,
String
url
,
JSONObject
jsonObject
){
try
{
//创建httpClient实例
...
...
@@ -320,7 +322,7 @@ public class PimHttpUtil {
CloseableHttpResponse
response
=
client
.
execute
(
httpDelete
);
//获取Response状态码
int
statusCode
=
response
.
getStatusLine
().
getStatusCode
();
System
.
out
.
println
(
statusCode
);
//
System.out.println(statusCode);
//获取响应实体, 响应内容
HttpEntity
entity
=
response
.
getEntity
();
//通过EntityUtils中的toString方法将结果转换为字符串
...
...
@@ -341,7 +343,6 @@ public class PimHttpUtil {
}
public
static
String
resultUtil
(
String
re
){
// System.out.println(re);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
re
);
if
(
jsonObject
.
get
(
"code"
).
toString
().
equals
(
"200"
)){
return
jsonObject
.
get
(
"data"
).
toString
();
...
...
src/main/java/com/tongda/tdpimssdk/remote/RemoteAppConfiguration.java
deleted
100644 → 0
View file @
82f7ad21
package
com
.
tongda
.
tdpimssdk
.
remote
;
import
com.tongda.tdpimssdk.entities.common.Team2
;
public
class
RemoteAppConfiguration
extends
Team2
{
}
src/main/java/com/tongda/tdpimssdk/remote/RemoteAsset.java
deleted
100644 → 0
View file @
82f7ad21
package
com
.
tongda
.
tdpimssdk
.
remote
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tongda.tdpimssdk.entities.Product
;
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
RemoteAsset
extends
Product
{
protected
RemoteSaAuthHandler
rsh
;
public
String
updateAssetValues
(
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/field?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPut
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
assetVo
));
String
s
=
resultUtil
(
response
);
return
s
;
}
}
src/main/java/com/tongda/tdpimssdk/remote/RemoteDocument.java
deleted
100644 → 0
View file @
82f7ad21
package
com
.
tongda
.
tdpimssdk
.
remote
;
import
com.alibaba.fastjson.JSONObject
;
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
{
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
;
}
}
src/main/java/com/tongda/tdpimssdk/remote/RemoteSaAuthHandler.java
View file @
a953e9fe
...
...
@@ -44,7 +44,8 @@ public class RemoteSaAuthHandler {
" serverIP: "
+
this
.
serverIP
+
"\n"
+
" serverPort: "
+
this
.
serverPort
+
"\n"
+
" dbName: "
+
this
.
dbName
+
"\n"
+
" saToken: "
+
this
.
saToken
+
"\n"
;
" saToken: "
+
this
.
saToken
+
"\n"
+
"-------------------------------------------"
+
"\n"
;
}
...
...
src/main/java/com/tongda/tdpimssdk/remote/RemoteTdPimHelper.java
deleted
100644 → 0
View file @
82f7ad21
package
com
.
tongda
.
tdpimssdk
.
remote
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.tongda.tdpimssdk.entities.AssetAbstract
;
import
com.tongda.tdpimssdk.entities.Entity
;
import
com.tongda.tdpimssdk.entities.common.CatalogRoot
;
import
com.tongda.tdpimssdk.http.PimHttpUtil
;
import
com.tongda.tdpimssdk.resultVo.vo.AssetVo
;
import
com.tongda.tdpimssdk.resultVo.vo.CatalogItem
;
import
com.tongda.tdpimssdk.resultVo.vo.GeneralPagerVo
;
import
com.tongda.tdpimssdk.resultVo.vo.TeamVo
;
import
java.io.File
;
import
java.util.List
;
import
static
com
.
tongda
.
tdpimssdk
.
http
.
PimHttpUtil
.
resultUtil
;
public
class
RemoteTdPimHelper
{
RemoteSaAuthHandler
rsh
;
public
RemoteTdPimHelper
(
RemoteSaAuthHandler
rsh
){
this
.
rsh
=
rsh
;
}
/**
* 查询资产模型清单
* @return
*/
public
CatalogRoot
fetchAssetTemplates
(){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/template?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendGet
(
this
.
rsh
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
List
<
CatalogRoot
>
catList
=
JSONObject
.
parseArray
(
s
,
CatalogRoot
.
class
);
if
(
catList
.
size
()
==
1
){
return
catList
.
get
(
0
);
}
return
null
;
}
/**
* 查询文档模型清单
* @return
*/
public
CatalogRoot
fetchDocumentTemplates
(){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/template/document?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendGet
(
this
.
rsh
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
List
<
CatalogRoot
>
catList
=
JSONObject
.
parseArray
(
s
,
CatalogRoot
.
class
);
if
(
catList
.
size
()
==
1
){
return
catList
.
get
(
0
);
}
return
null
;
}
/**
* 根据模型ID查询资产/文档清单
* @param templateID
* @param page
* @param size
* @return
*/
public
GeneralPagerVo
<
AssetAbstract
>
fetchAssetByTemplate
(
String
templateID
,
int
page
,
int
size
){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/asset?dbName="
+
this
.
rsh
.
dbName
+
"&templateID="
+
templateID
+
"&page="
+
page
+
"&size="
+
size
;
String
response
=
PimHttpUtil
.
sendGet
(
this
.
rsh
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
return
JSONObject
.
parseObject
(
s
,
new
TypeReference
<
GeneralPagerVo
<
AssetAbstract
>>(){});
}
/**
* 查询资产所属业务
* @param id
* @return
*/
public
List
<
Entity
>
fetchAssetAppViewPath
(
String
id
){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/asset/business/path?dbName="
+
this
.
rsh
.
dbName
+
"&id="
+
id
;
String
response
=
PimHttpUtil
.
sendGet
(
this
.
rsh
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
return
JSONObject
.
parseArray
(
s
,
Entity
.
class
);
}
/**
* 查询业务清单
* @return
*/
public
List
<
Entity
>
fetchAppConfigList
(
String
label
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/business?dbName="
+
this
.
rsh
.
dbName
+
"&label="
+
label
;
String
response
=
PimHttpUtil
.
sendGet
(
this
.
rsh
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
return
JSONObject
.
parseArray
(
s
,
Entity
.
class
);
}
//------------资产相关------------
/**
* 修改资产
* @param vo
* @return
*/
public
String
updateAssetValues
(
AssetVo
vo
){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/asset/field?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPut
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
vo
));
String
s
=
resultUtil
(
response
);
return
s
;
}
/**
* 新建资产
* @param vo
* @return
*/
public
String
createAsset
(
AssetVo
vo
){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/asset?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPost
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
vo
));
String
s
=
resultUtil
(
response
);
return
s
;
}
/**
* 删除资产
* @param id
* @return
*/
public
String
deleteAsset
(
String
id
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/asset?dbName="
+
this
.
rsh
.
dbName
+
"&id="
+
id
;
String
response
=
PimHttpUtil
.
sendDelete
(
this
.
rsh
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
return
s
;
}
/**
* 查询资产
* @param id
* @return
*/
public
RemoteAsset
fetchAsset
(
String
id
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/asset/details?dbName="
+
this
.
rsh
.
dbName
+
"&id="
+
id
;
String
response
=
PimHttpUtil
.
sendGet
(
this
.
rsh
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
RemoteAsset
ra
=
JSONObject
.
parseArray
(
s
,
RemoteAsset
.
class
).
get
(
0
);
ra
.
setRsh
(
rsh
);
return
ra
;
}
//------------文档相关------------
/**
* 创建文档
* @param vo
* @return
*/
public
String
createDocument
(
AssetVo
vo
){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/asset/document?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPost
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
vo
));
String
s
=
resultUtil
(
response
);
return
s
;
}
/**
* 查询文档
* @param id
* @return
*/
public
RemoteDocument
fetchDocument
(
String
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
s
=
resultUtil
(
response
);
RemoteDocument
remoteDocument
=
JSONObject
.
parseArray
(
s
,
RemoteDocument
.
class
).
get
(
0
);
remoteDocument
.
setRsh
(
rsh
);
return
remoteDocument
;
}
/**
* 修改文档
* @param vo
* @return
*/
public
String
updateDocumentValues
(
AssetVo
vo
)
{
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
(
vo
));
String
s
=
resultUtil
(
response
);
return
s
;
}
/**
* 删除文档
* @param id
* @return
*/
public
String
deleteDocument
(
String
id
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/asset/document?dbName="
+
this
.
rsh
.
dbName
+
"&id="
+
id
;
String
response
=
PimHttpUtil
.
sendDelete
(
this
.
rsh
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
return
s
;
}
/**
* 上传文件
* @param id
* @param file
* @return
*/
public
String
uploadBinary
(
String
id
,
File
file
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/document/upload?dbName="
+
this
.
rsh
.
dbName
+
"&id="
+
id
;
String
response
=
PimHttpUtil
.
uploadFile
(
this
.
rsh
.
saToken
,
url
,
file
);
String
s
=
resultUtil
(
response
);
return
s
;
}
//------------业务相关------------
/**
* 新建业务
* @param teamVo
* @return
*/
public
String
createAppConfig
(
TeamVo
teamVo
){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/business?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPost
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
teamVo
));
String
s
=
resultUtil
(
response
);
return
s
;
}
/**
* 查询业务详情
* @param id
* @return
*/
public
RemoteAppConfiguration
fetchAppConfig
(
String
id
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/business/details?dbName="
+
this
.
rsh
.
dbName
+
"&id="
+
id
;
String
response
=
PimHttpUtil
.
sendGet
(
this
.
rsh
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
return
JSONObject
.
parseArray
(
s
,
RemoteAppConfiguration
.
class
).
get
(
0
);
}
/**
* 查询目录下资产列表
* @param id
* @return
*/
public
List
<
CatalogRoot
>
queryAssetByCatalog
(
String
id
,
String
catalogID
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/business/details?dbName="
+
this
.
rsh
.
dbName
+
"&id="
+
id
+
"&catalogID="
+
catalogID
;
String
response
=
PimHttpUtil
.
sendGet
(
this
.
rsh
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
return
JSONObject
.
parseArray
(
s
,
CatalogRoot
.
class
);
}
/**
* 删除业务
* @param id
* @return
*/
public
String
deleteAppConfig
(
String
id
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/business?dbName="
+
this
.
rsh
.
dbName
;
TeamVo
teamVo
=
new
TeamVo
();
teamVo
.
setTeamID
(
id
);
String
response
=
PimHttpUtil
.
sendDeleteBody
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
teamVo
));
String
s
=
resultUtil
(
response
);
return
s
;
}
/**
* 将资源从业务团队中移除
* @return
*/
public
String
removeAssetFromApp
(
CatalogItem
item
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/business/asset?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendDeleteBody
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
item
));
String
s
=
resultUtil
(
response
);
return
s
;
}
/**
* 将资产加入业务
* @param item
* @return
*/
public
String
addAssetRefToAppConfig
(
CatalogItem
item
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/business/asset?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPut
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
item
));
String
s
=
resultUtil
(
response
);
return
s
;
}
}
src/main/java/com/tongda/tdpimssdk/remote/common/RemoteAbstractEntity.java
0 → 100644
View file @
a953e9fe
package
com
.
tongda
.
tdpimssdk
.
remote
.
common
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tongda.tdpimssdk.entities.AssetAbstract
;
import
com.tongda.tdpimssdk.entities.common.*
;
import
com.tongda.tdpimssdk.http.PimHttpUtil
;
import
com.tongda.tdpimssdk.remote.paramset.AssetParamSet
;
import
com.tongda.tdpimssdk.remote.RemoteSaAuthHandler
;
import
lombok.Data
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
com
.
tongda
.
tdpimssdk
.
http
.
PimHttpUtil
.
resultUtil
;
@Data
abstract
public
class
RemoteAbstractEntity
extends
AssetAbstract
{
protected
AssetParamSet
assetVo
;
private
RemoteSaAuthHandler
rsh
;
public
MetadataEntry
getMetadataEntryByKey
(
String
key
){
List
<
Metadata
>
mdg
=
this
.
getMetadataGroup
().
getMetadata
();
for
(
Metadata
md
:
mdg
){
for
(
MetadataEntry
mde
:
md
.
getMetadataEntry
()){
if
(
mde
.
getKey
().
equals
(
key
)){
return
mde
;
}
}
}
return
null
;
}
}
src/main/java/com/tongda/tdpimssdk/remote/common/RemoteAbstractTeam.java
0 → 100644
View file @
a953e9fe
package
com
.
tongda
.
tdpimssdk
.
remote
.
common
;
import
com.tongda.tdpimssdk.entities.common.Team2
;
import
com.tongda.tdpimssdk.remote.RemoteSaAuthHandler
;
import
com.tongda.tdpimssdk.remote.paramset.AssetParamSet
;
import
com.tongda.tdpimssdk.remote.paramset.TeamParamSet
;
import
lombok.Data
;
@Data
public
class
RemoteAbstractTeam
extends
Team2
{
protected
TeamParamSet
paramVo
;
private
RemoteSaAuthHandler
rsh
;
}
src/main/java/com/tongda/tdpimssdk/remote/common/RemoteMetadataMode.java
0 → 100644
View file @
a953e9fe
package
com
.
tongda
.
tdpimssdk
.
remote
.
common
;
public
class
RemoteMetadataMode
{
public
static
final
String
SINGLE_VALUE
=
"tdpim.dict.system.metadata.mode.single.value"
;
public
static
final
String
SINGLE_SELECT_VALUE
=
"tdpim.dict.system.metadata.mode.single.value"
;
public
static
final
String
RANGE_VALUE
=
"tdpim.dict.system.metadata.mode.range.value"
;
public
static
final
String
MULTI_SELECT_VALUE
=
"tdpim.dict.system.metadata.mode.multi.select.value"
;
public
static
final
String
TIMESERIES_VALUE
=
"tdpim.dict.system.metadata.mode.timeseries.value"
;
}
src/main/java/com/tongda/tdpimssdk/remote/entity/RemoteAsset.java
0 → 100644
View file @
a953e9fe
package
com
.
tongda
.
tdpimssdk
.
remote
.
entity
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tongda.tdpimssdk.http.PimHttpUtil
;
import
com.tongda.tdpimssdk.remote.RemoteSaAuthHandler
;
import
com.tongda.tdpimssdk.remote.common.RemoteAbstractEntity
;
import
com.tongda.tdpimssdk.remote.paramset.AssetParamSet
;
import
com.tongda.tdpimssdk.remote.paramset.TeamParamSet
;
import
lombok.Data
;
import
static
com
.
tongda
.
tdpimssdk
.
http
.
PimHttpUtil
.
resultUtil
;
@Data
public
class
RemoteAsset
extends
RemoteAbstractEntity
{
public
static
final
String
METADATA_URI
=
"/pims/asset/field"
;
public
static
final
String
BASE_URI
=
"/pims/asset"
;
public
static
final
String
BASE_URI_UPGRADE
=
"/pims/asset/upgrade"
;
public
static
final
String
BASE_URI_LIFECYCLE
=
"/pims/lifecycle/asset/state"
;
public
String
toString
(){
return
JSON
.
toJSONString
(
this
);
}
public
AssetParamSet
prepareMetadataUpdate
(){
this
.
assetVo
=
new
AssetParamSet
(
this
.
getRsh
(),
AssetParamSet
.
action_asset_metadata_update
);
this
.
assetVo
.
setId
(
this
.
getId
());
return
this
.
assetVo
;
}
public
AssetParamSet
prepareUpgradeVersion
(){
this
.
assetVo
=
new
AssetParamSet
(
this
.
getRsh
(),
AssetParamSet
.
action_asset_upgrade
);
this
.
assetVo
.
setId
(
this
.
getId
());
return
this
.
assetVo
;
}
public
AssetParamSet
prepareChangeLifeCycleStatus
()
{
this
.
assetVo
=
new
AssetParamSet
(
this
.
getRsh
(),
AssetParamSet
.
action_asset_change_lifecycle
);
this
.
assetVo
.
setId
(
this
.
getId
());
return
this
.
assetVo
;
}
public
static
RemoteAsset
doFetchAsset
(
RemoteSaAuthHandler
rsa
,
String
assetID
){
String
url
=
"http://"
+
rsa
.
serverIP
+
":"
+
rsa
.
serverPort
+
"/pims/asset/details?dbName="
+
rsa
.
dbName
+
"&id="
+
assetID
;
String
response
=
PimHttpUtil
.
sendGet
(
rsa
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
RemoteAsset
ra
=
JSONObject
.
parseArray
(
s
,
RemoteAsset
.
class
).
get
(
0
);
ra
.
setRsh
(
rsa
);
return
ra
;
}
public
static
String
doDeleteAsset
(
RemoteSaAuthHandler
rsa
,
String
id
)
{
AssetParamSet
param
=
new
AssetParamSet
(
rsa
,
AssetParamSet
.
action_document_delete
);
param
.
setId
(
id
);
return
param
.
doAction
();
}
public
static
AssetParamSet
prepareToCreateAsset
(
RemoteSaAuthHandler
rsa
,
String
templateID
,
String
label
,
String
creatorID
)
{
AssetParamSet
param
=
new
AssetParamSet
(
rsa
,
AssetParamSet
.
action_asset_create
);
param
.
setParamTemplate
(
templateID
)
.
setParamLabel
(
label
)
.
setParamUserID
(
creatorID
);
return
param
;
}
}
src/main/java/com/tongda/tdpimssdk/remote/entity/RemoteDocument.java
0 → 100644
View file @
a953e9fe
package
com
.
tongda
.
tdpimssdk
.
remote
.
entity
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tongda.tdpimssdk.http.PimHttpUtil
;
import
com.tongda.tdpimssdk.remote.RemoteSaAuthHandler
;
import
com.tongda.tdpimssdk.remote.common.RemoteAbstractEntity
;
import
com.tongda.tdpimssdk.remote.paramset.AssetParamSet
;
import
com.tongda.tdpimssdk.remote.paramset.TeamParamSet
;
import
lombok.Data
;
import
javax.xml.bind.annotation.XmlAttribute
;
import
java.io.FileNotFoundException
;
import
static
com
.
tongda
.
tdpimssdk
.
http
.
PimHttpUtil
.
resultUtil
;
@Data
public
class
RemoteDocument
extends
RemoteAbstractEntity
{
public
static
final
String
METADATA_URI
=
"/pims/asset/document/field"
;
public
static
final
String
BASE_URI
=
"/pims/asset/document"
;
public
static
final
String
UPLOAD_URI
=
"/pims/document/upload"
;
public
static
final
String
BASE_URI_UPGRADE
=
"/pims/document/upgrade"
;
public
static
final
String
BASE_URI_LIFECYCLE
=
"/pims/lifecycle/document/state"
;
@XmlAttribute
(
name
=
"href"
)
protected
String
href
;
@XmlAttribute
(
name
=
"mediatype"
)
protected
String
mediaType
;
public
AssetParamSet
prepareMetadataUpdate
(){
this
.
assetVo
=
new
AssetParamSet
(
this
.
getRsh
(),
AssetParamSet
.
action_document_metadata_update
);
this
.
assetVo
.
setId
(
this
.
getId
());
return
this
.
assetVo
;
}
public
AssetParamSet
prepareUploadBinary
()
throws
FileNotFoundException
{
this
.
assetVo
=
new
AssetParamSet
(
this
.
getRsh
(),
AssetParamSet
.
action_document_file_upload
);
this
.
assetVo
.
setId
(
this
.
getId
());
return
this
.
assetVo
;
}
public
AssetParamSet
prepareChangeLifeCycleStatus
()
{
this
.
assetVo
=
new
AssetParamSet
(
this
.
getRsh
(),
AssetParamSet
.
action_document_change_lifecycle
);
this
.
assetVo
.
setId
(
this
.
getId
());
return
this
.
assetVo
;
}
public
AssetParamSet
prepareUpgradeVersion
(){
this
.
assetVo
=
new
AssetParamSet
(
this
.
getRsh
(),
AssetParamSet
.
action_document_upgrade
);
this
.
assetVo
.
setId
(
this
.
getId
());
return
this
.
assetVo
;
}
public
static
RemoteDocument
doFetchDocument
(
RemoteSaAuthHandler
rsa
,
String
docID
){
String
url
=
"http://"
+
rsa
.
serverIP
+
":"
+
rsa
.
serverPort
+
"/pims/document/content?dbName="
+
rsa
.
dbName
+
"&id="
+
docID
;
String
response
=
PimHttpUtil
.
sendGet
(
rsa
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
RemoteDocument
remoteDocument
=
JSONObject
.
parseArray
(
s
,
RemoteDocument
.
class
).
get
(
0
);
remoteDocument
.
setRsh
(
rsa
);
return
remoteDocument
;
}
public
static
String
doDeleteDocument
(
RemoteSaAuthHandler
rsa
,
String
docID
)
{
AssetParamSet
param
=
new
AssetParamSet
(
rsa
,
AssetParamSet
.
action_document_delete
);
param
.
setId
(
docID
);
return
param
.
doAction
();
}
public
static
AssetParamSet
prepareToCreateDocument
(
RemoteSaAuthHandler
rsa
,
String
templateID
,
String
label
,
String
creatorID
)
{
AssetParamSet
param
=
new
AssetParamSet
(
rsa
,
AssetParamSet
.
action_document_create
);
param
.
setParamTemplate
(
templateID
)
.
setParamLabel
(
label
)
.
setParamUserID
(
creatorID
);
return
param
;
}
}
src/main/java/com/tongda/tdpimssdk/remote/entity/RemoteTeam.java
0 → 100644
View file @
a953e9fe
package
com
.
tongda
.
tdpimssdk
.
remote
.
entity
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tongda.tdpimssdk.http.PimHttpUtil
;
import
com.tongda.tdpimssdk.remote.RemoteSaAuthHandler
;
import
com.tongda.tdpimssdk.remote.common.RemoteAbstractTeam
;
import
com.tongda.tdpimssdk.remote.paramset.TeamParamSet
;
import
static
com
.
tongda
.
tdpimssdk
.
http
.
PimHttpUtil
.
resultUtil
;
public
class
RemoteTeam
extends
RemoteAbstractTeam
{
public
static
final
String
BASE_URI_ASSET
=
"/pims/business/asset"
;
public
static
final
String
BASE_URI
=
"/pims/business"
;
public
static
final
String
BASE_URI_UPGRADE_VERSION
=
"/pims/business/upgrade"
;
public
static
final
String
BASE_URI_LIFECYCLE
=
"/pims/lifecycle/team/state"
;
public
String
toString
(){
return
JSON
.
toJSONString
(
this
);
}
public
TeamParamSet
prepareUpgradeVersion
(){
this
.
paramVo
=
new
TeamParamSet
(
this
.
getRsh
(),
TeamParamSet
.
action_team_upgrade_version
);
this
.
paramVo
.
setTeamID
(
this
.
getId
());
return
this
.
paramVo
;
}
public
TeamParamSet
prepareChangeLifeCycleStatus
(){
this
.
paramVo
=
new
TeamParamSet
(
this
.
getRsh
(),
TeamParamSet
.
action_team_change_lifecycle
);
this
.
paramVo
.
setTeamID
(
this
.
getId
());
return
this
.
paramVo
;
}
public
TeamParamSet
prepareAddAssetRef
(){
this
.
paramVo
=
new
TeamParamSet
(
this
.
getRsh
(),
TeamParamSet
.
action_team_add_asset_ref
);
this
.
paramVo
.
setTeamID
(
this
.
getId
());
return
this
.
paramVo
;
}
public
TeamParamSet
prepareRemoveAssetRef
(){
this
.
paramVo
=
new
TeamParamSet
(
this
.
getRsh
(),
TeamParamSet
.
action_team_remove_asset_ref
);
this
.
paramVo
.
setTeamID
(
this
.
getId
());
return
this
.
paramVo
;
}
public
static
RemoteTeam
doFetchTeam
(
RemoteSaAuthHandler
rsa
,
String
teamID
){
String
url
=
"http://"
+
rsa
.
serverIP
+
":"
+
rsa
.
serverPort
+
"/pims/business/details?dbName="
+
rsa
.
dbName
+
"&id="
+
teamID
;
String
response
=
PimHttpUtil
.
sendGet
(
rsa
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
RemoteTeam
team
=
JSONObject
.
parseArray
(
s
,
RemoteTeam
.
class
).
get
(
0
);
team
.
setRsh
(
rsa
);
return
team
;
}
public
static
String
doDeleteTeam
(
RemoteSaAuthHandler
rsa
,
String
id
)
{
TeamParamSet
param
=
new
TeamParamSet
(
rsa
,
TeamParamSet
.
action_team_delete
);
param
.
setTeamID
(
id
);
return
param
.
doAction
();
}
public
static
TeamParamSet
prepareToCreateTeam
(
RemoteSaAuthHandler
rsa
,
String
label
,
String
creatorID
)
{
TeamParamSet
param
=
new
TeamParamSet
(
rsa
,
TeamParamSet
.
action_team_create
);
param
.
setParamLabel
(
label
)
.
setParamUserID
(
creatorID
);
return
param
;
}
}
src/main/java/com/tongda/tdpimssdk/remote/paramset/AssetParamSet.java
0 → 100644
View file @
a953e9fe
package
com
.
tongda
.
tdpimssdk
.
remote
.
paramset
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.tongda.tdpimssdk.http.PimHttpUtil
;
import
com.tongda.tdpimssdk.remote.entity.RemoteAsset
;
import
com.tongda.tdpimssdk.remote.entity.RemoteDocument
;
import
com.tongda.tdpimssdk.remote.RemoteSaAuthHandler
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
static
com
.
tongda
.
tdpimssdk
.
http
.
PimHttpUtil
.
resultUtil
;
/**
* @Tittle: AssetVo
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/5/25 19:10
*/
@Data
public
class
AssetParamSet
{
public
static
final
int
action_asset_create
=
100
;
public
static
final
int
action_asset_metadata_update
=
101
;
public
static
final
int
action_asset_delete
=
102
;
public
static
final
int
action_asset_upgrade
=
103
;
public
static
final
int
action_asset_change_lifecycle
=
104
;
public
static
final
int
action_document_metadata_update
=
200
;
public
static
final
int
action_document_create
=
201
;
public
static
final
int
action_document_delete
=
202
;
public
static
final
int
action_document_file_upload
=
203
;
public
static
final
int
action_document_upgrade
=
204
;
public
static
final
int
action_document_change_lifecycle
=
205
;
@JSONField
(
serialize
=
false
)
public
int
actionType
=
0
;
@JSONField
(
serialize
=
false
)
protected
RemoteSaAuthHandler
rsh
;
//用于创建资产的基本属性信息
private
String
templateID
;
private
String
label
;
private
String
userID
;
private
String
userName
;
//用于修改元数据、上传流文件、删除资产的实体对象ID, 升级版本,变更生命周期状态
private
String
id
;
private
String
desc
;
private
String
lcEvent
;
//用于文档上传二进制流文件所需的属性信息
private
String
mediaType
;
private
String
upLoadFilePath
;
//用于创建和修改元数据字段的属性信息
private
List
<
AssetField
>
fields
;
public
AssetParamSet
(){
}
public
AssetParamSet
(
RemoteSaAuthHandler
rsh
,
int
actionType
){
this
.
rsh
=
rsh
;
this
.
actionType
=
actionType
;
}
public
AssetParamSet
setAssetField
(
AssetField
field
){
if
(
fields
==
null
){
this
.
fields
=
new
ArrayList
<>();
}
this
.
fields
.
add
(
field
);
return
this
;
}
/**
* '[
* {"key": "tdpim.asset.mainframe.cpu.count", "type":"SingleValue", "value":"6"},
* {"key": "tdpim.asset.mainframe.cpu.temp", "type":"Range", "valueMin":"1", "valueMax":"5"},
* {"key": "tdpim.asset.mainframe.area", "type":"MultiSelect", "selectedIDs":["CandidateValue-1110951999471353858","CandidateValue-1110951999471353859"]}
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public
static
class
AssetField
{
//元数据Key
private
String
key
;
//元数据模式
private
String
mode
;
//元数据模式
//元数据据计量单位
private
String
uom
;
//单值
private
String
value
;
// 范围
private
String
valueMin
;
private
String
valueMax
;
// 多选
private
List
<
String
>
selectedIDs
;
public
AssetField
(
String
key
,
String
value
){
this
.
setKey
(
key
);
this
.
setValue
(
value
);
}
public
AssetField
(
String
key
,
Integer
value
,
String
uom
){
this
.
setKey
(
key
);
this
.
setIntegerValue
(
value
);
this
.
setUom
(
uom
);
}
public
AssetField
(
String
key
,
Float
value
,
String
uom
){
this
.
setKey
(
key
);
this
.
setFloatValue
(
value
);
this
.
setUom
(
uom
);
}
public
AssetField
(
String
key
,
Integer
valueMin
,
Integer
valueMax
,
String
uom
){
this
.
setKey
(
key
);
this
.
setIntegerValue
(
valueMin
);
this
.
setIntegerValue
(
valueMax
);
this
.
setUom
(
uom
);
}
public
AssetField
(
String
key
,
Integer
[]
values
,
String
uom
){
this
.
setKey
(
key
);
this
.
setMultiValue
(
values
);
this
.
setUom
(
uom
);
}
public
AssetField
(
String
key
,
Float
[]
values
,
String
uom
){
this
.
setKey
(
key
);
this
.
setMultiValue
(
values
);
this
.
setUom
(
uom
);
}
public
AssetField
(
String
key
,
String
[]
values
){
this
.
setKey
(
key
);
this
.
setMultiValue
(
values
);
}
/**
* 添加完整的构造方法
*/
public
void
setIntegerValue
(
Integer
value
){
this
.
setValue
(
String
.
valueOf
(
value
));
}
public
void
setFloatValue
(
Float
value
){
this
.
setValue
(
String
.
valueOf
(
value
));
}
public
void
setMinValue
(
Integer
value
){
this
.
setValueMin
(
String
.
valueOf
(
value
));
}
public
void
setMinValue
(
Float
value
){
this
.
setValueMin
(
String
.
valueOf
(
value
));
}
public
void
setMaxValue
(
Integer
value
){
this
.
setValueMax
(
String
.
valueOf
(
value
));
}
public
void
setMaxValue
(
Float
value
){
this
.
setValueMax
(
String
.
valueOf
(
value
));
}
public
void
setMultiValue
(
Integer
[]
value
){
String
v
=
""
;
for
(
Integer
i
:
value
){
v
+=
String
.
valueOf
(
i
)
+
";"
;
}
this
.
setValue
(
v
);
}
public
void
setMultiValue
(
Float
[]
value
){
String
v
=
""
;
for
(
Float
i
:
value
){
v
+=
String
.
valueOf
(
i
)
+
";"
;
}
this
.
setValue
(
v
);
}
public
void
setMultiValue
(
String
[]
value
){
String
v
=
""
;
for
(
String
i
:
value
){
v
+=
i
+
";"
;
}
this
.
setValue
(
v
);
}
}
public
AssetParamSet
setParamTemplate
(
String
templateID
){
this
.
setTemplateID
(
templateID
);
return
this
;
}
public
AssetParamSet
setParamLabel
(
String
label
){
this
.
setLabel
(
label
);
return
this
;
}
public
AssetParamSet
setParamUserID
(
String
userID
){
this
.
setUserID
(
label
);
return
this
;
}
public
AssetParamSet
setParamUploadFilePath
(
String
path
){
this
.
setUpLoadFilePath
(
path
);
return
this
;
}
public
AssetParamSet
setParamMediaType
(
String
mediaType
){
this
.
setMediaType
(
mediaType
);
return
this
;
}
public
AssetParamSet
setParamDesc
(
String
str
){
this
.
setDesc
(
str
);
return
this
;
}
public
AssetParamSet
setParamLifeCycleEvent
(
String
str
){
this
.
setLcEvent
(
str
);
return
this
;
}
//资产创建和元数据修改
private
String
doCreateAsset
(){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
RemoteAsset
.
BASE_URI
+
"?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPost
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
this
));
String
s
=
resultUtil
(
response
);
return
s
;
}
private
String
doUpdateAssetMetadataValues
(){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
rsh
.
serverPort
+
RemoteAsset
.
METADATA_URI
+
"?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPut
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
this
));
String
s
=
resultUtil
(
response
);
return
s
;
}
//文档创建和元数据修改
private
String
doCreateDocument
(){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
RemoteDocument
.
BASE_URI
+
"?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPost
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
this
));
String
s
=
resultUtil
(
response
);
return
s
;
}
private
String
doUpdateDocumentMetadataValues
(){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
RemoteDocument
.
METADATA_URI
+
"?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPut
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
this
));
String
s
=
resultUtil
(
response
);
return
s
;
}
private
String
doDeleteDocument
(){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
RemoteDocument
.
BASE_URI
+
"?dbName="
+
this
.
rsh
.
dbName
+
"&id="
+
this
.
getId
();
String
response
=
PimHttpUtil
.
sendDelete
(
this
.
rsh
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
return
s
;
}
private
String
doDeleteAsset
(){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
RemoteAsset
.
BASE_URI
+
"dbName="
+
this
.
rsh
.
dbName
+
"&id="
+
this
.
getId
();
String
response
=
PimHttpUtil
.
sendDelete
(
this
.
rsh
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
return
s
;
}
private
String
doUploadFile
()
{
File
file
=
new
File
(
this
.
getUpLoadFilePath
());
if
(!
file
.
exists
()){
return
"Error: 文件未找到:"
+
this
.
getUpLoadFilePath
();
}
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
RemoteDocument
.
UPLOAD_URI
+
"?dbName="
+
this
.
rsh
.
dbName
+
"&id="
+
this
.
getId
();
String
response
=
PimHttpUtil
.
uploadFile
(
this
.
rsh
.
saToken
,
url
,
file
);
String
s
=
resultUtil
(
response
);
return
s
;
}
private
String
doAssetUpgradeVersion
(){
//{docID: "AST_1138852517807915008", desc: "1111"}
Map
<
String
,
String
>
param
=
new
HashMap
<>();
param
.
put
(
"docID"
,
this
.
getId
());
param
.
put
(
"desc"
,
this
.
getDesc
());
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
RemoteAsset
.
BASE_URI_UPGRADE
+
"?dbName="
+
this
.
rsh
.
dbName
+
"&id="
+
this
.
getId
();
String
response
=
PimHttpUtil
.
sendPost
(
this
.
rsh
.
saToken
,
url
,
(
JSONObject
)
JSONObject
.
toJSON
(
param
));
String
s
=
resultUtil
(
response
);
return
s
;
}
private
String
doDocumentUpgradeVersion
(){
Map
<
String
,
String
>
param
=
new
HashMap
<>();
param
.
put
(
"docID"
,
this
.
getId
());
param
.
put
(
"desc"
,
this
.
getDesc
());
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
RemoteDocument
.
BASE_URI_UPGRADE
+
"?dbName="
+
this
.
rsh
.
dbName
+
"&id="
+
this
.
getId
();
String
response
=
PimHttpUtil
.
sendPost
(
this
.
rsh
.
saToken
,
url
,
(
JSONObject
)
JSONObject
.
toJSON
(
param
));
String
s
=
resultUtil
(
response
);
return
s
;
}
private
String
doAssetNewLifeCycleStatus
(){
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"entityId"
,
this
.
getId
());
Map
<
String
,
String
>
event
=
new
HashMap
<>();
event
.
put
(
"key"
,
this
.
getLcEvent
());
//"Submit"
param
.
put
(
"tdEvent"
,
event
);
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
RemoteAsset
.
BASE_URI_LIFECYCLE
+
"?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPut
(
this
.
rsh
.
saToken
,
url
,
(
JSONObject
)
JSONObject
.
toJSON
(
param
));
String
s
=
resultUtil
(
response
);
return
s
;
}
private
String
doDocumentNewLifeCycleStatus
(){
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"entityId"
,
this
.
getId
());
Map
<
String
,
String
>
event
=
new
HashMap
<>();
event
.
put
(
"key"
,
this
.
getLcEvent
());
//"Submit"
param
.
put
(
"tdEvent"
,
event
);
System
.
out
.
println
(
JSONObject
.
toJSON
(
param
));
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
RemoteDocument
.
BASE_URI_LIFECYCLE
+
"?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPut
(
this
.
rsh
.
saToken
,
url
,
(
JSONObject
)
JSONObject
.
toJSON
(
param
));
String
s
=
resultUtil
(
response
);
return
s
;
}
public
String
doAction
(){
System
.
out
.
println
(
JSON
.
toJSONString
(
this
));
switch
(
this
.
actionType
)
{
case
AssetParamSet
.
action_asset_create
:
return
doCreateAsset
();
case
AssetParamSet
.
action_document_create
:
return
doCreateDocument
();
case
AssetParamSet
.
action_document_metadata_update
:
return
doUpdateDocumentMetadataValues
();
case
AssetParamSet
.
action_asset_metadata_update
:
return
doUpdateAssetMetadataValues
();
case
AssetParamSet
.
action_document_delete
:
return
doDeleteDocument
();
case
AssetParamSet
.
action_asset_delete
:
return
doDeleteAsset
();
case
AssetParamSet
.
action_document_file_upload
:
return
doUploadFile
();
case
AssetParamSet
.
action_asset_upgrade
:
return
doAssetUpgradeVersion
();
case
AssetParamSet
.
action_asset_change_lifecycle
:
return
doAssetNewLifeCycleStatus
();
case
AssetParamSet
.
action_document_upgrade
:
return
doDocumentUpgradeVersion
();
case
AssetParamSet
.
action_document_change_lifecycle
:
return
doDocumentNewLifeCycleStatus
();
default
:
return
null
;
}
}
}
src/main/java/com/tongda/tdpimssdk/remote/paramset/TeamParamSet.java
0 → 100644
View file @
a953e9fe
package
com
.
tongda
.
tdpimssdk
.
remote
.
paramset
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.tongda.tdpimssdk.http.PimHttpUtil
;
import
com.tongda.tdpimssdk.remote.RemoteSaAuthHandler
;
import
com.tongda.tdpimssdk.remote.entity.RemoteTeam
;
import
lombok.Data
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.List
;
import
static
com
.
tongda
.
tdpimssdk
.
http
.
PimHttpUtil
.
resultUtil
;
@Data
public
class
TeamParamSet
{
@JSONField
(
serialize
=
false
)
protected
RemoteSaAuthHandler
rsh
;
public
static
final
int
action_team_create
=
100
;
public
static
final
int
action_team_upgrade_version
=
101
;
public
static
final
int
action_team_change_lifecycle
=
102
;
public
static
final
int
action_team_delete
=
103
;
public
static
final
int
action_team_add_asset_ref
=
104
;
public
static
final
int
action_team_remove_asset_ref
=
105
;
@JSONField
(
serialize
=
false
)
public
int
actionType
;
//用户创建业务
private
String
userId
;
private
String
label
;
private
String
desc
;
private
String
lifecycleID
;
//修改业务内部数据,变更状态,提升版本
private
String
teamID
;
private
String
lcEvent
;
//添加资源
private
List
<
String
>
assetListToAdd
;
private
String
assetToRemove
;
public
TeamParamSet
(
RemoteSaAuthHandler
rsh
,
int
actionType
){
this
.
rsh
=
rsh
;
this
.
actionType
=
actionType
;
}
public
TeamParamSet
setParamUserID
(
String
str
){
this
.
setUserId
(
str
);
return
this
;
}
public
TeamParamSet
setParamLabel
(
String
str
){
this
.
setLabel
(
str
);
return
this
;
}
public
TeamParamSet
setParamDesc
(
String
str
){
this
.
setDesc
(
str
);
return
this
;
}
public
TeamParamSet
setParamLifecycleID
(
String
str
){
this
.
setLifecycleID
(
str
);
return
this
;
}
public
TeamParamSet
setParamLcEvent
(
String
str
){
this
.
setLcEvent
(
str
);
return
this
;
}
public
TeamParamSet
setParamAssetListToAdd
(
List
<
String
>
assetIDList
){
this
.
setAssetListToAdd
(
assetIDList
);
return
this
;
}
public
TeamParamSet
setParamAssetToRemove
(
String
assetID
){
this
.
setAssetToRemove
(
assetID
);
return
this
;
}
private
String
doCreateTeam
(){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
RemoteTeam
.
BASE_URI
+
"?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPost
(
this
.
rsh
.
saToken
,
url
,
(
JSONObject
)
JSONObject
.
toJSON
(
this
));
String
s
=
resultUtil
(
response
);
return
s
;
}
private
String
doDeleteTeam
(){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
RemoteTeam
.
BASE_URI
+
"?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendDeleteBody
(
this
.
rsh
.
saToken
,
url
,
(
JSONObject
)
JSONObject
.
toJSON
(
this
));
String
s
=
resultUtil
(
response
);
return
s
;
}
private
String
doUpgradeVersion
(){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
RemoteTeam
.
BASE_URI_UPGRADE_VERSION
+
"?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPost
(
this
.
rsh
.
saToken
,
url
,
(
JSONObject
)
JSONObject
.
toJSON
(
this
));
String
s
=
resultUtil
(
response
);
return
s
;
}
private
String
doAssetNewLifeCycleStatus
(){
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"entityId"
,
this
.
getTeamID
());
Map
<
String
,
String
>
event
=
new
HashMap
<>();
event
.
put
(
"key"
,
this
.
getLcEvent
());
//"Submit"
param
.
put
(
"tdEvent"
,
event
);
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
RemoteTeam
.
BASE_URI_LIFECYCLE
+
"?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPut
(
this
.
rsh
.
saToken
,
url
,
(
JSONObject
)
JSONObject
.
toJSON
(
param
));
String
s
=
resultUtil
(
response
);
return
s
;
}
private
String
doAddAssetRef
(){
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"id"
,
this
.
getTeamID
());
String
ids
=
""
;
for
(
String
af
:
this
.
assetListToAdd
){
ids
+=
af
+
","
;
}
param
.
put
(
"assetID"
,
ids
);
System
.
out
.
println
(
JSONObject
.
toJSON
(
param
));
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
RemoteTeam
.
BASE_URI_ASSET
+
"?dbName="
+
this
.
rsh
.
dbName
;
System
.
out
.
println
(
url
);
String
response
=
PimHttpUtil
.
sendPut
(
this
.
rsh
.
saToken
,
url
,
(
JSONObject
)
JSONObject
.
toJSON
(
param
));
String
s
=
resultUtil
(
response
);
return
s
;
}
private
String
doRemoveAssetRef
(){
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"id"
,
this
.
getTeamID
());
param
.
put
(
"assetID"
,
this
.
assetToRemove
);
System
.
out
.
println
(
JSONObject
.
toJSON
(
param
));
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/business/asset?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendDeleteBody
(
this
.
rsh
.
saToken
,
url
,
(
JSONObject
)
JSONObject
.
toJSON
(
param
));
String
s
=
resultUtil
(
response
);
return
s
;
}
public
String
doAction
()
{
switch
(
this
.
actionType
)
{
case
TeamParamSet
.
action_team_create
:
return
doCreateTeam
();
case
TeamParamSet
.
action_team_upgrade_version
:
return
doUpgradeVersion
();
case
TeamParamSet
.
action_team_change_lifecycle
:
return
doAssetNewLifeCycleStatus
();
case
TeamParamSet
.
action_team_delete
:
return
doDeleteTeam
();
case
TeamParamSet
.
action_team_add_asset_ref
:
return
doAddAssetRef
();
case
TeamParamSet
.
action_team_remove_asset_ref
:
return
doRemoveAssetRef
();
default
:
return
null
;
}
}
}
src/main/java/com/tongda/tdpimssdk/resultVo/vo/AssetVo.java
View file @
a953e9fe
...
...
@@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
...
...
@@ -25,6 +26,14 @@ public class AssetVo {
private
List
<
AssetField
>
fields
;
public
void
addAssetField
(
AssetField
field
){
if
(
fields
==
null
){
this
.
fields
=
new
ArrayList
<>();
}
this
.
fields
.
add
(
field
);
}
/**
* '[
* {"key": "tdpim.asset.mainframe.cpu.count", "type":"SingleValue", "value":"6"},
...
...
@@ -35,23 +44,78 @@ public class AssetVo {
@NoArgsConstructor
@AllArgsConstructor
public
static
class
AssetField
{
// 单值/单选
//元数据Key
private
String
key
;
//元数据模式
private
String
mode
;
//元数据模式
private
String
value
;
//元数据据计量单位
private
String
uom
;
//单值
private
String
value
;
// 范围
// private String key;
// private String type;
private
String
valueMin
;
private
String
valueMax
;
// 多选
// private String key;
// private String type;
private
List
<
String
>
selectedIDs
;
public
void
setIntegerValue
(
Integer
value
){
this
.
setValue
(
String
.
valueOf
(
value
));
}
public
void
setFloatValue
(
Float
value
){
this
.
setValue
(
String
.
valueOf
(
value
));
}
public
void
setMinValue
(
Integer
value
){
this
.
setValueMin
(
String
.
valueOf
(
value
));
}
public
void
setMinValue
(
Float
value
){
this
.
setValueMin
(
String
.
valueOf
(
value
));
}
public
void
setMaxValue
(
Integer
value
){
this
.
setValueMax
(
String
.
valueOf
(
value
));
}
public
void
setMaxValue
(
Float
value
){
this
.
setValueMax
(
String
.
valueOf
(
value
));
}
public
void
setMultiValue
(
Integer
[]
value
){
String
v
=
""
;
for
(
Integer
i
:
value
){
v
+=
String
.
valueOf
(
i
)
+
";"
;
}
this
.
setValue
(
v
);
}
public
void
setMultiValue
(
Float
[]
value
){
String
v
=
""
;
for
(
Float
i
:
value
){
v
+=
String
.
valueOf
(
i
)
+
";"
;
}
this
.
setValue
(
v
);
}
public
void
setMultiValue
(
String
[]
value
){
String
v
=
""
;
for
(
String
i
:
value
){
v
+=
i
+
";"
;
}
this
.
setValue
(
v
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment