com.esri.adf.web.ags.data.edit.util
Class EditUtil

java.lang.Object
  extended by com.esri.adf.web.ags.data.edit.util.EditUtil

public class EditUtil
extends Object

A helper class for ArcObject related functions.


Field Summary
static String NOT_VERSIONED
           
 
Constructor Summary
EditUtil()
           
 
Method Summary
static com.esri.arcgis.geometry.IGeometry addVertex(double searchDistance, com.esri.arcgis.geometry.IGeometry geom, com.esri.arcgis.geometry.IPoint point, com.esri.arcgis.server.IServerContext ctx)
          Adds a vertex the geometry if it is in the search distance.
static com.esri.arcgis.geodatabase.IFeature copyFeature(com.esri.arcgis.carto.IFeatureLayer targetLayer, com.esri.arcgis.geometry.ILine offset, com.esri.arcgis.geodatabase.IFeature source)
          Copies the feature to the target layer and move it with the given offset.
static com.esri.arcgis.geodatabase.IFeature createFeature(com.esri.arcgis.carto.IFeatureLayer editLayer, com.esri.arcgis.geometry.IGeometry geom)
          Creates a geometry to a feature layer.
static Map<Integer,Attribute> getAttributes(com.esri.arcgis.carto.IFeatureLayer fLayer, com.esri.arcgis.geodatabase.IFeature feature, AttributeFilter filter, DateFormat dateFormat)
          Gets all the editable attributes on the feature.
static Map<Integer,Attribute> getAttributes(com.esri.arcgis.carto.IFeatureLayer fLayer, com.esri.arcgis.geodatabase.IFeature feature, AttributeFilter filter, DateFormat dateFormat, LayerDefinition layerDef)
          Gets all the editable attributes on the feature.
static Map<Integer,com.esri.arcgis.carto.IFeatureLayer> getFeatureLayers(com.esri.arcgis.carto.IMap map, com.esri.arcgis.server.IServerContext ctx)
          Gets all feature layers from the IMap.
static com.esri.arcgis.geodatabase.IFeatureCursor getFeatures(com.esri.arcgis.carto.IFeatureLayer editLayer, int[] oids, com.esri.arcgis.server.IServerContext ctx)
          Gets the features by the given object IDs.
static com.esri.arcgis.geodatabase.IFeatureCursor getSelection(com.esri.arcgis.carto.IFeatureLayer editLayer, com.esri.arcgisws.LayerDescription ldesc, com.esri.arcgis.geometry.IGeometry geometry, com.esri.arcgis.server.IServerContext ctx)
          Deprecated. As of ArcGIS Java Server 10.0, no replacement.
static com.esri.arcgis.geodatabase.IFeatureCursor getSelection(com.esri.arcgis.carto.IFeatureLayer editLayer, com.esri.arcgisws.LayerDescription ldesc, com.esri.arcgis.server.IServerContext ctx)
          Gets the selected feature on the given layer.
static com.esri.arcgis.geometry.ISpatialReference getSpatialReference(com.esri.arcgis.carto.IFeatureLayer flayer)
          Gets spatial reference from a feature layer.
static List<String> getVersions(com.esri.arcgis.carto.IMap map, String wsID, com.esri.arcgis.server.IServerContext ctx)
          Retrieves versions from a map's feature layers.
static String getWorkspaceID(com.esri.arcgis.carto.IFeatureLayer layer)
          Creates key that uniquely distinguishes workspace connection and feature-class registration.
static com.esri.arcgis.geodatabase.IFeature moveFeature(com.esri.arcgis.geometry.ILine offset, com.esri.arcgis.geodatabase.IFeature source)
          Moves the feature with the given offset.
static com.esri.arcgis.geometry.IGeometry moveVertex(double searchDistance, com.esri.arcgis.geometry.IGeometry geom, com.esri.arcgis.geometry.ILine line, com.esri.arcgis.server.IServerContext ctx)
          Moves a vertex from the start point to the end point of the line.
static com.esri.arcgis.geometry.IGeometry removeVertex(double searchDistance, com.esri.arcgis.geometry.IGeometry geom, com.esri.arcgis.geometry.IPoint point, com.esri.arcgis.server.IServerContext ctx)
          Removes a vertex the geometry if it is in the search distance.
static com.esri.arcgis.geodatabase.IFeatureCursor search(com.esri.arcgis.geometry.IEnvelope extent, com.esri.arcgis.carto.IFeatureLayer layer, com.esri.arcgis.server.IServerContext ctx)
          Gets all features on the layer within the given bounds.
static com.esri.arcgis.geodatabase.IFeature simplifyGeometry(com.esri.arcgis.geodatabase.IFeature feature, com.esri.arcgis.geometry.IGeometry geom)
          Simplifies the geometry.
static List<com.esri.arcgis.geodatabase.IFeature> splitLineFeature(com.esri.arcgis.geodatabase.IFeature feature, com.esri.arcgis.geometry.IPoint pt, double searchDistance, com.esri.arcgis.server.IServerContext ctx)
          Splits a line feature to two.
static List<com.esri.arcgis.geodatabase.IFeature> splitPolygonFeature(com.esri.arcgis.geodatabase.IFeature feature, com.esri.arcgis.geometry.IPolyline polyline)
          Splits a polygon feature to two.
static double toDistance(int pixels, com.esri.arcgis.geometry.IEnvelope bounds, int imageWidth, com.esri.arcgis.geometry.ISpatialReference refTo)
          Converts the screen pixels to map distance in the spatial reference's unit.
static com.esri.arcgis.geometry.IEnvelope toEnvelope(double minx, double miny, double maxx, double maxy, com.esri.arcgis.geometry.ISpatialReference ref, com.esri.arcgis.server.IServerContext ctx)
          Converts the WebExtent to an Envelope.
static com.esri.arcgis.geometry.ILine toILine(double x1, double y1, double x2, double y2, com.esri.arcgis.geometry.ISpatialReference ref, com.esri.arcgis.server.IServerContext ctx)
          Creates a ILine from 2 points.
static com.esri.arcgis.geometry.ILine toLine(double x1, double y1, double x2, double y2, com.esri.arcgis.geometry.ISpatialReference ref, com.esri.arcgis.server.IServerContext ctx)
          Creates a ILine from 2 points.
static com.esri.arcgis.geometry.IPoint toPoint(double x, double y, com.esri.arcgis.geometry.ISpatialReference ref, com.esri.arcgis.server.IServerContext ctx)
          Creates a IPoint from x,y.
static com.esri.arcgis.geometry.ILine transformLine(com.esri.arcgis.geometry.ILine geom, com.esri.arcgis.geometry.ISpatialReference newSpatialReference)
          Re-projects the ILine geometry to the given spatial reference.
static com.esri.arcgis.geodatabase.IFeature updateAttribute(com.esri.arcgis.geodatabase.IFeature feature, Attribute att, DateFormat dateFormat)
          Deprecated. As of ArcGIS Java Server 10.0, no replacement.
static com.esri.arcgis.geodatabase.IFeature updateAttribute(com.esri.arcgis.carto.IFeatureLayer layer, com.esri.arcgis.geodatabase.IFeature feature, Attribute att, DateFormat format)
          Updates an attribute value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOT_VERSIONED

public static final String NOT_VERSIONED
See Also:
Constant Field Values
Constructor Detail

EditUtil

public EditUtil()
Method Detail

copyFeature

public static com.esri.arcgis.geodatabase.IFeature copyFeature(com.esri.arcgis.carto.IFeatureLayer targetLayer,
                                                               com.esri.arcgis.geometry.ILine offset,
                                                               com.esri.arcgis.geodatabase.IFeature source)
                                                        throws IOException,
                                                               com.esri.arcgis.interop.AutomationException
Copies the feature to the target layer and move it with the given offset. The new feature will not be stored by default, you need to store it explicitly.
 IFeature fNew = EditorUtil.copyFeature(workspace.getLayer(), offset, feature);
 fNew.store();
 

Parameters:
targetLayer - the layer to copy to.
offset - the offset of the feature position. Set to null for no offset.
source - the feature to copy.
Returns:
the reference of the new Feature.
Throws:
IOException - If there are interop problems.
com.esri.arcgis.interop.AutomationException - If the ArcObject component throws an exception.

moveFeature

public static com.esri.arcgis.geodatabase.IFeature moveFeature(com.esri.arcgis.geometry.ILine offset,
                                                               com.esri.arcgis.geodatabase.IFeature source)
                                                        throws IOException,
                                                               com.esri.arcgis.interop.AutomationException
Moves the feature with the given offset. The new feature will not be stored by default, you need to store it explicitly.
 IFeature fNew = EditorUtil.copyFeature(workspace.getLayer(), offset, feature);
 fNew.store();
 

Parameters:
offset - the offset of the feature position. Set to null for no offset.
source - the feature to copy.
Returns:
the reference of the new Feature.
Throws:
IOException - If there are interop problems.
com.esri.arcgis.interop.AutomationException - If the ArcObject component throws an exception.

createFeature

public static com.esri.arcgis.geodatabase.IFeature createFeature(com.esri.arcgis.carto.IFeatureLayer editLayer,
                                                                 com.esri.arcgis.geometry.IGeometry geom)
                                                          throws Exception
Creates a geometry to a feature layer. The feature will not be stored be default.

Parameters:
editLayer - a feature layer
geom - geometry
Returns:
the feature or null if not succeed..
Throws:
Exception

getSelection

public static com.esri.arcgis.geodatabase.IFeatureCursor getSelection(com.esri.arcgis.carto.IFeatureLayer editLayer,
                                                                      com.esri.arcgisws.LayerDescription ldesc,
                                                                      com.esri.arcgis.server.IServerContext ctx)
                                                               throws Exception
Gets the selected feature on the given layer.

Parameters:
editLayer - the layer to search.
Returns:
the feature cursor.
Throws:
IOException
com.esri.arcgis.interop.AutomationException
Exception

getFeatures

public static com.esri.arcgis.geodatabase.IFeatureCursor getFeatures(com.esri.arcgis.carto.IFeatureLayer editLayer,
                                                                     int[] oids,
                                                                     com.esri.arcgis.server.IServerContext ctx)
                                                              throws Exception
Gets the features by the given object IDs.

Parameters:
editLayer - the layer to search.
Returns:
the feature cursor.
Throws:
Exception

getWorkspaceID

public static String getWorkspaceID(com.esri.arcgis.carto.IFeatureLayer layer)
Creates key that uniquely distinguishes workspace connection and feature-class registration.

Parameters:
layer - target feature layer.
Returns:
the workspace ID

getFeatureLayers

public static Map<Integer,com.esri.arcgis.carto.IFeatureLayer> getFeatureLayers(com.esri.arcgis.carto.IMap map,
                                                                                com.esri.arcgis.server.IServerContext ctx)
                                                                         throws Exception
Gets all feature layers from the IMap.

Parameters:
map - the IMap instance.
ctx - server context
Returns:
the index and feature layer pairs in a Map.
Throws:
Exception

toEnvelope

public static com.esri.arcgis.geometry.IEnvelope toEnvelope(double minx,
                                                            double miny,
                                                            double maxx,
                                                            double maxy,
                                                            com.esri.arcgis.geometry.ISpatialReference ref,
                                                            com.esri.arcgis.server.IServerContext ctx)
                                                     throws Exception
Converts the WebExtent to an Envelope.

Parameters:
ctx - set to null to use ArcObject.
Throws:
Exception

toPoint

public static com.esri.arcgis.geometry.IPoint toPoint(double x,
                                                      double y,
                                                      com.esri.arcgis.geometry.ISpatialReference ref,
                                                      com.esri.arcgis.server.IServerContext ctx)
                                               throws Exception
Creates a IPoint from x,y.

Parameters:
ctx - set to null to use ArcObject.
Throws:
Exception

toLine

public static com.esri.arcgis.geometry.ILine toLine(double x1,
                                                    double y1,
                                                    double x2,
                                                    double y2,
                                                    com.esri.arcgis.geometry.ISpatialReference ref,
                                                    com.esri.arcgis.server.IServerContext ctx)
                                             throws Exception
Creates a ILine from 2 points.

Parameters:
ctx - set to null to use ArcObject.
Throws:
Exception

search

public static com.esri.arcgis.geodatabase.IFeatureCursor search(com.esri.arcgis.geometry.IEnvelope extent,
                                                                com.esri.arcgis.carto.IFeatureLayer layer,
                                                                com.esri.arcgis.server.IServerContext ctx)
                                                         throws Exception
Gets all features on the layer within the given bounds.

Parameters:
extent - the search bounds
layer - the layer to search
ctx - server context
Returns:
the cursor.
Throws:
Exception

toILine

public static com.esri.arcgis.geometry.ILine toILine(double x1,
                                                     double y1,
                                                     double x2,
                                                     double y2,
                                                     com.esri.arcgis.geometry.ISpatialReference ref,
                                                     com.esri.arcgis.server.IServerContext ctx)
                                              throws Exception
Creates a ILine from 2 points.

Throws:
Exception

getAttributes

public static Map<Integer,Attribute> getAttributes(com.esri.arcgis.carto.IFeatureLayer fLayer,
                                                   com.esri.arcgis.geodatabase.IFeature feature,
                                                   AttributeFilter filter,
                                                   DateFormat dateFormat)
                                            throws Exception
Gets all the editable attributes on the feature.

Parameters:
fLayer - the layer from which the feature retrieved.
feature - the feature from which the attributes retrieved.
filter - to control how to display attributes.
dateFormat - to format date type attribute. Set to null to use the default date and time format.
Returns:
the index and attribute pairs.
Throws:
Exception

getAttributes

public static Map<Integer,Attribute> getAttributes(com.esri.arcgis.carto.IFeatureLayer fLayer,
                                                   com.esri.arcgis.geodatabase.IFeature feature,
                                                   AttributeFilter filter,
                                                   DateFormat dateFormat,
                                                   LayerDefinition layerDef)
                                            throws Exception
Gets all the editable attributes on the feature. This method honors the field alias settings in LayerDefinition.

Parameters:
fLayer - the layer from which the feature retrieved.
feature - the feature from which the attributes retrieved.
filter - to control how to display attributes.
dateFormat - to format date type attribute. Set to null to use the default date and time format.
layerDef - the layerDefinition defined in faces-config.xml
Returns:
the index and attribute pairs.
Throws:
Exception

updateAttribute

public static com.esri.arcgis.geodatabase.IFeature updateAttribute(com.esri.arcgis.geodatabase.IFeature feature,
                                                                   Attribute att,
                                                                   DateFormat dateFormat)
                                                            throws Exception
Deprecated. As of ArcGIS Java Server 10.0, no replacement.

Updates an attribute value. The feature will not be store.

Parameters:
feature - the feature to update
att - the changed attribute.
dateFormat - the parse the date string. Set to null to use the default date and time format.
Returns:
the updated feature
Throws:
Exception

updateAttribute

public static com.esri.arcgis.geodatabase.IFeature updateAttribute(com.esri.arcgis.carto.IFeatureLayer layer,
                                                                   com.esri.arcgis.geodatabase.IFeature feature,
                                                                   Attribute att,
                                                                   DateFormat format)
                                                            throws Exception
Updates an attribute value. The feature will not be store. If the attribute is a sub-type field, all the related domains will be changed based on the configuration.

Parameters:
layer - the layer of the feature.
feature - the feature to update
att - the changed attribute.
format - the parse the date string. Set to null to use the default date and time format.
Returns:
the updated feature
Throws:
Exception

addVertex

public static com.esri.arcgis.geometry.IGeometry addVertex(double searchDistance,
                                                           com.esri.arcgis.geometry.IGeometry geom,
                                                           com.esri.arcgis.geometry.IPoint point,
                                                           com.esri.arcgis.server.IServerContext ctx)
                                                    throws Exception
Adds a vertex the geometry if it is in the search distance.

Parameters:
searchDistance - the search distance in unit of geometry spatial reference.
geom - the geom to hit.
point - the vertex point
Returns:
return the new geometry or null if no geometry hit.
Throws:
Exception

getSpatialReference

public static com.esri.arcgis.geometry.ISpatialReference getSpatialReference(com.esri.arcgis.carto.IFeatureLayer flayer)
                                                                      throws IOException,
                                                                             com.esri.arcgis.interop.AutomationException
Gets spatial reference from a feature layer.

Parameters:
flayer - the layer
Throws:
IOException
com.esri.arcgis.interop.AutomationException

toDistance

public static double toDistance(int pixels,
                                com.esri.arcgis.geometry.IEnvelope bounds,
                                int imageWidth,
                                com.esri.arcgis.geometry.ISpatialReference refTo)
                         throws IOException,
                                com.esri.arcgis.interop.AutomationException
Converts the screen pixels to map distance in the spatial reference's unit.

Parameters:
pixels - the pixel value.
bounds - the map bounds.
imageWidth - the map width in pixels.
refTo - the spatial reference of the target layer or map.
Returns:
the distance in the spatial reference's unit.
Throws:
IOException - If there are interop problems.
com.esri.arcgis.interop.AutomationException - If the ArcObject component throws an exception.

moveVertex

public static com.esri.arcgis.geometry.IGeometry moveVertex(double searchDistance,
                                                            com.esri.arcgis.geometry.IGeometry geom,
                                                            com.esri.arcgis.geometry.ILine line,
                                                            com.esri.arcgis.server.IServerContext ctx)
                                                     throws Exception
Moves a vertex from the start point to the end point of the line.

Parameters:
searchDistance - the search distance in geometry's unit.
geom - the target geometry
line - the line to move along with.
Returns:
the new geometry or null if none geometry in the search distance.
Throws:
Exception

simplifyGeometry

public static com.esri.arcgis.geodatabase.IFeature simplifyGeometry(com.esri.arcgis.geodatabase.IFeature feature,
                                                                    com.esri.arcgis.geometry.IGeometry geom)
                                                             throws Exception
Simplifies the geometry.

Parameters:
feature - the feature to set
geom - the geometry to simplify
Returns:
the feature with the simplified geometry.
Throws:
Exception

removeVertex

public static com.esri.arcgis.geometry.IGeometry removeVertex(double searchDistance,
                                                              com.esri.arcgis.geometry.IGeometry geom,
                                                              com.esri.arcgis.geometry.IPoint point,
                                                              com.esri.arcgis.server.IServerContext ctx)
                                                       throws Exception
Removes a vertex the geometry if it is in the search distance.

Parameters:
searchDistance - the search distance in unit of geometry spatial reference.
geom - the geom to hit.
point - the vertex point
Returns:
return the new geometry or null if no geometry hit.
Throws:
Exception

splitLineFeature

public static List<com.esri.arcgis.geodatabase.IFeature> splitLineFeature(com.esri.arcgis.geodatabase.IFeature feature,
                                                                          com.esri.arcgis.geometry.IPoint pt,
                                                                          double searchDistance,
                                                                          com.esri.arcgis.server.IServerContext ctx)
                                                                   throws Exception
Splits a line feature to two.

Parameters:
feature - the feature to split
pt - the split point
searchDistance - the search tolerance.
Returns:
the split result.
Throws:
Exception

splitPolygonFeature

public static List<com.esri.arcgis.geodatabase.IFeature> splitPolygonFeature(com.esri.arcgis.geodatabase.IFeature feature,
                                                                             com.esri.arcgis.geometry.IPolyline polyline)
                                                                      throws Exception
Splits a polygon feature to two.

Parameters:
feature - the feature to split
polyline - the split line.
Returns:
the split result.
Throws:
Exception

getSelection

public static com.esri.arcgis.geodatabase.IFeatureCursor getSelection(com.esri.arcgis.carto.IFeatureLayer editLayer,
                                                                      com.esri.arcgisws.LayerDescription ldesc,
                                                                      com.esri.arcgis.geometry.IGeometry geometry,
                                                                      com.esri.arcgis.server.IServerContext ctx)
                                                               throws Exception
Deprecated. As of ArcGIS Java Server 10.0, no replacement.

Gets the selected feature on the given layer intersected with the given geometry

Parameters:
editLayer - the layer to search.
Returns:
the feature cursor.
Throws:
IOException
com.esri.arcgis.interop.AutomationException
Exception

getVersions

public static List<String> getVersions(com.esri.arcgis.carto.IMap map,
                                       String wsID,
                                       com.esri.arcgis.server.IServerContext ctx)
                                throws Exception
Retrieves versions from a map's feature layers.

Parameters:
map - the source map.
wsID - the optional workspace id.
Returns:
the version name list. If the return list is empty, the map has no versioned layers. If the return list is not empty, and some layers are non-versioned layers, the non-version will be returned as a empty String "".
Throws:
Exception

transformLine

public static com.esri.arcgis.geometry.ILine transformLine(com.esri.arcgis.geometry.ILine geom,
                                                           com.esri.arcgis.geometry.ISpatialReference newSpatialReference)
                                                    throws Exception
Re-projects the ILine geometry to the given spatial reference.

Parameters:
geom - the ILine geometry to transform
newSpatialReference - the spatial reference to transform.
Throws:
Exception