public static void addOrOverwriteSlot(RegistryObjectType ro, Map<String, SlotType1> slots, String slotName, String... val) throws JAXBException { if ( slots.containsKey(slotName) ) { SlotType1 oldSlot = (SlotType1)slots.get(slotName); ro.getSlot().remove(oldSlot); } SlotType1 slot = objFac.createSlotType1(); slot.setName(slotName); ValueListType valueList = objFac.createValueListType(); for ( int i = 0 ; i < val.length ; i++) { valueList.getValue().add(val[i]); } slot.setValueList(valueList); ro.getSlot().add(slot); }
public static SlotType1 createSlot(String name, String type, String...values) { SlotType1 slot = Util.rimFactory.createSlotType1(); slot.setName(name); slot.setSlotType(type); ValueListType valueList = rimFactory.createValueListType(); slot.setValueList(valueList); if (values != null) { List<String> l = valueList.getValue(); for (int i = 0 ; i < values.length ; i++) { l.add(values[i]); } } return slot; }
private void copySlotType(List<Slot> slots, RegistryObjectType roType) { if (slots != null) { SlotType1 slotType; HashMap<String, SlotType1> slotTypeMap = new HashMap<String, SlotType1>(); for (Slot slot : slots) { slotType = slotTypeMap.get(slot.getName()); if (log.isDebugEnabled()) log.debug("########add slot name:"+slot.getName()+" value:"+slot.getValue()+" parent.pk:"+slot.getParent().getPk()+" pk:"+slot.getPk()); if (slotType == null) { slotType = factory.createSlotType1(); slotType.setName(slot.getName()); slotType.setSlotType(slot.getType()); slotType.setValueList(factory.createValueListType()); slotTypeMap.put(slot.getName(), slotType); } slotType.getValueList().getValue().add(slot.getValue()); } roType.getSlot().addAll(slotTypeMap.values()); } }