Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[udig-devel] Change Attributes and geometry

  Hi, uDig developers,

     congratulations for the last release 1.0.0.

I’m developing one external plugin to edit geometry and attributes value at the same time. The source data is Esri Shapefile. I’m doing the follow action:

  1. Add a layer to a Map (shapefile).
  2. Active my plugin to change data.
  3. Select a point on the map.
  4. Search the feature close point.
  5. Show a dialog to change attributes data.

 

When I confirm the changes, I’m using the method FeatureStore.modifyFeatures  as follow:

 

public boolean updateHouseNumber(HouseNumberVO houseNumber) {

                        FeatureType fType = fSourcehouseNumber.getSchema();

                        FilterFactory fFilter = FilterFactory.createFilterFactory();

                        try {

                                   CompareFilter cFilter = fFilter.createCompareFilter(CompareFilter.COMPARE_EQUALS);

                                   cFilter.addLeftValue(fFilter.createAttributeExpression(fType, "COD_UTE"));

                                   cFilter.addRightValue(fFilter.createLiteralExpression(houseNumber.getCodice_Utente()));

                                  

                                   System.out.println("updateHouseNumber -> '" + houseNumber.getCodice_Utente() + "' ** NUMERO:" + houseNumber.getNumero() +

                                              " SUBALT:" + houseNumber.getSubalterno() +

                                              " ESPON:" + houseNumber.getEsponente());

                                  

                                   AttributeType[] myAtt = new AttributeType[3];

                                   myAtt[0] = fType.getAttributeType("NUMERO");

                                   myAtt[1] = fType.getAttributeType("SUBALT");

                                   myAtt[2] = fType.getAttributeType("ESPON");

                                  

                                   Object[] myVal = new Object[3];

                                   myVal[0] = houseNumber.getNumero();

                                   myVal[1] = houseNumber.getSubalterno();

                                   myVal[2] = houseNumber.getEsponente();

                                  

                                   FeatureStore fs;

                                   fs = (FeatureStore)(fSourcehouseNumber);

                                  

                                   System.out.println("Modifico");

                                  

                                   Transaction myt = fs.getTransaction();

                                  

                                   fs.modifyFeatures(myAtt, myVal, cFilter);

                                  

                                   myt.commit();

                                   myt.close();

                                  

                                   System.out.println("Terminato");

           

                        }

                        catch (Exception e)

                        {

                                   System.out.println(e.toString());

                                   return false;

                        }

                       

                        return true;

            }

 

the code work quite well, but when I accomplish that doesn’t work correctly… and I must terminate UDig debug session by Windows task manager…

 

Thanks,

 

Davide.

 

 

 


Back to the top