There are also some methods in DataUtilities to sort out default values for 
you (based on the information contained in the feature type). But yeah it is 
really tough; for mandatory parameters you need a real value from your user 
before you can insert something. 

-- 
Jody Garnett


On Thursday, 29 September 2011 at 2:38 PM, rBartel wrote:

> I'm trying to create something that will insert a new row into a table. The
> table is quite large, and at the moment, we keep changing the columns, as
> it's still in development stages (sort of). So, I'm just passing the values
> I want in the new row to another class. That class fills in the blanks with
> either a blank string, or if the column has a default value, it uses that.
> 
> However, I have two problems. 1) None of the default values are being found,
> even though the column names are. 2) When I commit the new row, I get this:
> 
> WARNING: javax.naming.OperationNotSupportedException: java.lang.String
> java.io.IOException: An error occured while committing.
>  at
> org.geotools.data.wfs.v1_0_0.WFSTransactionState.commit(WFSTransactionState.java:177)
>  at
> org.geotools.data.DefaultTransaction.commit(DefaultTransaction.java:182)
>  at
> com.terrapages.geoserver_wfst_db.DatabaseInterface.insertRow(DatabaseInterface.java:565)
>  at
> com.terrapages.geoserver_wfst_db.servlet.InsertNewPoiServlet.doPost(InsertNewPoiServlet.java:204)
>  at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
>  at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>  at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>  at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>  at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>  at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>  at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>  at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>  at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>  at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
>  at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
>  at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
>  at
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
>  at java.lang.Thread.run(Thread.java:619)
> 
> I believe the two errors are connected, because I have used the exact same
> insert code before just fine. It makes me think it's the values I'm sending
> to the insert code. It seems likely that solving the default values problem
> first will solve the second problem. Here's what I'm doing to get the column
> names and default values:
> 
> WFS_1_0_0_DataStore wfs = (WFS_1_0_0_DataStore)getCapabilities(true,
> baseGeoserverUrl);
> if(wfs == null){
>  //Code that complains at the logs and returns. Irrelevant for this problem.
> }
> List<AttributeDescriptor> fields = null;
> try{
>  SimpleFeatureType schema = wfs.getSchema(tableName);
>  fields = schema.getAttributeDescriptors();
> }catch(IOException e){
>  e.printStackTrace();
> }
> return fields
> 
> Where tableName is a String, not a Name.
> This certainly returns AttributeDescriptors, because I can get the column
> names from them. But when I ask for the default values, I always get null.
> 
> if(attr.getDefaultValue() == null){
>  entries.add("");
> }else{
>  entries.add(attr.getDefaultValue().toString());
> }
> 
> Where entries is an ArrayList<String>, and attr is the current
> AttributeDescriptor.
> 
> The database is pgadmin, if that makes any difference.
> 
> Any ideas what I'm doing wrong?
> 
> --
> View this message in context: 
> http://osgeo-org.1803224.n2.nabble.com/Using-the-default-values-in-a-new-row-tp6842711p6842711.html
> Sent from the geotools-gt2-users mailing list archive at Nabble.com 
> (http://Nabble.com).
> 
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2dcopy1
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected] 
> (mailto:[email protected])
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to