Post on 13-Apr-2017
transcript
i-viewsUniversityPart04:Imports&Exports
Imports&Exports
2
Ifyouhaveproblemswiththesound:- Checktheaudiosettingsinmenuitem „Communicate“- Joinalternativelybytelephoneorbydial-innumber
from landline phone (for free):• 000-800-100-8171 for India• 0800-894627for Switzerland
from mobilephone• +41434569564 only for Switzerland
Event-Number: 841561659Event-Password: hello
Imports&Exports
3
Today‘s Speaker
AnnekathrinLösche
KnowledgeEngineer
intelligentviews gmbh
Imports&Exports
4
Agenda1. DataFormatsand Recommendations
2. BasicPrinciple of the Import-ExportToolExplained
3. Opening of and Overview over Import-ExportTool
4. Mappingof DataSources3.1Mappingof Objects
3.2Mappingof Types
3.3Mappingof MultipleValues
5. ImportBehaviour
6. XMLImport
7. Export
Imports&Exports
5
ImportDataFormats• Standardized database interface for direct connection to relationaldatabases
• MySQL
• ODBC
• Oracle
• PostgreSQL
• LDAP(available for exchanging user IDs)
• .csv/.xlsx
• .xml• .rdf
• .owl
Imports&Exports
6
ExportDataFormats• Standardized database interface for direct connection to relationaldatabases
• MySQL
• ODBC
• Oracle
• PostgreSQL
• LDAP(available for exchanging user IDs)
• .csv/.xlsx
• .rdf
• .owl
• Furtherformats (e.g.JSON)can be generated through the i-views programming interface – the programminginterface is notpart of the import-exporttool
Imports&Exports
7
Import-RecommendationsThereisnobackbutton!
• Toavoidunnessecaryfallbacks,importsshouldfirstbetestedinalocalcopyofthenetwork
Thedatabasestructureshouldnotbecreatedviaimports!• Importsshouldnotbeusedtobuildthedatamodel
• Relation- andattributetypescannotbedefinedduringtheimport
Largefilesshouldnotbeimporteduntested!• Importmappingsshouldbetestedwithasmallsamplefile
Imports&Exports
8
BasicPrinciple:Mappingwith the Import-ExportTool• MAPPING=assigningtable-columns/xml-tagstothe
datamodelini-views
Artist Album
Radiohead TheKingoflimbs
Portishead Artist
Nameoftheobject
Album
Imports&Exports
9
BasicPrinciple:Mappingwith the Import-ExportTool
Artist Album
Radiohead TheKingoflimbs
Portishead Artist
Nameoftheobject
Album
Demonstration
Importsettings
Imports&Exports
11
Opening the Import-ExportTool• Locationoftheimport-exporttool:
• Folder->WorkingfolderorPrivate
• Technical->Registeredobjects->Datasources
Imports&Exports
12
Opening the Import-ExportTool• Importand export mappings require:• Name
• Informationof the format to be imported
Imports&Exports
13
Example File(.csv)
"Band";“Album”;"Shortdescriptionalbum";"Songs"
“Pink”;"M!ssundaztood";"MissundaztoodisthesecondstudioalbumbyAmericansinger-songwriterPink."Thealbumwhichreleasedworldwideinlate2001toglobalcommercialandcriticalsuccess,criticswelcomingthenewpop-rocksoundpinkpresentedontherecord,afterurban-influencedR&bdebut.";"M!ssundaztood,Don'tletmegetme,JustLikeapill,Getthepartystarted,Respect,18Wheeler,Familyportrait,misery,Deardiary,Eventually,LonelyGirl,Numb,GonetoCalifornia,MyVietnam"
Imports&Exports
14
ReadDatafrom Import-File
1.Selectfiletoimport(mustcorrespondtoformatoftheimport)
2.Read/updatestructureofthe
table
Imports&Exports
15
Choose TableFileType
Selectfiletype(default:.csv)
Imports&Exports
16
Identifying Headings
Ifthefirstlineconsistsofheadingsandthevaluesofthecellsarein““- puta
checkmarkhere
"Band";'Album';"Shortdescriptionalbum";"Songs"
'Pink';"M!ssundaztood";"MissundaztoodisthesecondstudioalbumbyAmericansinger-songwriterPink."Thealbumwhichreleasedworldwideinlate2001toglobalcommercialandcriticalsuccess,criticswelcomingthenewpop-rocksoundpinkpresentedontherecord,afterurban-influencedR&bdebut.";""M!ssundaztood,Don'tletmegetme,JustLikeapill,Getthepartystarted,Respect,18Wheeler,Familyportrait,misery,Deardiary,Eventually,LonelyGirl,Numb,GonetoCalifornia,MyVietnam"
Imports&Exports
17
Identifying Columns
Theidentificationofcolumnsisverythatimportantforone-timeimports.
Ifamappingisusedforimportingvariousfilesorperiodicallyrecurringimports,thisoptionisveryimportant.
Imports&Exports
18
Identfiy Columns• Ifthestructureofafileischanged
(columnsrenamed,sequencechanged,etc.),themappinghastobeadaptedtothesechanges
• Ifi-viewscanidentifythecolumns,themappingdoesn'thavetobeadaptedmanually
Album Artist
TheKingofLimbs Radiohead
Dummy Portishead
Artist Album
Radiohead TheKingofLimbs
Portishead Dummy
Imports&Exports
19
Identfiy Columns• Byheading• When?
• Columnheadingsremainconstantbuttheorderofthecolumnsdoesn’t
• Requirements
• Stringsofthecolumnheadingsmustbeidentical
Album Artist
TheKingofLimbs Radiohead
Dummy Portishead
Artist Album
Radiohead TheKingofLimbs
Portishead Dummy
i-viewscomparesthestringsoftheheadingsandadaptsthechangesinthe
mapping
Imports&Exports
20
Identfiy Columns• Byposition• When?
• Columnlabelchanges,thetypeofinformationremainsthesame
• Requirements
• Columnpositionandnumbermaynotchange
Band CDname
Radiohead TheKingofLimbs
Portishead Dummy
Artist Album
Radiohead TheKingofLimbs
Portishead Dummy
Contentfromcolumn1alwaysbecomeartistobjectsinthenetwork,thosefromcolumn2arealbumsobjects.
Imports&Exports
21
Identfiy Columns• ÜberZeichenposition• When?
• Iftheentriesarenotcommaseparatedandhaveaconstantlength(withina"column")
• Requirement
• Characterpositionandnumbermaynotchange
1 6 7
ID123 F Ida
ID456 M Timmi
ID789 M Max
ID753 F Michaela
Radio h ead
Exampledata
ID123FIdaID456MTimmiID789MMaxID753FMichaelaRadiohead
Positionofcharactersresultsin
this"table"
Thelastlinemakeslittlesense,sinceit
doesnotcorrespondtothe
grid
Imports&Exports
22
Choosing the Seperator
Indicationofthecharacterthatseparatesthe
valuesintheCSVfile
"Band";'Album';"Shortdescriptionalbum";"Songs"
'Pink';"M!ssundaztood";"MissundaztoodisthesecondstudioalbumbyAmericansinger-songwriterPink."Thealbumwhichreleasedworldwideinlate2001toglobalcommercialandcriticalsuccess,criticswelcomingthenewpop-rocksoundpinkpresentedontherecord,afterurban-influencedR&bdebut.";""M!ssundaztood,Don'tletmegetme,JustLikeapill,Getthepartystarted,Respect,18Wheeler,Familyportrait,misery,Deardiary,Eventually,LonelyGirl,Numb,GonetoCalifornia,MyVietnam"
Imports&Exports
23
Encoding
Characterencodingoftextinthe.csv
file
Imports&Exports
24
LineSeperator
Methodbywhichthelinesareseparatedfromeachother
InWindowsyoucanselect"autodetect"orCR-LF
CR=carriagereturn(beginningoftheline)
LF=linefeed(nextline)
Imports&Exports
25
Identification of Objectsby Seperator
, Tablecolumnsthatcontainmultiplevaluescanbe
identifiedbyspecifyingtheseparator
Inthe"songs"columnmultipleentriesareseparatedbycommas.Ifthecommaisspecifiedasdelimiter,the
importtoolcancreatethesongsasindividualobjects
"Band";'Album';"Shortdescriptionalbum";"Songs"
'Pink';"M!ssundaztood";"MissundaztoodisthesecondstudioalbumbyAmericansinger-songwriterPink."Thealbumwhichreleasedworldwideinlate2001toglobalcommercialandcriticalsuccess,criticswelcomingthenewpop-rocksoundpinkpresentedontherecord,afterurban-influencedR&bdebut.";""M!ssundaztood,Don'tletmegetme,JustLikeapill,Getthepartystarted,Respect,18Wheeler,Familyportrait,misery,Deardiary,Eventually,LonelyGirl,Numb,GonetoCalifornia,MyVietnam"
Imports&Exports
26
Creating Logs
Foraneasycontroloftheimportresults,theimportedobjectscanbecollectedinafolder.Thisfoldermusthavebeencreatedpreviously
Create"NewSemanticelementsfolder"(whetherinthePrivateorWorkingFolder)
andselectduringimportmapping.
Imports&Exports
27
Registry
Registrykeysfordatasourcescanbesetintheregistry.
Registereddatasourcescanbeusedagaininanothercontext.
Anyotheruseofthisdatasourcecanbeviewed.
Buildingyourimportmapping
Demonstration
Imports&Exports
29
MappingTools
Themappingsforimportsandexportsarebuiltusingthesebuildingblocks.
Object
Type
Attribute
Relation
Extension
Deletemappingmodule
Forexport:Exporttheobjectinventoryofa
folder
Forexport:Exportresultslistofasearch
Forexport:Modifythevalueofacellwith
script
Forexport:Exportinternali-
viewsID
MoveImport/ExportMapping
toanotherwindow
ForexportofSearch:
Objectswiththisidentifier
Export! specificobjectImportstepbystep!
Import!
Imports&Exports
30
Mappingof DataSources
Imports&Exports
31
Object Mapping
Imports&Exports
32
AttributeMapping(1stColumn)
• Eachcolumnheadingcanbemappedtoanattribute;eachcellrepresentsanattributevalue(canalsobeempty)
Imports&Exports
33
Mappingof DataSources
Imports&Exports
34
Mappingof DataSources
• „Pink“is singing the song.
• Furthermore,„Pink“is aPerson.
• We know that the Personsinging this song is the creator of the song and can therefor linkthe song to the creater„Pink“with arelation of the type„wascreated by“.
• Therelation target (Pink)is anobject of type„Person“.
• Thisobject has anan attribute „Name“with the value of „Pink“.
Imports&Exports
35
RelationMapping
• Eachrelationneedsasourceandatarget
Imports&Exports
36
AttributeMapping(2ndColumn)
• Each column heading can be mapped to anattribute,each of this column‘s cell represents anattribute value (it can be empty though)
Imports&Exports
37
Mappingof DataSources
Imports&Exports
38
Identification of Objects
• Each object needs atleastone attribute for identification inthe graph database.
• If available,the IDshould be used for identification.
IfthereisnoID,andandoneattributeisnotsufficienttouniquelyidentifyanobject,severalattributesshouldbeselected(ex.nameandalbumofthesong).
!
Imports&Exports
39
TypeIllustration
• Typescanalsobeimportedandexported.Forexample,thegenresofsongsaretobeimportedastypes.Thesongsshouldbespecificobjectsofgenretypes.
Imports&Exports
40
Mappingof Types
!
Imports&Exports
41
Mappingof Types
Imports&Exports
42
Mappingof Types – SpecialCase
• Differenttypescanbepresentinonecolumnofatable.This case canalsobemapped.
Imports&Exports
43
AttributeTypes
• Adate/timecan be assigned to anattribute of type„date“.
• Booleanattributens and selection attributes can beassigned the corresponding values from the database.
Imports&Exports
44
Mappingof MultipleValuesfor One Object Type
If several values are given for anobject typewith anobject (inourexample,several „Genres“for eachalbum),there are three possibleways the table could look like.For two of those,the import has tobe adapted.
Imports&Exports
45
Mappingof MultipleValuesfor One Object Type
Imports&Exports
46
Settingsfor ImportBehavior
• Foreachitemitsownimportbehaviorcanbedetermined.
• Defaultsetting:"Updateorcreateifnotfound"• Existingelementswillbeoverwritten,iftheyarenotpresent,theywillbecreated
YoucanspecifytheImportbehaviour.
Imports&Exports
47
Settingsfor ImportBehavior• Update
• Existingitemswillbeoverwritten(updated),nonewelementswillbecreated.
• Createnew
• Createsanewproperty/object,withoutconsideringwhethertheattributevalueortheobjectalreadyexists,ifpossible(notethesetting,canoccurseveraltimesintheattributedefinition).
• Createnewifnotfound(onlyavailableonattributes)
• Onlyifnootherattributeofthedesiredtypeexists,anewonewillbeapplied.(Theimportmultipleattributevaluessimultaneouslytoanattributetypeisnotpossible,sincewecannotdecidewhichoftheattributevaluesshouldbeused.)
• Donotimport
Imports&Exports
48
Settingsfor ImportBehavior• Delete
• Usedtodeleteexactlytheelement.
• Deleteallwithsamevalue(onlypropertiesavailable)
• Allattributevaluesthatmatchtheimportedvaluewillbedeletedfortherespectivecorrespondingobjectsoftheimporttable.
• Deleteallofsamekind
• Allattributevaluesoftheselectedtypearedeletedforthecorrespondingobjectsoftheimporttable,regardlessofwhetherthevaluesmatchornot.
Import
Imports&Exports
49
Settingsfor ImportBehavior• Synchronize
• Caution- Syncisalsoaformofdeletion:• Ifobjectsofatypearesynchronized,allobjectsofthattypethatdon'toccurintheimporttablewillbedeleted,
• Ifanexistingattributereceivesnovaluefromanimport,itisdeletedforthecorrespondingobjectoftheimporttable.If theexistingattributehasadifferentvaluethanintheimporttable,itisupdated,evenifitmayappearseveraltimes.
Import
Imports&Exports
50
XMLImport
• AllXMLfiles can be imported into i-views.
• JSONpreprocessingpossible
• XSLTtransformationpossible
Imports&Exports
51
XMLImport• OptionsofdatasourcefileorURI
• Tagscanbereadthroughthebutton"Readfromdatasource"
Imports&Exports
52
XMLImport
- Adding anXPath expression
Imports&Exports
53
XMLImport• Anitemmaybedisplayedineachcaseononeday.
• X-pathexpressionscanbeusedforamapping,too.
Imports&Exports
54
XPath - Examples
//genre[@label=„Rock“]/@lable
//genre Selectsallgenres,itdoesnotmatterwheretheyareinthedocument.
./genre Selects genres,which are asubelement ofthe current node.
genre[@label] Selects allgenres which hava alable.
@label Selects the lable itself.
Imports&Exports
55
Export• Theexportmappingissimilartotheimportmapping
• Columnsmustbedefinedmanually.
• Exportsettingsperelement:ExportAllorDonotexport
Imports&Exports
56
Exporting QueryResults
Exportofstructurequeryresultspossible.
Withidentifiersyoucanaccessindividualelements.
Imports&Exports
57
ExportDetails• Exportofcollectionsofsemanticobjectsispossible
• Exportofindividualsemanticelementsispossible
• ExportoftheframeIDsasastringor64-bitintegerispossible
Imports&Exports
58
Exporting with Script• Scriptmappingsareusedwhenspecialcolumnsinthetargettablehavetobecreated.
• Scriptinglanguage:KScriptorJavascript
• Example:threeattributesfromthesemanticgraphdatabasearetobecombinedtoanID.
• Example:allattributesofatypeshouldbewrittenseparatedbycommainarowinthetargettable.
Imports&Exports
59
ExercisemusicCSVbeispielEinfach.csv
1. Importallalbumsofaband(withshortdescription).
2. 1+allsongs of analbum
musicCSVbeispiel.csv
1. importallbands,albumandsongs
2. 1+genre
spicePersonen2.csv
1. Importallbandmembersandalltheiralternativenames
musicXMLbeispiel2.xml
1. importallbandsandalbums
2. 1+pricesofthealbums
3. importonlybandsandalbumswhosealbumscostmorethan10dollars
Exportallsongswiththemoodpleasant
Exportallsongsandtheirdurationinminutes
Imports&Exports
60
Sendyour questions to:contact-webinar@i-views.com
Consultationhours:EveryWednesday
Thank you for visitingi-viewsUniversity
Imports&Exports
61
UnsereneuenIcons