in SdmxStructureParser/src/main/java/org/sdmxsource/sdmx/structureparser/builder/query/v2/DataQueryBuilderV2.java [178:249]
private void processAnd(AndType andType) {
Set<DataQuerySelection> selections = new HashSet<DataQuerySelection>();
SdmxDate dateFrom = null;
SdmxDate dateTo = null;
if (andType != null) {
if (ObjectUtil.validCollection(andType.getAndList())) {
throw new SdmxNotImplementedException("DataWhere.AND followed by AND is not supported");
}
if (andType.getDimensionList() != null) {
for (DimensionType currentDimension : andType.getDimensionList()) {
for (DataQuerySelection selection : selections) {
//CAN NOT AND TWO DIMENSIONS WITH DIFFERNT VALUES
if (selection.getComponentId().equals(currentDimension.getId())) {
throw new SdmxSemmanticException(ExceptionCode.QUERY_SELECTION_ILLEGAL_AND_CODES_IN_SAME_DIMENSION, currentDimension.getId());
}
}
addComponentSelection(selections, currentDimension.getId(), currentDimension.getStringValue());
}
}
if (andType.getAttributeList() != null) {
for (AttributeType currentAttribute : andType.getAttributeList()) {
for (DataQuerySelection selection : selections) {
//CAN NOT AND TWO ATTRIBUTES WITH DIFFERNT VALUES
if (selection.getComponentId().equals(currentAttribute.getId())) {
throw new SdmxSemmanticException(ExceptionCode.QUERY_SELECTION_ILLEGAL_AND_CODES_IN_SAME_DIMENSION, currentAttribute.getId());
}
}
addComponentSelection(selections, currentAttribute.getId(), currentAttribute.getStringValue());
}
}
if (andType.getTimeList() != null) {
if (andType.getTimeList().size() > 1) {
throw new SdmxNotImplementedException("Multiple Time selection on DataWhere.And not supported");
}
for (TimeType time : andType.getTimeList()) {
Time t = new Time(time);
dateFrom = t.dateFrom;
dateTo = t.dateTo;
}
}
if (ObjectUtil.validCollection(andType.getAgencyIDList())) {
if (andType.getAgencyIDList().size() > 1) {
throw new SdmxSemmanticException(ExceptionCode.QUERY_SELECTION_ILLEGAL_AND_AGENCY_ID);
}
if (this.agencyId != null && !andType.getAgencyIDList().get(0).equals(agencyId)) {
throw new SdmxSemmanticException("Multiple agency Ids not supported on DataWhere - got '" + agencyId + "' and '" + andType.getAgencyIDList().get(0) + "'");
}
agencyId = andType.getAgencyIDList().get(0);
}
if (ObjectUtil.validCollection(andType.getKeyFamilyList())) {
if (andType.getKeyFamilyList().size() > 1) {
throw new SdmxSemmanticException(ExceptionCode.QUERY_SELECTION_ILLEGAL_AND_KEYFAMILY);
}
if (this.keyFamilyId != null && !andType.getKeyFamilyList().get(0).equals(keyFamilyId)) {
throw new SdmxSemmanticException("Multiple Data Structure Ids not supported on DataWhere - got '" + keyFamilyId + "' and '" + andType.getKeyFamilyList().get(0) + "'");
}
keyFamilyId = andType.getKeyFamilyList().get(0);
}
if (ObjectUtil.validCollection(andType.getDataflowList())) {
if (andType.getDataflowList().size() > 1) {
throw new SdmxNotImplementedException("Multiple Dataflow Ids not supported in an AND operation");
}
if (this.dataflowId != null && !andType.getDataflowList().get(0).equals(dataflowId)) {
throw new SdmxSemmanticException("Multiple Dataflow Ids not supported on DataWhere - got '" + dataflowId + "' and '" + andType.getDataflowList().get(0) + "'");
}
dataflowId = andType.getDataflowList().get(0);
}
processOr(andType.getOrList(), selections);
addGroupIfSelectionsExist(selections, dateFrom, dateTo);
}
}