Search in sources :

Example 1 with AttributeDTO

use of org.geosdi.geoplatform.connector.wfs.response.AttributeDTO in project geo-platform by geosdi.

the class AbstractFeatureStreamWriter method writeFeature.

/**
 * @param request
 * @throws XMLStreamException
 * @throws Exception
 */
private void writeFeature(WFSTransactionRequest request) throws XMLStreamException, Exception {
    QName typeName = request.getTypeName();
    writer().writeStartElement(typeName.getLocalPart());
    List<AttributeDTO> attributes = request.getAttributes();
    for (AttributeDTO attributeDTO : attributes) {
        if (attributeDTO instanceof GeometryAttributeDTO) {
            writeGeometryAttribute((GeometryAttributeDTO) attributeDTO, typeName);
        } else {
            writeAttribute(attributeDTO, typeName);
        }
    }
    writer().writeEndElement();
}
Also used : GeometryAttributeDTO(org.geosdi.geoplatform.connector.wfs.response.GeometryAttributeDTO) AttributeDTO(org.geosdi.geoplatform.connector.wfs.response.AttributeDTO) QName(javax.xml.namespace.QName) GeometryAttributeDTO(org.geosdi.geoplatform.connector.wfs.response.GeometryAttributeDTO)

Example 2 with AttributeDTO

use of org.geosdi.geoplatform.connector.wfs.response.AttributeDTO in project geo-platform by geosdi.

the class FeatureAttributeConditionField method getQueryRestriction.

@Override
public QueryRestrictionDTO getQueryRestriction() {
    QueryRestrictionDTO queryRestriction = null;
    AttributeDetail attributeDetail = this.nameAttributeCombo.getValue();
    String operator = this.operatorCombo.getValue().getValue();
    String restriction = this.conditionAttributeField.getValue();
    if ((attributeDetail != null) && (operator != null) && (this.conditionAttributeField.isValid()) && (restriction != null)) {
        AttributeDTO attributeDTO = FeatureConverter.convert(attributeDetail);
        queryRestriction = new QueryRestrictionDTO(attributeDTO, OperatorType.fromSymbol(operator), restriction);
    }
    return queryRestriction;
}
Also used : AttributeDTO(org.geosdi.geoplatform.connector.wfs.response.AttributeDTO) AttributeDetail(org.geosdi.geoplatform.gui.client.model.wfs.AttributeDetail) QueryRestrictionDTO(org.geosdi.geoplatform.connector.wfs.response.QueryRestrictionDTO)

Example 3 with AttributeDTO

use of org.geosdi.geoplatform.connector.wfs.response.AttributeDTO in project geo-platform by geosdi.

the class FeatureAttributesWidget method prepareColumnModel.

private ColumnModel prepareColumnModel() {
    List<AttributeDTO> attributesDTO = this.layerSchemaBinder.getLayerSchemaDTO().getAttributes();
    List<ColumnConfig> configs = Lists.<ColumnConfig>newArrayListWithCapacity(attributesDTO.size());
    for (final AttributeDTO att : attributesDTO) {
        final GPSecureStringTextField valueTextField = new GPSecureStringTextField();
        valueTextField.setValidator(AttributeCustomFieldsMap.getValidatorForAttributeType(att.getType()));
        valueTextField.setAutoValidate(true);
        if (att.isDateType()) {
            FocusHandler focusHandler = new FocusHandler() {

                @Override
                public void onFocus(FocusEvent event) {
                    dataAttributeName = att.getName();
                    timeInputWidget.show();
                }
            };
            valueTextField.addHandler(focusHandler, FocusEvent.getType());
        }
        ColumnConfig valueColumn = new ColumnConfig();
        String name = att.getName();
        valueColumn.setId(name);
        valueColumn.setHeaderHtml(name);
        valueColumn.setEditor(buildCellEditor(valueTextField));
        valueColumn.setWidth((name.length() + 1) * 10);
        valueColumn.setToolTip("Datatype: " + att.getType());
        configs.add(valueColumn);
    }
    return new ColumnModel(configs);
}
Also used : AttributeDTO(org.geosdi.geoplatform.connector.wfs.response.AttributeDTO) GPSecureStringTextField(org.geosdi.geoplatform.gui.configuration.GPSecureStringTextField) ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) FocusHandler(com.google.gwt.event.dom.client.FocusHandler) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel) FocusEvent(com.google.gwt.event.dom.client.FocusEvent)

Example 4 with AttributeDTO

use of org.geosdi.geoplatform.connector.wfs.response.AttributeDTO in project geo-platform by geosdi.

the class FeatureReaderTest method testFeature.

@Test
public void testFeature() throws Exception {
    FileInputStream ff = null;
    try {
        File dftFile = new File(fileDFT);
        ff = new FileInputStream(dftFile);
        List<LayerSchemaDTO> schemas = featureReaderXSD.read(ff);
        Assert.assertNotNull(schemas);
        Assert.assertEquals(1, schemas.size());
        LayerSchemaDTO layerSchema = schemas.get(0);
        Assert.assertNotNull(layerSchema.getTypeName());
        String name = layerSchema.getTypeName().substring(layerSchema.getTypeName().indexOf(":") + 1);
        Assert.assertNotNull(layerSchema.getTargetNamespace());
        Assert.assertNotNull(layerSchema.getGeometry());
        List<AttributeDTO> attributes = layerSchema.getAttributes();
        Assert.assertNotNull(attributes);
        Assert.assertEquals(numAttributes, attributes.size());
        for (AttributeDTO att : attributes) {
            Assert.assertTrue(att.getMinOccurs() >= 0);
            Assert.assertTrue(att.getMaxOccurs() > att.getMinOccurs());
            Assert.assertNotNull(att.getName());
            Assert.assertNotNull(att.getType());
        }
        logger.debug("@@@@@@@@@@@@@@@@@@@@LAYER_SCHEMA : {}", layerSchema);
        WFSGetFeatureStaxReader featureReader = new WFSGetFeatureStaxReader(layerSchema);
        FeatureCollectionDTO fc = featureReader.read(new File(fileGF));
        Assert.assertNotNull(fc);
        Assert.assertNotNull(fc.getTimeStamp());
        Assert.assertEquals(numFeatures, fc.getNumberOfFeatures());
        List<FeatureDTO> features = fc.getFeatures();
        Assert.assertNotNull(features);
        Assert.assertEquals(numFeatures, features.size());
        for (FeatureDTO feature : features) {
            Assert.assertNotNull(feature.getFID());
            Assert.assertTrue(feature.getFID().contains(name));
            Assert.assertNotNull(feature.getGeometry());
            if (numAttributes == 0) {
                Assert.assertTrue(feature.getAttributes().getAttributesMap().isEmpty());
            } else {
                Assert.assertNotNull(feature.getAttributes());
                Map<String, String> fMap = feature.getAttributes().getAttributesMap();
                Assert.assertNotNull(fMap);
                logger.debug("#################FMAP_SIZE : {}\n", fMap.size());
                Assert.assertEquals(numAttributes, fMap.size());
            }
            logger.debug("@@@@@@@@@@@@@@@@@@@@ {} - {}", feature.getFID(), feature.getAttributes());
            logger.debug("GEOMETRY @@@@@@@@@@@@@@@@ : {}", feature.getGeometry());
        }
    } finally {
        if (ff != null) {
            ff.close();
        }
    }
}
Also used : AttributeDTO(org.geosdi.geoplatform.connector.wfs.response.AttributeDTO) WFSGetFeatureStaxReader(org.geosdi.geoplatform.support.wfs.feature.reader.WFSGetFeatureStaxReader) LayerSchemaDTO(org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO) FeatureDTO(org.geosdi.geoplatform.connector.wfs.response.FeatureDTO) File(java.io.File) FileInputStream(java.io.FileInputStream) FeatureCollectionDTO(org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO) Test(org.junit.Test)

Example 5 with AttributeDTO

use of org.geosdi.geoplatform.connector.wfs.response.AttributeDTO in project geo-platform by geosdi.

the class WFSTransactionUpdateTest method polyLandmarks.

@Test
public void polyLandmarks() throws Exception {
    WFSTransactionRequest<TransactionResponseType> request = super.serverConnector.createTransactionRequest();
    request.setOperation(TransactionOperation.UPDATE);
    QName name = new QName(POLY_LANDMARKS.getLocalPart());
    request.setTypeName(name);
    request.setFID("poly_landmarks.1");
    AttributeDTO att = new AttributeDTO();
    att.setMaxOccurs(1);
    att.setMinOccurs(0);
    att.setName("LANAME");
    att.setNillable(true);
    att.setType("string");
    att.setValue("Washington Square Park.");
    request.setAttributes(Arrays.asList(att));
    // We must avoid transactions on the server,
    // but show only the requests generated
    logger.info("\n\nHERE THE REQUEST ########################## \n {}", request.showRequestAsString());
// TransactionResponseType response = request.getResponse();
// logger.info("\n*** {}", response.getTransactionResults());
// 
// TransactionSummaryType transactionSummary = response.getTransactionSummary();
// Assert.assertEquals(0, transactionSummary.getTotalDeleted().intValue());
// Assert.assertEquals(0, transactionSummary.getTotalInserted().intValue());
// Assert.assertEquals(1, transactionSummary.getTotalUpdated().intValue());
// Assert.assertEquals("1.1.0", response.getVersion());
// HERE THE CODE TO TEST THE TRANSACTION RESULT WITH A SPECIFIC GET_FEATURE
// WFSGetFeatureRequest<FeatureCollectionType> requestGet =
// super.serverConnector.createGetFeatureRequest();
// 
// requestGet.setResultType(ResultTypeType.RESULTS.value());
// requestGet.setTypeName(POLY_LANDMARKS);
// 
// requestGet.setFeatureIDs(Arrays.asList("poly_landmarks.1"));
// 
// logger.info("\n\n\nRESPONSE @@@@@@@@@@@@@@@@@@@@@@@@@@@@@ {}",
// requestGet.getResponseAsString());
}
Also used : GeometryAttributeDTO(org.geosdi.geoplatform.connector.wfs.response.GeometryAttributeDTO) AttributeDTO(org.geosdi.geoplatform.connector.wfs.response.AttributeDTO) QName(javax.xml.namespace.QName) TransactionResponseType(org.geosdi.geoplatform.xml.wfs.v110.TransactionResponseType) Test(org.junit.Test)

Aggregations

AttributeDTO (org.geosdi.geoplatform.connector.wfs.response.AttributeDTO)28 Test (org.junit.Test)18 GeometryAttributeDTO (org.geosdi.geoplatform.connector.wfs.response.GeometryAttributeDTO)14 QName (javax.xml.namespace.QName)12 LayerSchemaDTO (org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO)7 QueryRestrictionDTO (org.geosdi.geoplatform.connector.wfs.response.QueryRestrictionDTO)7 QueryDTO (org.geosdi.geoplatform.connector.wfs.response.QueryDTO)6 FeatureCollectionType (org.geosdi.geoplatform.xml.wfs.v110.FeatureCollectionType)6 TransactionResponseType (org.geosdi.geoplatform.xml.wfs.v110.TransactionResponseType)6 StringWriter (java.io.StringWriter)3 Writer (java.io.Writer)3 List (java.util.List)3 Collectors.toList (java.util.stream.Collectors.toList)3 WFSTransactionRequestV110 (org.geosdi.geoplatform.connector.server.request.v110.WFSTransactionRequestV110)3 FeatureStreamWriter (org.geosdi.geoplatform.connector.server.request.v110.transaction.stax.FeatureStreamWriter)3 FeatureCollectionDTO (org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO)3 ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)2 ColumnModel (com.extjs.gxt.ui.client.widget.grid.ColumnModel)2 FeatureDTO (org.geosdi.geoplatform.connector.wfs.response.FeatureDTO)2 WFSGetFeatureStaxReader (org.geosdi.geoplatform.support.wfs.feature.reader.WFSGetFeatureStaxReader)2