Enterprise Administration > Windchill Data Loading > Loading Variant Specifications > Loading Variant Specifications Using an API > Loading Variant Specifications Using Java List API > Sample Code for Java List API
  
Sample Code for Java List API
Below is a sample code for using API #1 for loading variant specifications.
public static void main(String[] args) throws Exception {

// Create part config specs

List<VariantLoadPartConfigSpecBean> partConfigSpecBeans = new
ArrayList<VariantLoadPartConfigSpecBean> (1);
VariantLoadPartConfigSpecBean partConfigSpecBean1 = new
VariantLoadPartConfigSpecBean("MyPartConfigSpec1", null, null, null, null);
partConfigSpecBeans.add(partConfigSpecBean1);

// Create a Latest ATO rule Config spec

List<VariantLoadATORuleConfigSpecBean> atoConfigSpecBeans = new
ArrayList<VariantLoadATORuleConfigSpecBean> (1);

VariantLoadATORuleConfigSpecBean atoConfigSpecBean1 = new

VariantLoadATORuleConfigSpecBean("MyATOConfigSpec1", null, null);
atoConfigSpecBeans.add(atoConfigSpecBean1);

VariantLoadNavCriteriaBean bean1 = new VariantLoadNavCriteriaBean();

bean1.setVariantSpecName("TestThruApi3");
bean1.setVariantSpecDescription("Test thru API 1");
bean1.setVariantSpecFolder("/Default");
bean1.setVariantSpecCreateVariants(false);
bean1.setPartNumber("BICYCLE1");
bean1.setRuleCheckingDisabled(true);
bean1.setPartViewInformation("Design");
bean1.setOrganization("Demo Organization");

List<String> choices = new ArrayList<String>();

choices.add("D0022");
bean1.addChoiceNames("Locale", choices);

choices = new ArrayList<String>();
choices.add("D0009");

bean1.addChoiceNames("Steering Type", choices);

// Use the part and option filter config specs from above
bean1.addPartConfigSpec("MyPartConfigSpec1");
bean1.addAtoRuleConfigSpecs("MyATOConfigSpec1");
//////////////////////////////////////////////////////

VariantLoadNavCriteriaBean bean2 = new VariantLoadNavCriteriaBean();

bean2.setVariantSpecName("TestThruApi1");
bean2.setVariantSpecDescription("Test thru API 1");
bean2.setVariantSpecFolder("/Default");
bean2.setVariantSpecCreateVariants(false);
bean2.setPartNumber("BICYCLE1");
bean2.setRuleCheckingDisabled(true);
bean2.setPartViewInformation("Design");
bean2.setOrganization("Demo Organization");

choices = new ArrayList<String>();
choices.add("D0022");

bean2.addChoiceNames("Locale", choices);

List<VariantLoadNavCriteriaBean> beans = new ArrayList<VariantLoadNavCriteriaBean>(1);

beans.add(bean1);
beans.add(bean2);
VariantSpecLoaderHelper.service.loadVariantSpecs(beans, partConfigSpecBeans, atoConfigSpecBeans);
}