客製化開發中會用到Windchill 創建/更新部件時獲取屬性佈局,屬性約束範圍 API
獲取佈局
/**
* 獲取佈局
* @param type
* @return
* @throws NotAuthorizedException
* @throws WTContainerException
* @throws WTException
*/
public static LayoutDefinitionReadView getLayout(Typed type) throws NotAuthorizedException, WTContainerException, WTException {
LayoutDefinitionReadView layout = null;
TypeDefinitionReference ref = type.getTypeDefinitionReference();
TypeIdentifier t = EPMSoftTypeServerUtilities.getTypeIdentifier(ref);
TypeDefinitionManager theTypeDefinitionManager = TypeDefinitionManager.getTypeDefinitionManagerInstance();
TypeDefinitionReadView arg3 = theTypeDefinitionManager.getTypeDefView(getTypeDefName(t));
Collection<LayoutDefinitionReadView> layouts = arg3.getAllLayouts();
for(LayoutDefinitionReadView layoutDefinitionReadView : layouts) {
String name = layoutDefinitionReadView.getName();
System.out.println("layoutName=="+name);
if("Edit Layout".equals(name)) {
layout = layoutDefinitionReadView;
break;
}
}
// LayoutDefinitionReadView layout = TypeDefinitionServiceHelper.service.getLayoutDefinition(t, "", "Edit Layout");
return layout;
}
查詢對象屬性值和約束
/**
* 查詢對象屬性值和約束
* @param part
* @throws RemoteException
* @throws WTException
*/
public static void getAttrite(WTPart part) throws RemoteException, WTException {
String softtype = TypeIdentifierUtilityHelper.service.getTypeIdentifier(part).toString();
TypeIdentifier ti = TypedUtility.getTypeIdentifier(softtype);
TypeDefinitionReadView tv = TypeDefinitionServiceHelper.service.getTypeDefView(ti);
Collection<AttributeDefinitionReadView> attrs = tv.getAllAttributes();
IBAHolder ibaHolder = null;
DefaultAttributeContainer dac = null;
ibaHolder = IBAValueHelper.service.refreshAttributeContainerWithoutConstraints(part);
dac = (DefaultAttributeContainer) ibaHolder.getAttributeContainer();
AbstractValueView valueView[] = dac.getAttributeValues();
//查詢屬性值
if (valueView.length != 0) {
for (int i = 0; i < valueView.length; i++) {
AbstractValueView avv = valueView[i];
if(!(avv instanceof StringValueDefaultView)) {
//只讀字符型
continue;
}
String attrname = avv.getDefinition().getName();
String attrValue = ((StringValueDefaultView) avv).getValue();
System.out.println("IBAName=="+attrname);
System.out.println("IBAValue=="+attrValue);
AttributeDefinitionReadView av = tv.getAttributeByName(attrname);
if (av == null) {
continue;
}
Collection<ConstraintDefinitionReadView> constraints = av.getAllConstraints();
for (ConstraintDefinitionReadView constraint : constraints) {
ConstraintRuleDefinitionReadView crdrv = constraint.getRule();
DatatypeReadView datatypeReadView = crdrv.getDatatype();
String datatype = datatypeReadView.getName();
boolean isDateTimestampType = Timestamp.class.getName().equals(datatype);
boolean isFloatingPointWithUnitsType = FloatingPointWithUnits.class.getName().equals(datatype);
boolean isLong = Long.class.getName().equals(datatype);
boolean isString = String.class.getName().equals(datatype);
String rule = constraint.getRule().getKey().toString();
System.out.println("rule===========>" + rule);
if (rule.indexOf("com.ptc.core.lwc.server.LWCEnumerationBasedConstraint") > -1) {
// 枚舉
RuleDataObject rdo = constraint.getRuleDataObj();
if (rdo != null) {
Collection coll = rdo.getEnumDef().getAllEnumerationEntries().values();
Iterator<EnumerationEntryReadView> it = coll.iterator();
while (it.hasNext()) {
EnumerationEntryReadView view = it.next();
String enumKey = view.getName();
String enumName = view.getPropertyValueByName("displayName").getValue().toString();
System.out.println("key: "+enumKey+"====enumName: "+enumName);
}
}
} else if (rule.indexOf("com.ptc.core.meta.container.common.impl.StringLengthConstrain") > -1) {
// 長度
RuleDataObject rdo = constraint.getRuleDataObj();
} else if (rule.indexOf("com.ptc.core.meta.container.common.impl.DiscreteSetConstraint") > -1) {
// 離散型
} else if (rule.indexOf("com.ptc.core.meta.container.common.impl.RangeConstrain") > -1) {
// 有效範圍
} else if (rule.indexOf("com.ptc.core.meta.container.common.impl.SuggestedValuesConstraint") > -1) {
// 建議值約束
} else if (rule.indexOf("com.ptc.core.meta.container.common.impl.ValueRequiredConstraint") > -1) {
// 必需值約束
System.out.println("必須的");
} else if (rule.indexOf("com.ptc.core.meta.container.common.impl.SingleValuedConstraint") > -1) {
// 單值約束
System.out.println("單值");
} else if (rule.indexOf("com.ptc.core.meta.container.common.impl.WildcardConstraint") > -1) {
// 通配符
}
}
}
}
}
給個栗子
windchill shell>D:\ptc\Windchill_10.0\Windchill>windchill ext.ec.main.test.Test OR:wt.part.WTPart:208995853
logs:
RMI TCP Connection(2422)-127.0.0.1: layoutName==More Attributes Info Page Layout
RMI TCP Connection(2422)-127.0.0.1: layoutName==Part Structure Classification
RMI TCP Connection(2422)-127.0.0.1: layoutName==More Attributes Phone Info Page Layout
RMI TCP Connection(2422)-127.0.0.1: layoutName==Primary Attributes Info Page Layout
RMI TCP Connection(2422)-127.0.0.1: layoutName==More Attributes Tablet Info Page Layout
RMI TCP Connection(2422)-127.0.0.1: layoutName==Insert Part Wizard
RMI TCP Connection(2422)-127.0.0.1: layoutName==Primary Attributes Tablet Info Page Layout
RMI TCP Connection(2422)-127.0.0.1: layoutName==Primary Attributes Phone Info Page Layout
RMI TCP Connection(2422)-127.0.0.1: layoutName==Default Layout
RMI TCP Connection(2422)-127.0.0.1: layoutName==Model Structure Attributes
RMI TCP Connection(2422)-127.0.0.1: layoutName==Create New Layout
RMI TCP Connection(2422)-127.0.0.1: layoutName==Structure Compare Attributes
RMI TCP Connection(2422)-127.0.0.1: layoutName==Part Structure Attributes
RMI TCP Connection(2422)-127.0.0.1: layoutName==Edit Layout
RMI TCP Connection(2422)-127.0.0.1: Attributes
RMI TCP Connection(2422)-127.0.0.1: null
RMI TCP Connection(2422)-127.0.0.1: name===partType===row===2====clo===0
RMI TCP Connection(2422)-127.0.0.1: name===Remark===row===10====clo===0
RMI TCP Connection(2422)-127.0.0.1: name===com.tclcom.ModelCode===row===11====clo===0
RMI TCP Connection(2422)-127.0.0.1: name===minimumRequired===row===3====clo===0
RMI TCP Connection(2422)-127.0.0.1: name===com.tclcom.MainColor1===row===14====clo===0
RMI TCP Connection(2422)-127.0.0.1: name===com.tclcom.PL_NUMBER===row===17====clo===0
RMI TCP Connection(2422)-127.0.0.1: name===jobAuthorizationNumber===row===6====clo===0
RMI TCP Connection(2422)-127.0.0.1: name===com.tclcom.BOMVersion===row===18====clo===0
RMI TCP Connection(2422)-127.0.0.1: name===contractNumber===row===5====clo===0
RMI TCP Connection(2422)-127.0.0.1: name===com.tclcom.ManufacturerID===row===0====clo===0
RMI TCP Connection(2422)-127.0.0.1: name===com.tclcom.AssemblyType===row===15====clo===0
RMI TCP Connection(2422)-127.0.0.1: name===source===row===8====clo===0
RMI TCP Connection(2422)-127.0.0.1: name===phase===row===7====clo===0
RMI TCP Connection(2422)-127.0.0.1: name===com.tclcom.BOMReleasedToERP===row===12====clo===0
RMI TCP Connection(2422)-127.0.0.1: name===com.tclcom.CustomerSuppliedMaterial===row===13====clo===0
RMI TCP Connection(2422)-127.0.0.1: name===com.tclcom.MainColor2===row===16====clo===0
RMI TCP Connection(2422)-127.0.0.1: name===classification.id===row===1====clo===0
RMI TCP Connection(2422)-127.0.0.1: name===ICS===row===9====clo===0
RMI TCP Connection(2422)-127.0.0.1: name===maximumAllowed===row===4====clo===0
RMI TCP Connection(2422)-127.0.0.1: IBAName==MP3
RMI TCP Connection(2422)-127.0.0.1: IBAValue==MP3
RMI TCP Connection(2422)-127.0.0.1: IBAName==LOGO
RMI TCP Connection(2422)-127.0.0.1: IBAValue==ALCATEL Logo
RMI TCP Connection(2422)-127.0.0.1: IBAName==HandsetType
RMI TCP Connection(2422)-127.0.0.1: IBAValue==Tablet
RMI TCP Connection(2422)-127.0.0.1: IBAName==Comments
RMI TCP Connection(2422)-127.0.0.1: IBAValue==N/A
RMI TCP Connection(2422)-127.0.0.1: IBAName==FunctionDescription
RMI TCP Connection(2422)-127.0.0.1: IBAValue==_0821_02
RMI TCP Connection(2422)-127.0.0.1: IBAName==ProductName
RMI TCP Connection(2422)-127.0.0.1: IBAValue==Wonly Test01
RMI TCP Connection(2422)-127.0.0.1: IBAName==ChineseName
RMI TCP Connection(2422)-127.0.0.1: IBAValue==手機機頭
RMI TCP Connection(2422)-127.0.0.1: IBAName==Color
RMI TCP Connection(2422)-127.0.0.1: IBAValue==RED
RMI TCP Connection(2422)-127.0.0.1: IBAName==EnglishName
RMI TCP Connection(2422)-127.0.0.1: IBAValue==Function Heart_0821_02
RMI TCP Connection(2422)-127.0.0.1: IBAName==CommercialName
RMI TCP Connection(2422)-127.0.0.1: IBAValue==N/A
RMI TCP Connection(2422)-127.0.0.1: IBAName==Manufactureplace
RMI TCP Connection(2422)-127.0.0.1: IBAValue==CHINA
RMI TCP Connection(2422)-127.0.0.1: IBAName==Language
RMI TCP Connection(2422)-127.0.0.1: IBAValue==Qwerty+Latin
RMI TCP Connection(2422)-127.0.0.1: IBAName==com.tclcom.PartDesciption
RMI TCP Connection(2422)-127.0.0.1: IBAValue==Function Heart_0821_02,Wonly Test01,Tablet,MP3,Qwerty+Latin,RED,ALCATEL Logo,_0821_02,CHINA
RMI TCP Connection(2422)-127.0.0.1: rule===========>com.ptc.core.meta.container.common.impl.SingleValuedConstraint:com.ptc.core.lwc.server.LWCBasicConstraint:2579:null
RMI TCP Connection(2422)-127.0.0.1: 單值
RMI TCP Connection(2422)-127.0.0.1: rule===========>com.ptc.core.meta.container.common.impl.StringLengthConstraint:com.ptc.core.lwc.server.LWCBasicConstraint:2579:null
RMI TCP Connection(2422)-127.0.0.1: IBAName==com.tclcom.ModelCode
RMI TCP Connection(2422)-127.0.0.1: IBAValue==0000
RMI TCP Connection(2422)-127.0.0.1: rule===========>com.ptc.core.meta.container.common.impl.SingleValuedConstraint:com.ptc.core.lwc.server.LWCBasicConstraint:2579:null
RMI TCP Connection(2422)-127.0.0.1: 單值
RMI TCP Connection(2422)-127.0.0.1: rule===========>com.ptc.core.meta.container.common.impl.StringLengthConstraint:com.ptc.core.lwc.server.LWCBasicConstraint:2579:null
RMI TCP Connection(2422)-127.0.0.1: IBAName==com.tclcom.MainColor1
RMI TCP Connection(2422)-127.0.0.1: IBAValue==Red
RMI TCP Connection(2422)-127.0.0.1: rule===========>com.ptc.core.meta.container.common.impl.SingleValuedConstraint:com.ptc.core.lwc.server.LWCBasicConstraint:2579:null
RMI TCP Connection(2422)-127.0.0.1: 單值
RMI TCP Connection(2422)-127.0.0.1: rule===========>com.ptc.core.meta.container.common.impl.StringLengthConstraint:com.ptc.core.lwc.server.LWCBasicConstraint:2579:null
RMI TCP Connection(2422)-127.0.0.1: IBAName==com.tclcom.MainColor2
RMI TCP Connection(2422)-127.0.0.1: IBAValue==Black
RMI TCP Connection(2422)-127.0.0.1: rule===========>com.ptc.core.meta.container.common.impl.SingleValuedConstraint:com.ptc.core.lwc.server.LWCBasicConstraint:2579:null
RMI TCP Connection(2422)-127.0.0.1: 單值
RMI TCP Connection(2422)-127.0.0.1: rule===========>com.ptc.core.meta.container.common.impl.StringLengthConstraint:com.ptc.core.lwc.server.LWCBasicConstraint:2579:null
RMI TCP Connection(2422)-127.0.0.1: IBAName==com.tclcom.ManufacturerID
RMI TCP Connection(2422)-127.0.0.1: IBAValue==TCT
RMI TCP Connection(2422)-127.0.0.1: rule===========>com.ptc.core.meta.container.common.impl.StringLengthConstraint:com.ptc.core.lwc.server.LWCBasicConstraint:2579:null
RMI TCP Connection(2422)-127.0.0.1: rule===========>com.ptc.core.meta.container.common.impl.SingleValuedConstraint:com.ptc.core.lwc.server.LWCBasicConstraint:2579:null
RMI TCP Connection(2422)-127.0.0.1: 單值
RMI TCP Connection(2422)-127.0.0.1: rule===========>com.ptc.core.meta.container.common.impl.ValueRequiredConstraint:com.ptc.core.lwc.server.LWCBasicConstraint:2579:null
RMI TCP Connection(2422)-127.0.0.1: 必須的
RMI TCP Connection(2422)-127.0.0.1: IBAName==com.tclcom.PL_NUMBER
RMI TCP Connection(2422)-127.0.0.1: IBAValue==WONLY TEST01 PARTLIST
RMI TCP Connection(2422)-127.0.0.1: rule===========>com.ptc.core.meta.container.common.impl.StringLengthConstraint:com.ptc.core.lwc.server.LWCBasicConstraint:2579:null
RMI TCP Connection(2422)-127.0.0.1: rule===========>com.ptc.core.meta.container.common.impl.SingleValuedConstraint:com.ptc.core.lwc.server.LWCBasicConstraint:2579:null
RMI TCP Connection(2422)-127.0.0.1: 單值
完整測試類
package ext.ec.main.test;
import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import com.ptc.core.lwc.common.view.AttributeDefinitionReadView;
import com.ptc.core.lwc.common.view.ConstraintDefinitionReadView;
import com.ptc.core.lwc.common.view.ConstraintDefinitionReadView.RuleDataObject;
import com.ptc.core.lwc.common.view.ConstraintRuleDefinitionReadView;
import com.ptc.core.lwc.common.view.DatatypeReadView;
import com.ptc.core.lwc.common.view.EnumerationEntryReadView;
import com.ptc.core.lwc.common.view.GroupDefinitionReadView;
import com.ptc.core.lwc.common.view.GroupMembershipReadView;
import com.ptc.core.lwc.common.view.LayoutDefinitionReadView;
import com.ptc.core.lwc.common.view.TypeDefinitionReadView;
import com.ptc.core.lwc.server.TypeDefinitionServiceHelper;
import com.ptc.core.lwc.server.cache.TypeDefinitionManager;
import com.ptc.core.meta.common.TypeIdentifier;
import com.ptc.core.meta.common.impl.TypeIdentifierUtilityHelper;
import com.ptc.core.meta.type.mgmt.common.TypeDefinitionDefaultView;
import com.ptc.core.meta.type.mgmt.server.impl.WTTypeDefinition;
import wt.access.NotAuthorizedException;
import wt.csm.constraint.CSMSingleDefConstraint;
import wt.csm.constraint.service.CSMConstraintHelper;
import wt.epm.util.EPMSoftTypeServerUtilities;
import wt.fc.PersistenceHelper;
import wt.fc.ReferenceFactory;
import wt.iba.constraint.AttributeConstraint;
import wt.iba.constraint.Immutable;
import wt.iba.constraint.SingleValued;
import wt.iba.constraint.StringContentDiscreteSet;
import wt.iba.constraint.ValueConstraint;
import wt.iba.constraint.ValueRequired;
import wt.iba.definition.AbstractAttributeDefinition;
import wt.iba.value.DefaultAttributeContainer;
import wt.iba.value.IBAHolder;
import wt.iba.value.litevalue.AbstractValueView;
import wt.iba.value.litevalue.StringValueDefaultView;
import wt.iba.value.service.IBAValueHelper;
import wt.inf.container.WTContainerException;
import wt.method.RemoteMethodServer;
import wt.part.WTPart;
import wt.type.TypeDefinitionReference;
import wt.type.Typed;
import wt.type.TypedUtility;
import wt.units.FloatingPointWithUnits;
import wt.util.WTException;
public class Test implements wt.method.RemoteAccess {
public static void main(String[] args) {
String oid = args[0];
try {
if (!RemoteMethodServer.ServerFlag) {
RemoteMethodServer rs = RemoteMethodServer.getDefault();
rs.setUserName("wcadmin");
rs.setPassword("wcadmin");
rs.invoke("test",
Test.class.getName(), null, new Class[] { String.class}, new Object[] { oid});
} else {
test(oid);
}
} catch (RemoteException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (WTException e) {
e.printStackTrace();
}
}
public static void test(String oid) throws WTException, RemoteException {
ReferenceFactory rf = new ReferenceFactory();
Object pbo = rf.getReference(oid).getObject();
WTPart part = (WTPart) pbo;
//獲取佈局中屬性
LayoutDefinitionReadView l = getLayout(part);
Collection<GroupDefinitionReadView> groups = l.getAllGroups();
Iterator<GroupDefinitionReadView> i = groups.iterator();
while(i.hasNext()) {
GroupDefinitionReadView groupDefinitionReadView = i.next();
System.out.println(groupDefinitionReadView.getName());
System.out.println(groupDefinitionReadView.getViewDisplayStyle());
List<GroupMembershipReadView> list = groupDefinitionReadView.getAllMembers();
for(GroupMembershipReadView member : list) {
String name = member.getName();
String clo = member.getCol().toString();
String row = member.getRow().toString();
System.out.println("name==="+name+"===row==="+row+"====clo==="+clo);
}
}
getAttrite(part);
}
/**
* 獲取佈局
* @param type
* @return
* @throws NotAuthorizedException
* @throws WTContainerException
* @throws WTException
*/
public static LayoutDefinitionReadView getLayout(Typed type) throws NotAuthorizedException, WTContainerException, WTException {
LayoutDefinitionReadView layout = null;
TypeDefinitionReference ref = type.getTypeDefinitionReference();
TypeIdentifier t = EPMSoftTypeServerUtilities.getTypeIdentifier(ref);
TypeDefinitionManager theTypeDefinitionManager = TypeDefinitionManager.getTypeDefinitionManagerInstance();
TypeDefinitionReadView arg3 = theTypeDefinitionManager.getTypeDefView(getTypeDefName(t));
Collection<LayoutDefinitionReadView> layouts = arg3.getAllLayouts();
for(LayoutDefinitionReadView layoutDefinitionReadView : layouts) {
String name = layoutDefinitionReadView.getName();
System.out.println("layoutName=="+name);
if("Edit Layout".equals(name)) {
layout = layoutDefinitionReadView;
break;
}
}
// LayoutDefinitionReadView layout = TypeDefinitionServiceHelper.service.getLayoutDefinition(t, "", "Edit Layout");
return layout;
}
private static String getTypeDefName(TypeIdentifier arg0) {
if (arg0 == null) {
return null;
} else {
String arg1 = null;
String arg2 = arg0.getTypename();
if (arg2 != null) {
int arg3 = arg2.lastIndexOf("|");
if (arg3 == -1) {
arg1 = arg2;
} else {
arg1 = arg2.substring(arg3 + 1);
}
}
return arg1;
}
}
public static WTTypeDefinition geTypeDefinition(Typed type) throws WTException {
TypeDefinitionReference ref = type.getTypeDefinitionReference();
TypeDefinitionDefaultView view = EPMSoftTypeServerUtilities.getTypeDefinition(ref);
WTTypeDefinition definition = (WTTypeDefinition) PersistenceHelper.manager.refresh(view.getObjectID());
return definition;
}
/**
* 查詢對象屬性值和約束
* @param part
* @throws RemoteException
* @throws WTException
*/
public static void getAttrite(WTPart part) throws RemoteException, WTException {
String softtype = TypeIdentifierUtilityHelper.service.getTypeIdentifier(part).toString();
TypeIdentifier ti = TypedUtility.getTypeIdentifier(softtype);
TypeDefinitionReadView tv = TypeDefinitionServiceHelper.service.getTypeDefView(ti);
Collection<AttributeDefinitionReadView> attrs = tv.getAllAttributes();
IBAHolder ibaHolder = null;
DefaultAttributeContainer dac = null;
ibaHolder = IBAValueHelper.service.refreshAttributeContainerWithoutConstraints(part);
dac = (DefaultAttributeContainer) ibaHolder.getAttributeContainer();
AbstractValueView valueView[] = dac.getAttributeValues();
//查詢屬性值
if (valueView.length != 0) {
for (int i = 0; i < valueView.length; i++) {
AbstractValueView avv = valueView[i];
if(!(avv instanceof StringValueDefaultView)) {
//只讀字符型
continue;
}
String attrname = avv.getDefinition().getName();
String attrValue = ((StringValueDefaultView) avv).getValue();
System.out.println("IBAName=="+attrname);
System.out.println("IBAValue=="+attrValue);
AttributeDefinitionReadView av = tv.getAttributeByName(attrname);
if (av == null) {
continue;
}
Collection<ConstraintDefinitionReadView> constraints = av.getAllConstraints();
for (ConstraintDefinitionReadView constraint : constraints) {
ConstraintRuleDefinitionReadView crdrv = constraint.getRule();
DatatypeReadView datatypeReadView = crdrv.getDatatype();
String datatype = datatypeReadView.getName();
boolean isDateTimestampType = Timestamp.class.getName().equals(datatype);
boolean isFloatingPointWithUnitsType = FloatingPointWithUnits.class.getName().equals(datatype);
boolean isLong = Long.class.getName().equals(datatype);
boolean isString = String.class.getName().equals(datatype);
String rule = constraint.getRule().getKey().toString();
System.out.println("rule===========>" + rule);
if (rule.indexOf("com.ptc.core.lwc.server.LWCEnumerationBasedConstraint") > -1) {
// 枚舉
RuleDataObject rdo = constraint.getRuleDataObj();
if (rdo != null) {
Collection coll = rdo.getEnumDef().getAllEnumerationEntries().values();
Iterator<EnumerationEntryReadView> it = coll.iterator();
while (it.hasNext()) {
EnumerationEntryReadView view = it.next();
String enumKey = view.getName();
String enumName = view.getPropertyValueByName("displayName").getValue().toString();
System.out.println("key: "+enumKey+"====enumName: "+enumName);
}
}
} else if (rule.indexOf("com.ptc.core.meta.container.common.impl.StringLengthConstrain") > -1) {
// 長度
RuleDataObject rdo = constraint.getRuleDataObj();
} else if (rule.indexOf("com.ptc.core.meta.container.common.impl.DiscreteSetConstraint") > -1) {
// 離散型
} else if (rule.indexOf("com.ptc.core.meta.container.common.impl.RangeConstrain") > -1) {
// 有效範圍
} else if (rule.indexOf("com.ptc.core.meta.container.common.impl.SuggestedValuesConstraint") > -1) {
// 建議值約束
} else if (rule.indexOf("com.ptc.core.meta.container.common.impl.ValueRequiredConstraint") > -1) {
// 必需值約束
System.out.println("必須的");
} else if (rule.indexOf("com.ptc.core.meta.container.common.impl.SingleValuedConstraint") > -1) {
// 單值約束
System.out.println("單值");
} else if (rule.indexOf("com.ptc.core.meta.container.common.impl.WildcardConstraint") > -1) {
// 通配符
}
}
}
}
}
public static void test11() throws RemoteException, WTException {
IBAHolder ibaHolder = null;
IBAHolder[] holders = { ibaHolder };
AttributeConstraint[] constraintList = CSMConstraintHelper.service.getCSMConstraints(holders);
for (int i = 0; i < constraintList.length; i++) {
if (!(constraintList[i] instanceof CSMSingleDefConstraint)) {
continue;
}
CSMSingleDefConstraint defConstraint = (CSMSingleDefConstraint) constraintList[i];
AbstractAttributeDefinition definition = (AbstractAttributeDefinition) defConstraint
.getAttributeDefReference().getObject();
ValueConstraint valueConstraint = defConstraint.getValueConstraint();
String attributeName = definition.getName();
boolean required = (valueConstraint instanceof ValueRequired);
boolean immutable = (valueConstraint instanceof Immutable);
boolean singleValued = (valueConstraint instanceof SingleValued);
if (valueConstraint instanceof StringContentDiscreteSet) {
StringContentDiscreteSet discreteSet = (StringContentDiscreteSet) valueConstraint;
System.out.println(discreteSet.getDiscreteSet());
}
}
}
}