Package org.geotools.data

Examples of org.geotools.data.Diff


     *
     * @param state ContentState for the transaction
     */
    public DiffTransactionState(ContentState state) {
        this.state = state;
        this.diff = new Diff();
    }
View Full Code Here


        //
        ReferencedEnvelope bounds;
        if(!canTransact() && transaction != null && transaction != Transaction.AUTO_COMMIT) {
            // grab the in memory transaction diff
            DiffTransactionState state = (DiffTransactionState) getTransaction().getState(getEntry());
            Diff diff = state.getDiff();
           
            // don't compute the bounds of the features that are modified or removed in the diff
            Iterator it = diff.getModified().values().iterator();
            FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
            Set<FeatureId> modifiedFids = new HashSet<FeatureId>();
            while(it.hasNext()){
                SimpleFeature feature = (SimpleFeature) it.next();
                modifiedFids.add(ff.featureId(feature.getID()));
            }
            Id idFilter = ff.id(modifiedFids);
            Query q = new Query(query);
            q.setFilter(ff.and(idFilter, query.getFilter()));
            bounds = getBoundsInternal(q);
           
            // update with the diff contents, all added feature and all modified, not deleted ones
            if(bounds != null) {
                // new ones
                it = diff.getAdded().values().iterator();
                while(it.hasNext()){
                    SimpleFeature feature = (SimpleFeature) it.next();
                    BoundingBox fb = feature.getBounds();
                    if(fb != null) {
                        bounds.expandToInclude(ReferencedEnvelope.reference(fb));
                    }
                }
               
                // modified ones
                it = diff.getModified().values().iterator();
                while(it.hasNext()){
                    SimpleFeature feature = (SimpleFeature) it.next();
                    if(feature != TransactionStateDiff.NULL) {
                        BoundingBox fb = feature.getBounds();
                        if(fb != null) {
View Full Code Here

        int count = getCountInternal( query );

        // if the internal actually counted, consider transactions
        if(count >= 0 && !canTransact() && transaction != null && transaction != Transaction.AUTO_COMMIT) {
            DiffTransactionState state = (DiffTransactionState) getTransaction().getState(getEntry());
            Diff diff = state.getDiff();
            synchronized (diff) {
                // consider newly added features that satisfy the filter
                Iterator it = diff.getAdded().values().iterator();
                Filter filter = query.getFilter();
                while(it.hasNext()){
                    Object feature = it.next();
                    if(filter.evaluate(feature)) {
                        count++;
                    }
                       
                }
               
                // consider removed features that satisfy the filter
                it = diff.getModified().values().iterator();
                FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
                Set<FeatureId> modifiedFids = new HashSet<FeatureId>();
                int modifiedPostCount = 0;
                while(it.hasNext()){
                    SimpleFeature feature = (SimpleFeature) it.next();
View Full Code Here

        WFSStrategy strategy = getStrategy();

        final Filter serverFiler = ((AbstractWFSStrategy) strategy).splitFilters(typeName,
                request.getFilter())[0];

        final Diff diff = diff(typeName);

        for (Iterator<SimpleFeature> it = originalFeatures.iterator(); it.hasNext();) {
            if (!serverFiler.evaluate(it.next())) {
                it.remove();
            }
View Full Code Here

        int deleted = 0, updated = 0;

        for (TransactionElement e : request.getTransactionElements()) {
            QName typeName = e.getTypeName();
            if (e instanceof Insert) {
                Diff diff = diff(typeName);
                for (SimpleFeature f : ((Insert) e).getFeatures()) {
                    //String newId = "wfs-generated-" + idseq.incrementAndGet();
                    diff.add(f.getID(), f);
                    added.add(f.getID());
                }
            }
            if (e instanceof Delete) {
                Diff diff = diff(typeName);
                Filter filter = ((Delete) e).getFilter();
                List<SimpleFeature> features = features(typeName);
                for (SimpleFeature f : features) {
                    if (filter.evaluate(f)) {
                        diff.remove(f.getID());
                        deleted++;
                    }
                }
            }
            if (e instanceof Update) {
                Diff diff = diff(typeName);
                Update u = (Update) e;
                Filter filter = u.getFilter();
                List<SimpleFeature> features = features(typeName);
                List<QName> propertyNames = u.getPropertyNames();
                List<Object> newValues = u.getNewValues();

                for (SimpleFeature f : features) {
                    if (!filter.evaluate(f)) {
                        continue;
                    }
                    for (int i = 0; i < propertyNames.size(); i++) {
                        QName propName = propertyNames.get(i);
                        Object value = newValues.get(i);
                        String attName = propName.getLocalPart();
                        f.setAttribute(attName, value);
                    }
                    diff.modify(f.getID(), f);
                    updated++;
                }
            }

        }
View Full Code Here

       
        return request.createResponse(httpResponse);
    }

    private Diff diff(QName typeName) {
        Diff diff = diffs.get(typeName);
        if (diff == null) {
            diff = new Diff();
            diffs.put(typeName, diff);
        }
        return diff;
    }
View Full Code Here

TOP

Related Classes of org.geotools.data.Diff

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.