Search in sources :

Example 21 with AttributeInformation

use of org.codice.alliance.nsili.common.GIAS.AttributeInformation in project alliance by codice.

the class NsiliFilterDelegate method isSupportedQueryableAttribute.

private boolean isSupportedQueryableAttribute(String propertyName) {
    List<String> mappedProperties = NsiliFilterFactory.mapToNsilQuery(propertyName);
    boolean supportedQueryAttribute = false;
    for (AttributeInformation attributeInformation : queryableAttributes.get(view)) {
        for (String mappedProperty : mappedProperties) {
            if (attributeInformation.attribute_name.equals(mappedProperty)) {
                supportedQueryAttribute = true;
                break;
            }
        }
    }
    return supportedQueryAttribute;
}
Also used : AttributeInformation(org.codice.alliance.nsili.common.GIAS.AttributeInformation)

Example 22 with AttributeInformation

use of org.codice.alliance.nsili.common.GIAS.AttributeInformation in project alliance by codice.

the class NsiliFilterFactory method buildPropertyIsLike.

public String buildPropertyIsLike(String propertyName, String value) {
    if (queryableAttributes == null) {
        return NsiliFilterDelegate.EMPTY_STRING;
    }
    // Replace * with %, since * is not a valid wildcard in BQS
    value = value.replaceAll("\\*", NsiliFilterDelegate.WILDCARD);
    value = value.replaceAll("\\?", NsiliFilterDelegate.WILDCARD);
    boolean addPrefixWildcard = false;
    boolean addPostfixWildcard = false;
    if (!value.startsWith(NsiliFilterDelegate.WILDCARD)) {
        addPrefixWildcard = true;
    }
    if (!value.endsWith(NsiliFilterDelegate.WILDCARD)) {
        addPostfixWildcard = true;
    }
    List<AttributeInformation> attributeInformationList = queryableAttributes.get(view);
    if (attributeInformationList == null) {
        return NsiliFilterDelegate.EMPTY_STRING;
    }
    Map<String, AttributeInformation> attrInfoMap = createAttrInfoMap(attributeInformationList);
    List<String> filters = new ArrayList<>();
    // anyText searches we will grab each attribute in NSILI, else we add only the attribute
    if (propertyName.equals(Metacard.ANY_TEXT)) {
        for (AttributeInformation attributeInformation : attributeInformationList) {
            if (isTextAttributeType(attributeInformation)) {
                setTextFilter(value, addPrefixWildcard, addPostfixWildcard, filters, attributeInformation);
            }
        }
    } else {
        List<String> propertyList = mapToNsilQuery(propertyName);
        String operator = EQ;
        if (addPrefixWildcard || addPostfixWildcard) {
            operator = LIKE;
        }
        for (String property : propertyList) {
            AttributeInformation attrInfo = attrInfoMap.get(property);
            setNonTextFilter(value, addPrefixWildcard, addPostfixWildcard, filters, operator, property, attrInfo);
        }
    }
    return buildOrFilter(filters);
}
Also used : AttributeInformation(org.codice.alliance.nsili.common.GIAS.AttributeInformation) ArrayList(java.util.ArrayList)

Example 23 with AttributeInformation

use of org.codice.alliance.nsili.common.GIAS.AttributeInformation in project alliance by codice.

the class NsiliSourceTest method getAttributeInformationMap.

private HashMap<String, List<AttributeInformation>> getAttributeInformationMap() {
    HashMap<String, List<AttributeInformation>> map = new HashMap<>();
    List<AttributeInformation> list = new ArrayList<>();
    Domain domain = new Domain();
    domain.t(200);
    AttributeInformation attributeInformation = new AttributeInformation(GMTI, AttributeType.TEXT, domain, NsiliFilterDelegate.EMPTY_STRING, NsiliFilterDelegate.EMPTY_STRING, RequirementMode.OPTIONAL, NsiliFilterDelegate.EMPTY_STRING, false, true);
    list.add(attributeInformation);
    map.put(NsiliConstants.NSIL_ALL_VIEW, list);
    return map;
}
Also used : AttributeInformation(org.codice.alliance.nsili.common.GIAS.AttributeInformation) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) Domain(org.codice.alliance.nsili.common.GIAS.Domain)

Example 24 with AttributeInformation

use of org.codice.alliance.nsili.common.GIAS.AttributeInformation in project alliance by codice.

the class NsiliAttributesGenerator method getNsilRelatedFileAttributes.

public static List<AttributeInformation> getNsilRelatedFileAttributes() {
    String prefix = NsiliConstants.NSIL_RELATED_FILE + ".";
    Domain domain;
    List<AttributeInformation> attributes = new ArrayList<>();
    domain = new Domain();
    domain.t(200);
    attributes.add(new AttributeInformation(prefix + NsiliConstants.CREATOR, AttributeType.TEXT, domain, "", "", RequirementMode.MANDATORY, "An entity primarily responsible for making the content of the related file. Creator is responsible for the intellectual or creative content of the resource.", true, true));
    domain = new Domain();
    domain.d(DATE_RANGE);
    attributes.add(new AttributeInformation(prefix + NsiliConstants.DATE_TIME_DECLARED, AttributeType.UCOS_ABS_TIME, domain, "", "", RequirementMode.MANDATORY, "Date and time on which the related file was declared, filed or stored (the date the content of the related file was compiled).", true, true));
    domain = new Domain();
    domain.fr(MAX_STANAG_4559_RANGE);
    attributes.add(new AttributeInformation(prefix + NsiliConstants.EXTENT, AttributeType.FLOATING_POINT, domain, "", "", RequirementMode.OPTIONAL, "(Estimated) size of the file, expressed in megabytes. The transfer size is > 0.0.", true, false));
    domain = new Domain();
    domain.t(0);
    attributes.add(new AttributeInformation(prefix + NsiliConstants.FILE_TYPE, AttributeType.TEXT, domain, "", "", RequirementMode.OPTIONAL, "The related file type.", false, false));
    domain = new Domain();
    domain.t(0);
    attributes.add(new AttributeInformation(prefix + NsiliConstants.URL, AttributeType.TEXT, domain, "", "", RequirementMode.OPTIONAL, "An unambiguous reference (in form of an URL) to the related file.", false, false));
    domain = new Domain();
    domain.bv(true);
    attributes.add(new AttributeInformation(prefix + NsiliConstants.IS_FILE_LOCAL, AttributeType.BOOLEAN_DATA, domain, "", "", RequirementMode.OPTIONAL, "Indicates whether the related file is available locally in the library, or resides in a remote library.", true, false));
    return attributes;
}
Also used : AttributeInformation(org.codice.alliance.nsili.common.GIAS.AttributeInformation) ArrayList(java.util.ArrayList) Domain(org.codice.alliance.nsili.common.GIAS.Domain)

Example 25 with AttributeInformation

use of org.codice.alliance.nsili.common.GIAS.AttributeInformation in project alliance by codice.

the class NsiliAttributesGenerator method getNsilCardAttributes.

public static List<AttributeInformation> getNsilCardAttributes() {
    String prefix = NsiliConstants.NSIL_CARD + ".";
    Domain domain;
    List<AttributeInformation> attributes = new ArrayList<>();
    domain = new Domain();
    domain.t(50);
    attributes.add(new AttributeInformation(prefix + NsiliConstants.IDENTIFIER, AttributeType.TEXT, domain, "", "", RequirementMode.OPTIONAL, "Alphanumeric identification code associated with the product. The code must universally uniquely identify the product.", true, false));
    domain = new Domain();
    domain.d(DATE_RANGE);
    attributes.add(new AttributeInformation(prefix + NsiliConstants.SOURCE_DATE_TIME_MODIFIED, AttributeType.UCOS_ABS_TIME, domain, "", "", RequirementMode.OPTIONAL, "The date and time upon which information (cataloguing metadata) about the product was last stored or changed in the source IPL. For any STANAG 4559 Edition 3 server that is not the source of the product, but which have received this product through synchronization, the value of this attribute shall stay unchanged as it is in the source STANAG 4559 server. This then means that the date-time value represent the instant in time when the product was uploaded or changed at the product-source STANAG 4559 Server.", true, false));
    domain = new Domain();
    domain.d(DATE_RANGE);
    attributes.add(new AttributeInformation(prefix + NsiliConstants.DATE_TIME_MODIFIED, AttributeType.UCOS_ABS_TIME, domain, "", "", RequirementMode.OPTIONAL, "The date and time upon which information (cataloguing metadata) about the product was last stored or changed in the local IPL. This attribute is used when synchronizing metadata, to capture when the metadata was synchronized (and not when the metadata was created at the source STANAG 4559 Server). For local products, not received through synchronization, the value of this attribute shall be identical to the value of the 'sourceDateTimeModified' attribute.", true, false));
    domain = new Domain();
    domain.l(getNsilCardStatusOptions());
    attributes.add(new AttributeInformation(prefix + NsiliConstants.STATUS, AttributeType.TEXT, domain, "", "", RequirementMode.OPTIONAL, "The status of the product metadata indicating if the metadata entry is new, has been changed or is marked as obsolete. Note: 1. The Library should remove the URL (productURL) when it sets the status to 'OBSOLETE'. Also the ordering of an obsolete product via OrderMgr should not be allowed. 2. A metadata entry should never be removed. 3. The product can never be modified after it has been posted to a library. The 'CHANGED' status refers to the metadata only.", true, false));
    domain = new Domain();
    domain.ir(NUM_OF_PARTS_RANGE);
    attributes.add(new AttributeInformation(prefix + NsiliConstants.NUM_OF_PARTS, AttributeType.INTEGER, domain, "", "", RequirementMode.OPTIONAL, "A number specifying the number of parts belonging to the product", true, false));
    domain = new Domain();
    domain.t(30);
    attributes.add(new AttributeInformation(prefix + NsiliConstants.PUBLISHER, AttributeType.TEXT, domain, "", "", RequirementMode.OPTIONAL, "The name of the organization responsible for making the resource (product) available in an IPL. By doing so the publisher enables the discovery of that resource by a requestor entity (client). Examples of organizations are 'CJTF', 'LCC', 'ACC' etc.", true, true));
    domain = new Domain();
    domain.t(30);
    attributes.add(new AttributeInformation(prefix + NsiliConstants.SOURCE_LIBRARY, AttributeType.TEXT, domain, "", "", RequirementMode.OPTIONAL, "Alphanumeric identification code of the library in which the product was initially ingested. This identifier is NOT identifying the library the client is currently connected to.", true, false));
    return attributes;
}
Also used : AttributeInformation(org.codice.alliance.nsili.common.GIAS.AttributeInformation) ArrayList(java.util.ArrayList) Domain(org.codice.alliance.nsili.common.GIAS.Domain)

Aggregations

AttributeInformation (org.codice.alliance.nsili.common.GIAS.AttributeInformation)40 ArrayList (java.util.ArrayList)36 Domain (org.codice.alliance.nsili.common.GIAS.Domain)29 IntegerRange (org.codice.alliance.nsili.common.GIAS.IntegerRange)7 HashMap (java.util.HashMap)5 List (java.util.List)5 Matchers.containsString (org.hamcrest.Matchers.containsString)3 Test (org.junit.Test)3 Objects (java.util.Objects)1 Association (org.codice.alliance.nsili.common.GIAS.Association)1 DateRange (org.codice.alliance.nsili.common.GIAS.DateRange)1 FloatingPointRange (org.codice.alliance.nsili.common.GIAS.FloatingPointRange)1 SortAttribute (org.codice.alliance.nsili.common.GIAS.SortAttribute)1 EntityGraph (org.codice.alliance.nsili.common.UCO.EntityGraph)1 EntityNode (org.codice.alliance.nsili.common.UCO.EntityNode)1 InvalidInputParameter (org.codice.alliance.nsili.common.UCO.InvalidInputParameter)1 ProcessingFault (org.codice.alliance.nsili.common.UCO.ProcessingFault)1 SystemFault (org.codice.alliance.nsili.common.UCO.SystemFault)1 Matchers.anyString (org.mockito.Matchers.anyString)1