public static QueryRetrieveLevel2 validateQueryIdentifier( Attributes keys, EnumSet<QueryRetrieveLevel2> levels, boolean relational) throws DicomServiceException { return validateIdentifier(keys, levels, relational, true); }
private static QueryRetrieveLevel2 validateIdentifier( Attributes keys, EnumSet<QueryRetrieveLevel2> levels, boolean relational, boolean query) throws DicomServiceException { String value = keys.getString(Tag.QueryRetrieveLevel); if (value == null) throw missingAttribute(Tag.QueryRetrieveLevel); QueryRetrieveLevel2 level; try { level = QueryRetrieveLevel2.valueOf(value); } catch (IllegalArgumentException e) { throw invalidAttributeValue(Tag.QueryRetrieveLevel, value); } if (!levels.contains(level)) throw invalidAttributeValue(Tag.QueryRetrieveLevel, value); if (level == QueryRetrieveLevel2.PATIENT) { level.checkUniqueKey(keys, query, false); return level; } for (QueryRetrieveLevel2 level2 : levels) { if (level2 == level) { if (!query) level.checkUniqueKey(keys, false, true); break; } level2.checkUniqueKey(keys, relational, false); } return level; }
private void checkUniqueKey(Attributes keys, boolean optional, boolean multiple) throws DicomServiceException { String[] ids = keys.getStrings(uniqueKey); if (ids == null || ids.length == 0) { if (!optional) throw missingAttribute(uniqueKey); } else if (!multiple && ids.length > 1) throw invalidAttributeValue(uniqueKey, StringUtils.concat(ids, '\\')); }
private static DicomServiceException invalidAttributeValue(int tag, String value) { return identifierDoesNotMatchSOPClass( "Invalid " + DICT.keywordOf(tag) + " " + TagUtils.toString(tag) + " - " + value, Tag.QueryRetrieveLevel); }
private static QueryRetrieveLevel2 validateIdentifier( Attributes keys, EnumSet<QueryRetrieveLevel2> levels, boolean relational, boolean query) throws DicomServiceException { String value = keys.getString(Tag.QueryRetrieveLevel); if (value == null) throw missingAttribute(Tag.QueryRetrieveLevel); QueryRetrieveLevel2 level; try { level = QueryRetrieveLevel2.valueOf(value); } catch (IllegalArgumentException e) { throw invalidAttributeValue(Tag.QueryRetrieveLevel, value); } if (!levels.contains(level)) throw invalidAttributeValue(Tag.QueryRetrieveLevel, value); if (level == QueryRetrieveLevel2.PATIENT) { level.checkUniqueKey(keys, query, false); return level; } for (QueryRetrieveLevel2 level2 : levels) { if (level2 == level) { if (!query) level.checkUniqueKey(keys, false, true); break; } level2.checkUniqueKey(keys, relational, false); } return level; }
private void checkUniqueKey(Attributes keys, boolean optional, boolean multiple) throws DicomServiceException { String[] ids = keys.getStrings(uniqueKey); if (ids == null || ids.length == 0) { if (!optional) throw missingAttribute(uniqueKey); } else if (!multiple && ids.length > 1) throw invalidAttributeValue(uniqueKey, StringUtils.concat(ids, '\\')); }
private static DicomServiceException invalidAttributeValue(int tag, String value) { return identifierDoesNotMatchSOPClass( "Invalid " + DICT.keywordOf(tag) + " " + TagUtils.toString(tag) + " - " + value, Tag.QueryRetrieveLevel); }
public static QueryRetrieveLevel2 validateRetrieveIdentifier( Attributes keys, EnumSet<QueryRetrieveLevel2> levels, boolean relational) throws DicomServiceException { return validateIdentifier(keys, levels, relational, false); }
private static DicomServiceException missingAttribute(int tag) { return identifierDoesNotMatchSOPClass( "Missing " + DICT.keywordOf(tag) + " " + TagUtils.toString(tag), tag); }
public static QueryRetrieveLevel2 validateQueryIdentifier( Attributes keys, EnumSet<QueryRetrieveLevel2> levels, boolean relational) throws DicomServiceException { return validateIdentifier(keys, levels, relational, true); }
private static DicomServiceException missingAttribute(int tag) { return identifierDoesNotMatchSOPClass( "Missing " + DICT.keywordOf(tag) + " " + TagUtils.toString(tag), tag); }
public static QueryRetrieveLevel2 validateRetrieveIdentifier( Attributes keys, EnumSet<QueryRetrieveLevel2> levels, boolean relational) throws DicomServiceException { return validateIdentifier(keys, levels, relational, false); }