public static List<String> getSlotTypeValues(List<SlotType1> slots, String name) { if (slots != null) { for (int i=0, len=slots.size() ; i < len ; i++) { if (name.equals(slots.get(i).getName()) && slots.get(i).getValueList() != null) { return slots.get(i).getValueList().getValue(); } } } return null; } public static List<String> getSlotValues(List<Slot> slots, String name) {
private PatSlot(SlotType1 slot) { slotValues = slot.getValueList().getValue(); }
public static String getSlotValue(List<SlotType1> slots, String slotName, String def) { for (SlotType1 slot : slots) { if ( slot.getName().equals(slotName)) { List<String> l = slot.getValueList().getValue(); return l.isEmpty() ? def : l.get(0); } } return def; }
public static String addOrCheckedOverwriteSlot(RegistryObjectType ro, Map<String, SlotType1> slots, String slotName, String val, boolean ignoreCase) throws JAXBException { if (slots == null) slots = getSlotsFromRegistryObject(ro); SlotType1 oldSlot = (SlotType1)slots.get(slotName); if (oldSlot != null) { List<String> values = oldSlot.getValueList().getValue(); if (values != null && values.size() > 0 && ! (ignoreCase ? val.equalsIgnoreCase(values.get(0)) : val.equals(values.get(0))) ) { return values.get(0); } } addOrOverwriteSlot(ro, slots, slotName, val); return null; } public static void addOrOverwriteSlot(RegistryObjectType ro, Map<String, SlotType1> slots, String slotName, String... val) throws JAXBException {
public static SlotType1 setSlot(RegistryObjectType ro, String name, String type, Collection<String> values) { SlotType1 slot = createSlot(name, type); if (values != null && values.size() > 0) slot.getValueList().getValue().addAll(values); List<SlotType1> slots = ro.getSlot(); for (int i = 0, len = slots.size() ; i < len ; i++) { if (slots.get(i).getName().equals(name)) { slots.remove(i); break; } } slots.add(slot); return slot; }
public String getSlotValue(IdentifiableType idType, String slotName) { List<SlotType1> list = idType.getSlot(); if (list != null) { for (SlotType1 slotType : list) { if (slotName.equals(slotType.getName())) return slotType.getValueList().getValue().get(0); } } return null; }
@SuppressWarnings("unchecked") private void setValues(int idx, List<String> values) { if (subAuthors[idx] == null) { if (values != null && values.size() > 0) { subAuthors[idx] = Util.setSlot(author, slotNames[idx], null, values).getValueList().getValue(); } } else { if (values == null) { Util.removeSlot(author, slotNames[idx]); subAuthors[idx] = null; } else { subAuthors[idx].clear(); subAuthors[idx].addAll(values); } } } @Override
private void copySlots(List<SlotType1> list, Identifiable ro) { List<Slot> slots = new ArrayList<Slot>(); if (list != null) { List<String> values; for (SlotType1 slotType : list) { if (!XDSConstants.SLOT_NAME_LAST_UPDATE_TIME.equals(slotType.getName())) { values = slotType.getValueList().getValue(); for (int i = 0, len = values.size() ; i < len ; i++) { slots.add(newSlot(ro, slotType.getName(), slotType.getSlotType(), values.get(i))); } } } if (ro instanceof XDSFolder) { slots.add( newSlot(ro, XDSConstants.SLOT_NAME_LAST_UPDATE_TIME, null, sdf.format(new Date()))); } } ro.setSlots(slots); }
public static Map<String, StoredQueryParam> getQueryParams(AdhocQueryRequest req) throws XDSException { List<SlotType1> slots = req.getAdhocQuery().getSlot(); Map<String, StoredQueryParam> params = new HashMap<String, StoredQueryParam>(); SlotType1 slot; StoredQueryParam param; for (int i = 0, len= slots.size() ; i < len ; i++) { slot = slots.get(i); param = params.get(slot.getName()); if (param == null) { param = new StoredQueryParam(slot.getName()); params.put(param.getName(), param); } param.addValues(slot.getValueList().getValue()); } return params; }
public XDSCode getXDSCode(ClassificationType clType, boolean createMissing) throws XDSException { String scheme = clType.getClassificationScheme(); String codeValue = clType.getNodeRepresentation(); String codeDesignator = clType.getSlot().get(0).getValueList().getValue().get(0); if (!createMissing) { if (!adCodes.isClassSchemeCodeDefined(scheme, codeValue, codeDesignator)) { throw new XDSException(XDSException.XDS_ERR_REGISTRY_METADATA_ERROR, "Unknown code:"+ codeValue+"^^"+codeDesignator+" ("+scheme+")", null); } } XDSCode code = new XDSCode(codeValue, codeDesignator, clType.getName().getLocalizedString().get(0).getValue(), scheme); try { return (XDSCode) em.createNamedQuery(XDSCode.FIND_BY_CODE_VALUE) .setParameter(1, codeValue) .setParameter(2, codeDesignator) .setParameter(3, scheme) .getSingleResult(); } catch (NoResultException x) { log.info("Store new XDS Code! code:"+code); em.persist(code); return code; } }
PatSlot patSlot = new PatSlot(slot); try { for (String pid : slot.getValueList().getValue()) { patSlot.addPatIDs(pixClient.queryXadPIDs(pid.substring(1, pid.length()-1), domains));
public PnRRequest(String sourceID, String submissionSetUID, String patID, String srcPatID, String patName, String sex, String birthdate, String address) { this(sourceID, submissionSetUID, patID, srcPatID); if (patName != null) { srcPatInfoSlot = Util.createSlot(XDSConstants.SLOT_NAME_SOURCE_PATIENT_INFO, null, "PID-3|"+srcPatID, "PID-5|"+patName); List<String> values = srcPatInfoSlot.getValueList().getValue(); addValue(values, birthdate, "PID-7|"); addValue(values, sex, "PID-8|"); addValue(values, address, "PID-11|"); } }
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()); } }