windchill 建模

1.继承WTObject
@GenAsPersistable(
  superClass = WTObject.class,
  properties = {
   @GeneratedProperty(name = "note", type = String.class, constraints = @PropertyConstraints(upperLimit = 500)),
  ......
   @GeneratedProperty(name = "str1", type = String.class)
  },
  foreignKeys = {
    @GeneratedForeignKey(foreignKeyRole = @ForeignKeyRole(name = "itemId", type = WTPartMaster.class, supportedAPI = SupportedAPI.PUBLIC, cascade = false,constraints = @PropertyConstraints(required = true))),
    @GeneratedForeignKey(foreignKeyRole = @ForeignKeyRole(name = "pscItemId", type = StandardProduct.class, supportedAPI = SupportedAPI.PUBLIC, cascade = false))
  })
public class ClassName extends _ClassName {
    static final long serialVersionUID = 1;
    public static ClassName newClassName () throws WTException {
     ClassName instance = new ClassName();
        instance.initialize();
        return instance;
    }
}
2.带大小版本,带生命周期
@GenAsPersistable (
  superClass=RevisionControlled.class, interfaces = { WTContained.class, Typed.class, TypeManaged.class, LifeCycleManaged.class,IBAHolder.class },
  properties={
   @GeneratedProperty(name = "orderId", type = Integer.class,constraints = @PropertyConstraints(required=true)),
   ......
   @GeneratedProperty(name = "str1", type = String.class)
  },
  foreignKeys = {
   @GeneratedForeignKey(foreignKeyRole = @ForeignKeyRole(name = "master", type = WeaveOrderMaster.class, supportedAPI = SupportedAPI.PUBLIC,
     cascade = false, constraints = @PropertyConstraints(required = true)),
              myRole = @MyRole(name = "iteration", supportedAPI = SupportedAPI.PUBLIC, cascade = false)),
      @GeneratedForeignKey(foreignKeyRole = @ForeignKeyRole(name = "typeId", type = ProductCategory.class, supportedAPI = SupportedAPI.PUBLIC, cascade = false))
  },       
  derivedProperties = {
   @DerivedProperty(name = "number", derivedFrom = "master>number", supportedAPI = SupportedAPI.PUBLIC),
         @DerivedProperty(name = "name", derivedFrom = "master>name", supportedAPI = SupportedAPI.PUBLIC) }
)
public class ClassName extends _ClassName {
 static final long serialVersionUID = 1;
 public static ClassName newClassName () throws Exception{
  ClassName instance = new ClassName();
  instance.initialize();
  return instance;
 }
 
  public TypeDefinitionInfo getTypeDefinitionInfo()
     {
         return null;
     }
     public Object getValue()
     {
         return null;
     }
     public void setValue(String s, String s1)
     {
     }
     public String getFlexTypeIdPath()
     {
         return null;
     }
}
------------------------------------------
@GenAsPersistable(superClass=Master.class, interfaces={UniquelyIdentified.class},
properties={
@GeneratedProperty(name="number", type=String.class, supportedAPI=SupportedAPI.PUBLIC,     
   constraints=@PropertyConstraints(stringCase=StringCase.UPPER_CASE, changeable=Changeable.VIA_OTHER_MEANS, required=true),
   columnProperties=@ColumnProperties(index=true, columnName="WaveOrderNumber")),
@GeneratedProperty(name="name", type=String.class, supportedAPI=SupportedAPI.PUBLIC,
   constraints=@PropertyConstraints(changeable=Changeable.VIA_OTHER_MEANS, upperLimit=4000,required=true))
},
tableProperties = @TableProperties(tableName = "ClassNameMaster")
)
public class ClassNameMaster extends _ClassNameMaster{
 static final long serialVersionUID = 1;
 
 protected void setIdentificationObject( SuperObjectMasterIdentity identity ) {
       number = identity.getNumber();
       name = identity.getName();
    }
    public IdentificationObject getIdentificationObject() throws WTException {
       return SuperObjectMasterIdentity.newSuperObjectMasterIdentity(getNumber(), getName());
    }
    @Override
    public String getIdentity() {
       return getNumber() + " - " + getName();
    }
 
 public static WeaveOrderMaster newWeaveOrderMaster() throws WTException {
  WeaveOrderMaster instance = new WeaveOrderMaster();
      instance.initialize();
      return instance;
   }
}
 
 
 
3.执行命令
ant -f bin/tools.xml model_uninstall -Dmodel_uninstall.filter="\Acom\.xxx\.cto|=com\.xxx\.cto"
ant -f bin/tools.xml class -Dclass.includes=com/xxx/cto/model/**
ant -f bin\tools.xml sql_script -Dgen.input=com.xxx.cto.model.**

 

你可能感兴趣的:(windchill 建模)