Insert KingOracle Provider

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Insert KingOracle Provider

mdelsinne
Hello,

I connect to an Oracle database with the provider "OSGeo.KingOracle.3.6" I wish I could create objects such as lines or polygons. For that I must use the "Insert", I have managed to use this command to create files sdf3 but I can not write in the database. I would like to know the steps, I have not found any documents to help me. Is it necessary to create a shema, a feature class, a datastore?

For now I can create a table but when I insert an error (enable to find class definition)

thank you
Reply | Threaded
Open this post in threaded view
|

Re: Insert KingOracle Provider

mdelsinne
This post was updated on .
I created a table MYFDOCLASS by following the instructions provided by OSGeo:
http://sl-king.com/fdooracle/KingFdoClass.htm. I do not understand what it is!?
The code below creates a table in oracle which will be named "CLASSTEST" but there is always a problem with the insert command!

IConnectionManager connManager = FeatureAccessManager.GetConnectionManager();
IConnection conn = connManager.CreateConnection("OSGeo.KingOracle.3.6");
IConnectionPropertyDictionary connProperties = conn.ConnectionInfo.ConnectionProperties;

connProperties.SetProperty("Username", "FDO");
connProperties.SetProperty("Password", "FDO");
connProperties.SetProperty("Service", "BASETEST");
connProperties.SetProperty("OracleSchema", "");
connProperties.SetProperty("KingFdoClass", "MYFDOCLASS");
conn.Open();

IApplySchema cmdApplySchema = conn.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_ApplySchema) as IApplySchema;
FeatureSchema aFeatureSchema = new FeatureSchema("FDO", "");
FeatureClass aFeatureClass = new FeatureClass("CLASSTEST", "");

// Add a id property
DataPropertyDefinition idProp = new DataPropertyDefinition("ID", "");
idProp.DataType = DataType.DataType_Int32;
idProp.IsAutoGenerated = true;
idProp.Nullable = false;
aFeatureClass.Properties.Add(idProp);
aFeatureClass.IdentityProperties.Add(idProp);
idProp.Dispose();

// Add a key property
DataPropertyDefinition keyProp = new DataPropertyDefinition("Key", "");
keyProp.DataType = DataType.DataType_String;
keyProp.Length = 255;
aFeatureClass.Properties.Add(keyProp);
keyProp.Dispose();

// Add a name property
DataPropertyDefinition nameProp = new DataPropertyDefinition("Name", "");
nameProp.DataType = DataType.DataType_String;
nameProp.Length = 255;
aFeatureClass.Properties.Add(nameProp);
nameProp.Dispose();

// Add a url property
DataPropertyDefinition urlProp = new DataPropertyDefinition("URL", "");
urlProp.DataType = DataType.DataType_String;
urlProp.Length = 255;
aFeatureClass.Properties.Add(urlProp);
urlProp.Dispose();

// Add a geometry property
GeometricPropertyDefinition geomProp = new GeometricPropertyDefinition("Geom", "");
geomProp.GeometryTypes = (int)GeometryType.GeometryType_MultiGeometry;
aFeatureClass.Properties.Add(geomProp);
aFeatureClass.GeometryProperty = geomProp;
geomProp.Dispose();

IInsert cmdInsert = conn.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_Insert) as IInsert;
cmdInsert.SetFeatureClassName(aFeatureClass.Name);
cmdInsert.PropertyValues.Clear();

// ID Value
Int32Value id = new Int32Value(idSdfObject);
cmdInsert.PropertyValues.Add(new PropertyValue("ID", id));
// Key Value
StringValue key = new StringValue(mySdfObject.Key.ToString());
cmdInsert.PropertyValues.Add(new PropertyValue("Key", key));
// Name Value
StringValue nameValue = new StringValue(mySdfObject.Name.ToString());
cmdInsert.PropertyValues.Add(new PropertyValue("Name", nameValue));
// URL Value
StringValue urlValue = new StringValue(mySdfObject.Url.ToString());
cmdInsert.PropertyValues.Add(new PropertyValue("URL", urlValue));
// Geometrie Value
GeometryValue geomValue = new GeometryValue(getGeom(mySdfObject, sdf2File));
cmdInsert.PropertyValues.Add(new PropertyValue("Geom", geomValue));

IReader cmdRead = cmdInsert.Execute();  -> Unable to find class definition!

Thank you for your help
Reply | Threaded
Open this post in threaded view
|

Re: Insert KingOracle Provider

Jackie Ng
Do you see this feature class when looking at the Oracle Data Store through FDO Toolbox (http://fdotoolbox.googlecode.com)?

If you can't see it, you can't insert data into it, meaning something was probably misconfigured when setting up that class definition.

- Jackie
Reply | Threaded
Open this post in threaded view
|

Re: Insert KingOracle Provider

mdelsinne
Yes I see my class "TestClass" via fdotoolbox
Reply | Threaded
Open this post in threaded view
|

Re: Insert KingOracle Provider

mdelsinne
But what he has to have a class similar to the "MYFDOCLASS"?
Reply | Threaded
Open this post in threaded view
|

Re: Insert KingOracle Provider

mdelsinne
This post was updated on .
I don't understand, it works well with fdotoolbox, I can insert entities etc ...
Reply | Threaded
Open this post in threaded view
|

Re: Insert KingOracle Provider

mdelsinne
I still have the same problem, I tried everything but I can not find the solution, yet well I get to connect and insert an entity via fdotoolbox but using c # api, impossible, I still have the same message error: Unable to find class definition! So here I block .

IConnection conn = connectFDO("OSGeo.KingOracle.3.6");
IConnectionPropertyDictionary connProperties = conn.ConnectionInfo.ConnectionProperties;
OSGeo.FDO.Connections.ConnectionState connState = conn.ConnectionState;

connProperties.SetProperty("Username", "FDO");
connProperties.SetProperty("Password", "FDO");
connProperties.SetProperty("Service", "BASETEST");
connProperties.SetProperty("OracleSchema", "FDO");
connProperties.SetProperty("KingFdoClass", "MYFDOCLASS");
connState = conn.Open();

IApplySchema cmdApplySchema = conn.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_ApplySchema) as IApplySchema;
FeatureSchema aFeatureSchema = new FeatureSchema("KingOra", "");
FeatureClass aFeatureClass = new FeatureClass("CLASSTEST", "");

// Add a id property
DataPropertyDefinition idProp = new DataPropertyDefinition("ID", "");
idProp.DataType = DataType.DataType_Int32;
idProp.IsAutoGenerated = true;
idProp.Nullable = false;
aFeatureClass.Properties.Add(idProp);
aFeatureClass.IdentityProperties.Add(idProp);

// Add a key property
DataPropertyDefinition keyProp = new DataPropertyDefinition("Key", "");
keyProp.DataType = DataType.DataType_String;
keyProp.Length = 255;
aFeatureClass.Properties.Add(keyProp);

// Add a name property
DataPropertyDefinition nameProp = new DataPropertyDefinition("Name", "");
nameProp.DataType = DataType.DataType_String;
nameProp.Length = 255;
aFeatureClass.Properties.Add(nameProp);

// Add a url property
DataPropertyDefinition urlProp = new DataPropertyDefinition("URL", "");
urlProp.DataType = DataType.DataType_String;
urlProp.Length = 255;
aFeatureClass.Properties.Add(urlProp);

// Add a geometry property
GeometricPropertyDefinition geomProp = new GeometricPropertyDefinition("Geom", "");
geomProp.GeometryTypes = (int)GeometryType.GeometryType_MultiGeometry;
aFeatureClass.Properties.Add(geomProp);
aFeatureClass.GeometryProperty = geomProp;

aFeatureSchema.Classes.Add(aFeatureClass);

IApplySchema applySchema = (IApplySchema)connect.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_ApplySchema);
applySchema.FeatureSchema = schema;
applySchema.Execute();

IInsert cmdInsert = conn.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_Insert) as IInsert;
cmdInsert.SetFeatureClassName(aFeatureClass.Name);
cmdInsert.PropertyValues.Clear();

// ID Value
Int32Value id = new Int32Value(idSdfObject);
cmdInsert.PropertyValues.Add(new PropertyValue("ID", id));
// Key Value
StringValue key = new StringValue(mySdfObject.Key.ToString());
cmdInsert.PropertyValues.Add(new PropertyValue("Key", key));
// Name Value
StringValue nameValue = new StringValue(mySdfObject.Name.ToString());
cmdInsert.PropertyValues.Add(new PropertyValue("Name", nameValue));
// URL Value
StringValue urlValue = new StringValue(mySdfObject.Url.ToString());
cmdInsert.PropertyValues.Add(new PropertyValue("URL", urlValue));
// Geometrie Value
GeometryValue geomValue = new GeometryValue(getGeom(mySdfObject, sdf2File));
cmdInsert.PropertyValues.Add(new PropertyValue("Geom", geomValue));

IReader cmdRead = cmdInsert.Execute();
cmdRead.Close();

Unable to find class definition!
Reply | Threaded
Open this post in threaded view
|

Re: Insert KingOracle Provider

Jackie Ng
Are you applying schema every time?

Because that is basically equivalent to creating the same database table over and over again.

Secondly you said you could see "TestClass" in FDO Toolbox, but you're inserting into a feature class called "CLASSTEST"

- Jackie
Reply | Threaded
Open this post in threaded view
|

Re: Insert KingOracle Provider

mdelsinne
This post was updated on .
sorry, yes: I see CLASSTEST in fdotoolbox, table created with the C # api (my program). But once I apply the schema, it creates the table in oracle with good properties definitions as I indicated in my program.

But I still have the same problem, Unable to find class definition, I try, I try different settings but it makes no difference :(.

I'll let you know

thank you Jackie
Reply | Threaded
Open this post in threaded view
|

Re: Insert KingOracle Provider

zspitzer
the schema definition is cached, you just need to flush the cache

On Tue, Nov 15, 2011 at 9:23 PM, mdelsinne <[hidden email]> wrote:

> sorry, yes I meant: I see in CLASSTEST fdotoolbox table created with the C #
> api. But not once I apply the schema, it creates the new table in good
> oracle properties with definitions as I indicated in my program.
>
> But I still have the same problem, Unable to find class definition, I try, I
> try different settings but it makes no difference: (.
>
> thank you Jackie
>
> --
> View this message in context: http://osgeo-org.1803224.n2.nabble.com/Insert-KingOracle-Provider-tp6992058p6995754.html
> Sent from the FDO Users mailing list archive at Nabble.com.
> _______________________________________________
> fdo-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/fdo-users
>



--
Zac Spitzer
Solution Architect / Director
Ennoble Consultancy Australia
http://www.ennoble.com.au
http://zacster.blogspot.com
+61 405 847 168
_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users
Reply | Threaded
Open this post in threaded view
|

Re: Insert KingOracle Provider

mdelsinne
the schema definition is cached !? what is the cache must be emptied
Reply | Threaded
Open this post in threaded view
|

Re: Insert KingOracle Provider

mdelsinne
Thank you but I clear the cache of oracle, but this does not change ...

I used the command:
ALTER SYSTEM FLUSH BUFFER_CACHE;
Reply | Threaded
Open this post in threaded view
|

Re: Insert KingOracle Provider

Jackie Ng
In reply to this post by mdelsinne
Replace this line:

cmdInsert.SetFeatureClassName(aFeatureClass.Name);

With this:

cmdInsert.SetFeatureClassName("CLASSTEST");

- Jackie
Reply | Threaded
Open this post in threaded view
|

Re: Insert KingOracle Provider

mdelsinne
it does not work...
Reply | Threaded
Open this post in threaded view
|

Re: Insert KingOracle Provider

mdelsinne
for sure? there is no need to create a datastore
Reply | Threaded
Open this post in threaded view
|

Re: Insert KingOracle Provider

mdelsinne
This post was updated on .
I found!

must define the name of the feature class like this: OracleSchema~FeatureClassName~GeometryProperty.

For my example it gives:
IInsert cmdInsert conn.CreateCommand = (OSGeo.FDO.Commands.CommandType.CommandType_Insert) as IInsert;
cmdInsert.SetFeatureClassName ("FDO~CLASSTEST~GEOM");


Thank's for the assistance !
Reply | Threaded
Open this post in threaded view
|

Re: Insert KingOracle Provider

Jackie Ng
Ah yes. That crazy feature class naming convention. Just note that this naming convention only needs to be used for the KingOracle provider.

- Jackie