Search in sources :

Example 6 with ValueListType

use of net.opengis.cat.wrs.v_1_0_2.ValueListType in project ddf by codice.

the class FederationAdmin method updateDateFields.

private void updateDateFields(RegistryPackageType rpt) {
    ExtrinsicObjectType nodeInfo = null;
    for (JAXBElement identifiable : rpt.getRegistryObjectList().getIdentifiable()) {
        RegistryObjectType registryObject = (RegistryObjectType) identifiable.getValue();
        if (registryObject instanceof ExtrinsicObjectType && RegistryConstants.REGISTRY_NODE_OBJECT_TYPE.equals(registryObject.getObjectType())) {
            nodeInfo = (ExtrinsicObjectType) registryObject;
            break;
        }
    }
    if (nodeInfo != null) {
        boolean liveDateFound = false;
        boolean lastUpdatedFound = false;
        OffsetDateTime now = OffsetDateTime.now(ZoneId.of(ZoneOffset.UTC.toString()));
        String rightNow = now.toString();
        for (SlotType1 slot : nodeInfo.getSlot()) {
            if (slot.getName().equals(RegistryConstants.XML_LIVE_DATE_NAME)) {
                liveDateFound = true;
            } else if (slot.getName().equals(RegistryConstants.XML_LAST_UPDATED_NAME)) {
                ValueListType valueList = EbrimConstants.RIM_FACTORY.createValueListType();
                valueList.getValue().add(rightNow);
                slot.setValueList(EbrimConstants.RIM_FACTORY.createValueList(valueList));
                lastUpdatedFound = true;
            }
        }
        if (!liveDateFound) {
            SlotType1 liveDate = slotHelper.create(RegistryConstants.XML_LIVE_DATE_NAME, rightNow, DATE_TIME);
            nodeInfo.getSlot().add(liveDate);
        }
        if (!lastUpdatedFound) {
            SlotType1 lastUpdated = slotHelper.create(RegistryConstants.XML_LAST_UPDATED_NAME, rightNow, DATE_TIME);
            nodeInfo.getSlot().add(lastUpdated);
        }
    }
}
Also used : SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1) OffsetDateTime(java.time.OffsetDateTime) ValueListType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ValueListType) ExtrinsicObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) JAXBElement(javax.xml.bind.JAXBElement) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)

Example 7 with ValueListType

use of net.opengis.cat.wrs.v_1_0_2.ValueListType in project ddf by codice.

the class SlotWebConverter method getSlotGeoMap.

private Map<String, Object> getSlotGeoMap(SlotType1 slot) {
    Map<String, Object> map = new HashMap<>();
    if (!slot.isSetValueList()) {
        return map;
    }
    ValueListType valueList = (ValueListType) slot.getValueList().getValue();
    for (AnyValueType anyValue : valueList.getAnyValue()) {
        anyValue.getContent().stream().filter(content -> content instanceof JAXBElement).forEach(content -> {
            JAXBElement jaxbElement = (JAXBElement) content;
            if (jaxbElement.getValue() instanceof PointType) {
                Map<String, Object> pointMap = getPointMapFromPointType((PointType) jaxbElement.getValue());
                if (MapUtils.isNotEmpty(pointMap)) {
                    Map<String, Object> valueMap = new HashMap<>();
                    valueMap.put(POINT_KEY, pointMap);
                    map.put(VALUE, valueMap);
                }
            }
        });
    }
    return map;
}
Also used : DirectPositionType(net.opengis.gml.v_3_1_1.DirectPositionType) StringUtils(org.apache.commons.lang.StringUtils) WebMapHelper(org.codice.ddf.registry.schemabindings.helper.WebMapHelper) MapUtils(org.apache.commons.collections.MapUtils) AnyValueType(net.opengis.cat.wrs.v_1_0_2.AnyValueType) JAXBElement(javax.xml.bind.JAXBElement) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) EnvelopeType(net.opengis.gml.v_3_1_1.EnvelopeType) ArrayList(java.util.ArrayList) List(java.util.List) SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1) Map(java.util.Map) ValueListType(net.opengis.cat.wrs.v_1_0_2.ValueListType) PointType(net.opengis.gml.v_3_1_1.PointType) SlotTypeHelper(org.codice.ddf.registry.schemabindings.helper.SlotTypeHelper) RegistryConstants(org.codice.ddf.registry.common.RegistryConstants) HashMap(java.util.HashMap) ValueListType(net.opengis.cat.wrs.v_1_0_2.ValueListType) PointType(net.opengis.gml.v_3_1_1.PointType) AnyValueType(net.opengis.cat.wrs.v_1_0_2.AnyValueType) JAXBElement(javax.xml.bind.JAXBElement)

Example 8 with ValueListType

use of net.opengis.cat.wrs.v_1_0_2.ValueListType in project ddf by codice.

the class SlotTypeConverter method getWrsValueList.

private Optional<net.opengis.cat.wrs.v_1_0_2.ValueListType> getWrsValueList(Map<String, Object> map) {
    Optional<net.opengis.cat.wrs.v_1_0_2.ValueListType> optionalValueList = Optional.empty();
    if (MapUtils.isEmpty(map) || !map.containsKey(VALUE)) {
        return optionalValueList;
    }
    Map<String, Object> valueMap = (Map<String, Object>) map.get(VALUE);
    if (valueMap.containsKey(POINT_KEY)) {
        Optional<PointType> optionalPoint = getPoint((Map<String, Object>) valueMap.get(POINT_KEY));
        if (optionalPoint.isPresent()) {
            AnyValueType anyValue = WRS_FACTORY.createAnyValueType();
            anyValue.getContent().add(GML_FACTORY.createPoint(optionalPoint.get()));
            net.opengis.cat.wrs.v_1_0_2.ValueListType valueList = WRS_FACTORY.createValueListType();
            valueList.getAnyValue().add(anyValue);
            if (!optionalValueList.isPresent()) {
                optionalValueList = Optional.of(WRS_FACTORY.createValueListType());
            }
            optionalValueList.get().getAnyValue().add(anyValue);
        }
    } else if (valueMap.containsKey(ENVELOPE_KEY)) {
        Optional<EnvelopeType> optionalEnvelope = getEnvelope((Map<String, Object>) valueMap.get(ENVELOPE_KEY));
        if (optionalEnvelope.isPresent()) {
            AnyValueType anyValue = WRS_FACTORY.createAnyValueType();
            anyValue.getContent().add(GML_FACTORY.createEnvelope(optionalEnvelope.get()));
            net.opengis.cat.wrs.v_1_0_2.ValueListType valueList = WRS_FACTORY.createValueListType();
            valueList.getAnyValue().add(anyValue);
            if (!optionalValueList.isPresent()) {
                optionalValueList = Optional.of(WRS_FACTORY.createValueListType());
            }
            optionalValueList.get().getAnyValue().add(anyValue);
        }
    }
    return optionalValueList;
}
Also used : Optional(java.util.Optional) ValueListType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ValueListType) PointType(net.opengis.gml.v_3_1_1.PointType) AnyValueType(net.opengis.cat.wrs.v_1_0_2.AnyValueType) Map(java.util.Map)

Example 9 with ValueListType

use of net.opengis.cat.wrs.v_1_0_2.ValueListType in project ddf by codice.

the class SlotTypeHelper method create.

/**
     * This is a convenience method to create a SlotType1 object with the List of values
     *
     * @param slotName   the name of the slot, empty SlotType1 if null
     * @param slotValues the value to set
     * @param slotType   the slot type of the slot
     * @return
     */
public SlotType1 create(String slotName, List<String> slotValues, String slotType) {
    SlotType1 slot = RIM_FACTORY.createSlotType1();
    if (StringUtils.isNotBlank(slotName)) {
        ValueListType valueList = RIM_FACTORY.createValueListType();
        valueList.getValue().addAll(slotValues);
        slot.setValueList(RIM_FACTORY.createValueList(valueList));
        slot.setSlotType(slotType);
        slot.setName(slotName);
    }
    return slot;
}
Also used : SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1) ValueListType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ValueListType)

Example 10 with ValueListType

use of net.opengis.cat.wrs.v_1_0_2.ValueListType in project ddf by codice.

the class SlotWebConverter method getSlotBoundsMap.

private Map<String, Object> getSlotBoundsMap(SlotType1 slot) {
    Map<String, Object> map = new HashMap<>();
    if (!slot.isSetValueList()) {
        return map;
    }
    ValueListType valueList = (ValueListType) slot.getValueList().getValue();
    for (AnyValueType anyValue : valueList.getAnyValue()) {
        anyValue.getContent().stream().filter(content -> content instanceof JAXBElement).forEach(content -> {
            JAXBElement jaxbElement = (JAXBElement) content;
            if (jaxbElement.getValue() instanceof EnvelopeType) {
                Map<String, Object> boundsMap = getBoundsMapFromEnvelopeType((EnvelopeType) jaxbElement.getValue());
                if (MapUtils.isNotEmpty(boundsMap)) {
                    Map<String, Object> valueMap = new HashMap<>();
                    valueMap.put(ENVELOPE_KEY, boundsMap);
                    map.put(VALUE, valueMap);
                }
            }
        });
    }
    return map;
}
Also used : DirectPositionType(net.opengis.gml.v_3_1_1.DirectPositionType) StringUtils(org.apache.commons.lang.StringUtils) WebMapHelper(org.codice.ddf.registry.schemabindings.helper.WebMapHelper) MapUtils(org.apache.commons.collections.MapUtils) AnyValueType(net.opengis.cat.wrs.v_1_0_2.AnyValueType) JAXBElement(javax.xml.bind.JAXBElement) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) EnvelopeType(net.opengis.gml.v_3_1_1.EnvelopeType) ArrayList(java.util.ArrayList) List(java.util.List) SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1) Map(java.util.Map) ValueListType(net.opengis.cat.wrs.v_1_0_2.ValueListType) PointType(net.opengis.gml.v_3_1_1.PointType) SlotTypeHelper(org.codice.ddf.registry.schemabindings.helper.SlotTypeHelper) RegistryConstants(org.codice.ddf.registry.common.RegistryConstants) EnvelopeType(net.opengis.gml.v_3_1_1.EnvelopeType) HashMap(java.util.HashMap) ValueListType(net.opengis.cat.wrs.v_1_0_2.ValueListType) AnyValueType(net.opengis.cat.wrs.v_1_0_2.AnyValueType) JAXBElement(javax.xml.bind.JAXBElement)

Aggregations

SlotType1 (oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1)8 ValueListType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ValueListType)6 AnyValueType (net.opengis.cat.wrs.v_1_0_2.AnyValueType)5 JAXBElement (javax.xml.bind.JAXBElement)4 PointType (net.opengis.gml.v_3_1_1.PointType)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 ValueListType (net.opengis.cat.wrs.v_1_0_2.ValueListType)3 DirectPositionType (net.opengis.gml.v_3_1_1.DirectPositionType)3 EnvelopeType (net.opengis.gml.v_3_1_1.EnvelopeType)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 ExtrinsicObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType)2 MapUtils (org.apache.commons.collections.MapUtils)2 StringUtils (org.apache.commons.lang.StringUtils)2 RegistryConstants (org.codice.ddf.registry.common.RegistryConstants)2 SlotTypeHelper (org.codice.ddf.registry.schemabindings.helper.SlotTypeHelper)2 WebMapHelper (org.codice.ddf.registry.schemabindings.helper.WebMapHelper)2 OffsetDateTime (java.time.OffsetDateTime)1