Tim; This is something we've seen before.  The overall issue is that the D2RQ wizard in TBC will read the entire schema when creating the mapping.  But not everything in the relational model can be mapped correctly.  It's also common that only a few table mappings are needed for the mapping.

This overall issue will be addressed in a revamped D2RQ wizard that allows the user to choose the table mappings you want.  This will be available in a beta release in the next few weeks.

In the meantime, there are a couple of ways you can remove unwanted mappings.  One is to edit the -mapping file.  It's in RDF and you can open it directly in Composer.  The class and property mappings are found in the subclasses of d2rq:ResourceMap.  Classes correspond to tables and are mapped via the d2rq:class property of a d2rq:ClassMap instance.  Property maps are instances of d2rq:PropertyBridge and mapped to the relational table through the d2rq:column (for columns) or d2rq:join (for foreign key relationships).  To see the effects of an edit, save your changes and close/open the DataView file.

Another way to do this is to use the attached service.  Copy the file into your workspace and run Scripts > Refresh/Display SPARQLMotion functions... Once that is done, the menu choice 'Resource > Get mappings for table column' will appear.  The script takes a previous mapping (specifically the schema and mapping files) and converts to a new set of mappings, retaining the old one.  This way you can create a mapping with a dump of the entire schema then build multiple mappings based on that.

To fill in the wizard, you need the base URI for the mapping and schema files from a previously executed D2RQ wizard.  Specify the new URIs for the four files generated by the D2RQ wizard and the names of the tables you want to include in the mapping.  The four files are created and you can view the data in Composer using the file generated for the Target Database.

Give those a try and let us know if that addresses the problems you are having. 

-- Scott

On 1/9/12 3:22 PM, Tim Smith wrote:
Hi,

This may be more of D2RQ issue that TBC so I apologize in advance if that is the case.

I've managed to connect to my database, create the mapping files, delete the references to Blobs and indices, etc...

I can open the DataView file and see instances in the Instance view for the various classes.  However, when I try to view the instances, a D2RQ exception is thrown that essentially displays an Oracle SQL error.

In short, the query generated by D2RQ is not valid:

 de.fuberlin.wiwiss.d2rq.D2RQException: ORA-01722: invalid number
: SELECT 1 FROM "ATTRIBUTE" WHERE "ATTRIBUTE"."ATTRIBUTE_ID" = '_TYPE10' (E0)

Of course this query will always return a value of "1" so I do not know what D2RQ is attempting to do.  Regardless, this query is invalid since Attribute.Attribute_ID is a number column - not a character.  The schema file correctly indicates a range of xsd:decimal for this column.

Has anyone seen this type of behavior from D2RQ before?

Thanks,

Tim

--
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include TopBraid Composer,
TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en

--
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include TopBraid Composer,
TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en
# Saved by TopBraid on Wed Jan 11 09:35:44 CST 2012
# baseURI: http://d2rq.tq.com/ChooseTableMappings
# imports: http://topbraid.org/sparqlmotionfunctions
# imports: http://topbraid.org/sparqlmotionlib

@prefix :        <http://d2rq.tq.com/ChooseTableMappings#> .
@prefix afn:     <http://jena.hpl.hp.com/ARQ/function#> .
@prefix d2rq:    <http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1#> .
@prefix dc:      <http://purl.org/dc/elements/1.1/> .
@prefix dcam:    <http://purl.org/dc/dcam/> .
@prefix dcterms:  <http://purl.org/dc/terms/> .
@prefix dtype:   <http://www.w3.org/2001/XMLSchema#> .
@prefix fn:      <http://www.w3.org/2005/xpath-functions#> .
@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix jdbc:    <http://d2rq.org/terms/jdbc/> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos:    <http://www.w3.org/2004/02/skos/core#> .
@prefix sm:      <http://topbraid.org/sparqlmotion#> .
@prefix smf:     <http://topbraid.org/sparqlmotionfunctions#> .
@prefix sml:     <http://topbraid.org/sparqlmotionlib#> .
@prefix sp:      <http://spinrdf.org/sp#> .
@prefix spin:    <http://spinrdf.org/spin#> .
@prefix spl:     <http://spinrdf.org/spl#> .
@prefix vcard:   <http://www.w3.org/2001/vcard-rdf/3.0#> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .

<http://d2rq.tq.com/ChooseTableMappings>
      rdf:type owl:Ontology ;
      owl:imports <http://topbraid.org/sparqlmotionlib> , 
<http://topbraid.org/sparqlmotionfunctions> ;
      owl:versionInfo "Created with TopBraid Composer"^^xsd:string .

:BindVariables
      rdf:type sml:BindBySelect ;
      rdfs:label "Bind variables"^^xsd:string ;
      sm:next :CreateMappingFile ;
      sm:nodeX 384 ;
      sm:nodeY 327 ;
      sml:selectQuery
              [ rdf:type sp:Select ;
                sp:resultVariables (_:b1 _:b2) ;
                sp:where ([ rdf:type sp:Let ;
                            sp:expression
                                    [ rdf:type fn:concat ;
                                      sp:arg1 [ rdf:type smf:subString ;
                                                sp:arg1 _:b3 ;
                                                sp:arg2 [ rdf:type sp:add ;
                                                          sp:arg1 [ rdf:type 
smf:lastIndexOf ;
                                                                    sp:arg1 
_:b3 ;
                                                                    sp:arg2 "/"
                                                                  ] ;
                                                          sp:arg2 1
                                                        ]
                                              ] ;
                                      sp:arg2 ".rdf"
                                    ] ;
                            sp:variable _:b1
                          ] [ rdf:type sp:Let ;
                            sp:expression
                                    [ rdf:type afn:now
                                    ] ;
                            sp:variable _:b2
                          ])
              ] .

:ConstructMappings
      rdf:type sml:ApplyConstruct ;
      rdfs:label "Construct mappings"^^xsd:string ;
      sm:nodeX 551 ;
      sm:nodeY 102 ;
      sml:constructQuery
              [ rdf:type sp:Construct ;
                sp:templates ([ sp:object _:b4 ;
                            sp:predicate _:b5 ;
                            sp:subject _:b6
                          ] [ sp:object _:b7 ;
                            sp:predicate _:b8 ;
                            sp:subject _:b9
                          ]) ;
                sp:where ([ sp:object
                                    [ sp:varName "clsUri"^^xsd:string
                                    ] ;
                            sp:predicate d2rq:belongsToClassMap ;
                            sp:subject _:b6
                          ] [ sp:object _:b4 ;
                            sp:predicate _:b5 ;
                            sp:subject _:b6
                          ] [ rdf:type sp:Optional ;
                            sp:elements ([ sp:object _:b9 ;
                                        sp:predicate d2rq:refersToClassMap ;
                                        sp:subject _:b6
                                      ] [ sp:object _:b7 ;
                                        sp:predicate _:b8 ;
                                        sp:subject _:b9
                                      ])
                          ])
              ] ;
      sml:constructQuery
              [ rdf:type sp:Construct ;
                sp:templates ([ sp:object _:b10 ;
                            sp:predicate _:b11 ;
                            sp:subject _:b12
                          ] [ sp:object 
<http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1> ;
                            sp:predicate owl:imports ;
                            sp:subject _:b13
                          ]) ;
                sp:where ([ sp:object d2rq:Database ;
                            sp:predicate rdf:type ;
                            sp:subject _:b12
                          ] [ sp:object _:b10 ;
                            sp:predicate _:b11 ;
                            sp:subject _:b12
                          ] [ rdf:type sp:Let ;
                            sp:expression
                                    [ rdf:type smf:buildURI ;
                                      sp:arg1 [ sp:varName 
"targetMapURI"^^xsd:string
                                              ]
                                    ] ;
                            sp:variable _:b13
                          ])
              ] ;
      sml:constructQuery
              [ rdf:type sp:Construct ;
                sp:templates ([ sp:object _:b14 ;
                            sp:predicate _:b15 ;
                            sp:subject _:b16
                          ]) ;
                sp:where ([ sp:object _:b14 ;
                            sp:predicate _:b15 ;
                            sp:subject _:b16
                          ])
              ] ;
      sml:replace "true"^^xsd:boolean .

:ConstructSchemaFile
      rdf:type sml:ApplyConstruct ;
      rdfs:label "Construct schema file"^^xsd:string ;
      sm:next :CreateSchemaFile ;
      sm:nodeX 690 ;
      sm:nodeY 397 ;
      sml:constructQuery
              [ rdf:type sp:Construct ;
                sp:templates ([ sp:object _:b17 ;
                            sp:predicate _:b18 ;
                            sp:subject _:b19
                          ] [ sp:object owl:Thing ;
                            sp:predicate rdfs:subClassOf ;
                            sp:subject _:b19
                          ] [ sp:object _:b20 ;
                            sp:predicate _:b21 ;
                            sp:subject _:b22
                          ]) ;
                sp:where ([ sp:object d2rq:ClassMap ;
                            sp:predicate rdf:type ;
                            sp:subject _:b23
                          ] [ sp:object _:b19 ;
                            sp:predicate d2rq:class ;
                            sp:subject _:b23
                          ] [ sp:object _:b17 ;
                            sp:predicate _:b18 ;
                            sp:subject _:b19
                          ] [ sp:object d2rq:PropertyBridge ;
                            sp:predicate rdf:type ;
                            sp:subject _:b24
                          ] [ sp:object _:b22 ;
                            sp:predicate d2rq:property ;
                            sp:subject _:b24
                          ] [ sp:object _:b20 ;
                            sp:predicate _:b21 ;
                            sp:subject _:b22
                          ])
              ] ;
      sml:replace "true"^^xsd:boolean .

:CreateD2RQ_File
      rdf:type sml:ExportToTextFile ;
      rdfs:label "Create d2RQ File"^^xsd:string ;
      sm:next :ReturnMessage ;
      sm:nodeX 337 ;
      sm:nodeY 654 ;
      sml:replace "true"^^xsd:boolean ;
      sml:targetFilePath
              [ rdf:type fn:concat ;
                sp:arg1 [ sp:varName "zdbConnName"^^xsd:string
                        ] ;
                sp:arg2 ".d2rq"
              ] ;
      sml:text """#D2RQ Properties file needed by TopBraid Composer as a 
placeholder for the virtual database
#{?time}
MappingFile={?mapfilename}
BaseURI={?targetDbURI}
DriverClassName=com.mysql.jdbc.Driver"""^^xsd:string .

:CreateDataFile
      rdf:type sml:ExportToRDFFile ;
      rdfs:label "Create data file"^^xsd:string ;
      sm:next :CreateD2RQ_File ;
      sm:nodeX 215 ;
      sm:nodeY 765 ;
      sml:baseURI "{?dbFileUri}"^^xsd:string ;
      sml:targetFilePath
              [ rdf:type fn:concat ;
                sp:arg1 [ rdf:type smf:subString ;
                          sp:arg1 _:b25 ;
                          sp:arg2 [ rdf:type sp:add ;
                                    sp:arg1 [ rdf:type smf:lastIndexOf ;
                                              sp:arg1 _:b25 ;
                                              sp:arg2 "/"
                                            ] ;
                                    sp:arg2 1
                                  ]
                        ] ;
                sp:arg2 ".ttl"
              ] .

:CreateDataImportStmts
      rdf:type sml:ApplyConstruct ;
      rdfs:label "Create data import stmts"^^xsd:string ;
      sm:next :CreateDataFile ;
      sm:nodeX 41 ;
      sm:nodeY 594 ;
      sml:constructQuery
              [ rdf:type sp:Construct ;
                sp:templates ([ sp:object _:b26 ;
                            sp:predicate owl:imports ;
                            sp:subject _:b27
                          ] [ sp:object _:b28 ;
                            sp:predicate owl:imports ;
                            sp:subject _:b27
                          ]) ;
                sp:where ([ rdf:type sp:Let ;
                            sp:expression
                                    [ rdf:type smf:buildURI ;
                                      sp:arg1 [ sp:varName 
"dbFileUri"^^xsd:string
                                              ]
                                    ] ;
                            sp:variable _:b27
                          ] [ rdf:type sp:Let ;
                            sp:expression
                                    [ rdf:type smf:buildURI ;
                                      sp:arg1 [ sp:varName 
"targetDbURI"^^xsd:string
                                              ]
                                    ] ;
                            sp:variable _:b26
                          ] [ rdf:type sp:Let ;
                            sp:expression
                                    [ rdf:type smf:buildURI ;
                                      sp:arg1 [ sp:varName 
"targetSchemaURI"^^xsd:string
                                              ]
                                    ] ;
                            sp:variable _:b28
                          ])
              ] .

:CreateMappingFile
      rdf:type sml:ExportToRDFFile ;
      rdfs:label "Create mapping file"^^xsd:string ;
      sm:next :CreateD2RQ_File ;
      sm:nodeX 364 ;
      sm:nodeY 470 ;
      sml:baseURI "{?targetMapURI}"^^xsd:string ;
      sml:targetFilePath "{?mapfilename}"^^xsd:string .

:CreateSchemaFile
      rdf:type sml:ExportToRDFFile ;
      rdfs:label "Create schema file"^^xsd:string ;
      sm:next :ReturnMessage ;
      sm:nodeX 713 ;
      sm:nodeY 599 ;
      sml:baseURI "{?targetSchemaURI}"^^xsd:string ;
      sml:targetFilePath
              [ rdf:type fn:concat ;
                sp:arg1 [ rdf:type smf:subString ;
                          sp:arg1 _:b29 ;
                          sp:arg2 [ rdf:type sp:add ;
                                    sp:arg1 [ rdf:type smf:lastIndexOf ;
                                              sp:arg1 _:b29 ;
                                              sp:arg2 "/"
                                            ] ;
                                    sp:arg2 1
                                  ]
                        ] ;
                sp:arg2 ".ttl"
              ] .

:GetDatabaseFileURI
      rdf:type sml:BindLiteralVariable ;
      rdfs:label "Get database file URI"^^xsd:string ;
      sm:next :CreateDataImportStmts ;
      sm:nodeX 35 ;
      sm:nodeY 724 ;
      sm:outputVariable "dbFileUri"^^xsd:string ;
      sml:datatype xsd:string ;
      sml:template
              [ rdf:type fn:concat ;
                sp:arg1 [ sp:varName "targetDbURI"^^xsd:string
                        ] ;
                sp:arg2 "-db"
              ] .

:GetMappingsForTableColumn
      rdf:type spin:Function ;
      rdfs:label "Get mappings for table column"^^xsd:string ;
      rdfs:subClassOf spin:Functions ;
      spin:constraint
              [ rdf:type spl:Argument ;
                rdfs:comment "Target Database (Instances) Base URI"^^xsd:string 
;
                spl:defaultValue 
"http://support.tq.com.com/testFinalDataView"^^xsd:string ;
                spl:predicate sp:targetDbURI ;
                spl:valueType xsd:string ;
                sm:next :GetDatabaseFileURI ;
                sm:nodeX 34 ;
                sm:nodeY 863
              ] ;
      spin:constraint
              [ rdf:type sml:SelectedResourceArgument ;
                spl:predicate sml:selectedResource
              ] ;
      spin:constraint
              [ rdf:type spl:Argument ;
                rdfs:comment "Target Schema Base URI"^^xsd:string ;
                spl:defaultValue 
"http://support.tq.com.com/testFinalSchema"^^xsd:string ;
                spl:predicate sp:targetSchemaURI ;
                spl:valueType xsd:string ;
                sm:next :CreateDataImportStmts , :CreateSchemaFile ;
                sm:nodeX 40 ;
                sm:nodeY 451
              ] ;
      spin:constraint
              [ rdf:type spl:Argument ;
                rdfs:comment "Name of tables to be converted (comma-delimited 
list)"^^xsd:string ;
                spl:defaultValue "movies2.person, movies2.movie"^^xsd:string ;
                spl:predicate sp:atableNames ;
                spl:valueType xsd:string ;
                sm:next :IterateOverTableNames ;
                sm:nodeX 8 ;
                sm:nodeY 131
              ] ;
      spin:constraint
              [ rdf:type spl:Argument ;
                rdfs:comment "Name of D2RQ Connector File"^^xsd:string ;
                spl:defaultValue "dbConnector"^^xsd:string ;
                spl:predicate sp:zdbConnName ;
                spl:valueType xsd:string ;
                sm:next :CreateD2RQ_File ;
                sm:nodeX 390 ;
                sm:nodeY 847
              ] ;
      spin:constraint
              [ rdf:type spl:Argument ;
                rdfs:comment "Source Schema Base URI"^^xsd:string ;
                spl:defaultValue "http://example.org/my-schemaa"^^xsd:string ;
                spl:predicate sp:srcSchema ;
                spl:valueType xsd:string ;
                sm:next :ImportSchema ;
                sm:nodeX 626 ;
                sm:nodeY 8
              ] ;
      spin:constraint
              [ rdf:type spl:Argument ;
                rdfs:comment "Source Mapping Base URI"^^xsd:string ;
                spl:defaultValue "http://example.org/my-mappinga"^^xsd:string ;
                spl:predicate sp:srcMapping ;
                spl:valueType xsd:string ;
                sm:next :ImportMapping ;
                sm:nodeX 81 ;
                sm:nodeY 13
              ] ;
      spin:constraint
              [ rdf:type spl:Argument ;
                rdfs:comment "Target Mapping Base URI"^^xsd:string ;
                spl:defaultValue 
"http://support.tq.com.com/testFinalMapping"^^xsd:string ;
                spl:predicate sp:targetMapURI ;
                spl:valueType xsd:string ;
                sm:next :IterateOverTableNames ;
                sm:nodeX 12 ;
                sm:nodeY 296
              ] ;
      sm:returnModule :ReturnMessage .

:ImportMapping
      rdf:type sml:ImportRDFFromWorkspace ;
      rdfs:label "Import Mapping"^^xsd:string ;
      sm:next :IterateOverTableNames ;
      sm:nodeX 380 ;
      sm:nodeY 8 ;
      sml:baseURI "{?srcMapping}"^^xsd:string .

:ImportSchema
      rdf:type sml:ImportRDFFromWorkspace ;
      rdfs:label "Import Schema"^^xsd:string ;
      sm:next :ConstructSchemaFile ;
      sm:nodeX 698 ;
      sm:nodeY 216 ;
      sml:baseURI "{?srcSchema}"^^xsd:string .

:IterateOverTableNames
      rdf:type sml:IterateOverSelect ;
      rdfs:label "Iterate over table names"^^xsd:string ;
      sm:body :ConstructMappings ;
      sm:next :BindVariables , :ConstructSchemaFile ;
      sm:nodeX 320 ;
      sm:nodeY 180 ;
      sml:selectQuery
              [ rdf:type sp:Select ;
                sp:resultVariables (_:b30) ;
                sp:where ([ sp:object _:b31 ;
                            sp:predicate <http://www.topbraid.org/tops#split> ;
                            sp:subject
                                    [ sp:varName "name"^^xsd:string
                                    ]
                          ] [ sp:object
                                    [ sp:varName "atableNames"^^xsd:string
                                    ] ;
                            sp:predicate rdf:first ;
                            sp:subject _:b31
                          ] [ sp:object _:b32 ;
                            sp:predicate rdf:rest ;
                            sp:subject _:b31
                          ] [ sp:object "[^A-Za-z]*,[^A-Za-z]*" ;
                            sp:predicate rdf:first ;
                            sp:subject _:b32
                          ] [ sp:object () ;
                            sp:predicate rdf:rest ;
                            sp:subject _:b32
                          ] [ rdf:type sp:Let ;
                            sp:expression
                                    [ rdf:type smf:buildURI ;
                                      sp:arg1 "{?srcMapping}#{?name}"
                                    ] ;
                            sp:variable _:b30
                          ])
              ] .

:ReturnMessage
      rdf:type sml:ReturnText ;
      rdfs:label "Return message"^^xsd:string ;
      sm:nodeX 723 ;
      sm:nodeY 831 ;
      sml:mimeType "text"^^xsd:string ;
      sml:text "Mapping and schema conversions completed."^^xsd:string .

sp:atableNames
      rdf:type rdf:Property ;
      rdfs:label "table names"^^xsd:string ;
      rdfs:subPropertyOf sp:arg .

sp:srcMapping
      rdf:type rdf:Property ;
      rdfs:label "Src mapping"^^xsd:string ;
      rdfs:subPropertyOf sp:arg .

sp:srcSchema
      rdf:type rdf:Property ;
      rdfs:label "Src schema"^^xsd:string ;
      rdfs:subPropertyOf sp:arg .

sp:targetDbURI
      rdf:type rdf:Property ;
      rdfs:label "target db URI"^^xsd:string ;
      rdfs:subPropertyOf sp:arg .

sp:targetMapURI
      rdf:type rdf:Property ;
      rdfs:label "target map URI"^^xsd:string ;
      rdfs:subPropertyOf sp:arg .

sp:targetSchemaURI
      rdf:type rdf:Property ;
      rdfs:label "target schema URI"^^xsd:string ;
      rdfs:subPropertyOf sp:arg .

sp:zdbConnName
      rdf:type rdf:Property ;
      rdfs:label "db conn name"^^xsd:string ;
      rdfs:subPropertyOf sp:arg .

_:b32
      sp:varName "?1"^^xsd:string .

_:b31
      sp:varName "?0"^^xsd:string .

_:b30
      sp:varName "clsUri"^^xsd:string .

_:b29
      sp:varName "targetSchemaURI"^^xsd:string .

_:b28
      sp:varName "schemaUri"^^xsd:string .

_:b27
      sp:varName "fileUri"^^xsd:string .

_:b26
      sp:varName "dbUri"^^xsd:string .

_:b25
      sp:varName "targetDbURI"^^xsd:string .

_:b24
      sp:varName "propMap"^^xsd:string .

_:b23
      sp:varName "clsMap"^^xsd:string .

_:b22
      sp:varName "prop"^^xsd:string .

_:b21
      sp:varName "propProp"^^xsd:string .

_:b20
      sp:varName "propObj"^^xsd:string .

_:b19
      sp:varName "cls"^^xsd:string .

_:b18
      sp:varName "clsProp"^^xsd:string .

_:b17
      sp:varName "clsObj"^^xsd:string .

_:b9  sp:varName "cls"^^xsd:string .

_:b8  sp:varName "cp"^^xsd:string .

_:b7  sp:varName "co"^^xsd:string .

_:b6  sp:varName "prop"^^xsd:string .

_:b5  sp:varName "pp"^^xsd:string .

_:b4  sp:varName "po"^^xsd:string .

_:b13
      sp:varName "mapFileUri"^^xsd:string .

_:b12
      sp:varName "db"^^xsd:string .

_:b11
      sp:varName "p"^^xsd:string .

_:b10
      sp:varName "o"^^xsd:string .

_:b16
      sp:varName "clsUri"^^xsd:string .

_:b15
      sp:varName "p"^^xsd:string .

_:b14
      sp:varName "o"^^xsd:string .

_:b3  sp:varName "targetMapURI"^^xsd:string .

_:b2  sp:varName "time"^^xsd:string .

_:b1  sp:varName "mapfilename"^^xsd:string .

Reply via email to