66*
77***************************************************************************************************/
88
9- var ImportFormCtrl = function ( $scope , $http , $q , $timeout , ConfigurationService , flash , AccountService , GraphService , Ns , Upload , ImportRdfService , ServerErrorResponse , Helpers ) {
9+ var ImportFormCtrl = function ( $scope , $http , $q , $timeout , ConfigurationService , flash , AccountService , AuthSessionService , GraphService , Ns , Upload , ImportRdfService , ServerErrorResponse , Helpers ) {
1010
1111 var currentAccount = AccountService . getAccount ( ) ;
1212
@@ -40,7 +40,7 @@ var ImportFormCtrl = function($scope, $http, $q, $timeout, ConfigurationService,
4040 graph : "" ,
4141 isNew : {
4242 prefix : "RdfImport" ,
43- label : "" ,
43+ label : "RdfImport " ,
4444 description : ""
4545 }
4646 } ;
@@ -66,13 +66,19 @@ var ImportFormCtrl = function($scope, $http, $q, $timeout, ConfigurationService,
6666 if ( $scope . importLocal . action == 'QUERY' ) {
6767 $scope . importLocal . sparqlQuery = "INSERT { GRAPH <" + Ns . lengthen ( $scope . target . graph ) + "> {?s ?p ?o}} "
6868 + "WHERE {GRAPH <" + Ns . lengthen ( $scope . importRdf . source ) + "> {?s ?p ?o}}" ;
69- return true ;
7069 }
7170 else
7271 $scope . importLocal . sparqlQuery = $scope . importLocal . action ;
73- return false ;
7472 } ;
7573
74+ $scope . showInputQuery = function ( ) {
75+ if ( $scope . importLocal . action == 'QUERY' )
76+ return true ;
77+ else
78+ return false ;
79+ }
80+
81+
7682 $scope . updateNewTargetInfo = function ( ) {
7783 console . log ( $scope . source . graph ) ;
7884 if ( $scope . sourceType . value == 'file' ) {
@@ -103,6 +109,7 @@ var ImportFormCtrl = function($scope, $http, $q, $timeout, ConfigurationService,
103109 label : "Import from graph" ,
104110 description : "Import from graph " + $scope . importRdf . source ,
105111 } ;
112+ $scope . updateSparqlCopyQuery ( ) ;
106113 }
107114
108115 }
@@ -216,8 +223,18 @@ var ImportFormCtrl = function($scope, $http, $q, $timeout, ConfigurationService,
216223 importPromise = ImportRdfService . importFromFile ( $scope . importRdf . files , $scope . target . graph ) ;
217224 else if ( $scope . sourceType . value == 'url' )
218225 importPromise = ImportRdfService . importFromUrl ( $scope . importRdf . source , $scope . target . graph ) ;
219- else if ( $scope . sourceType . value == 'externalQuery' )
220- importPromise = ImportRdfService . importFromEndpoint ( scope . importEndpoint . sparqlQuery , $scope . importRdf . source , $scope . target . graph ) ;
226+ else if ( $scope . sourceType . value == 'externalQuery' ) {
227+
228+ if ( $scope . importRdf . source == ConfigurationService . getSPARQLEndpoint ( ) ) {
229+ importPromise = AuthSessionService . createSession ( ) . then ( function ( response ) {
230+ var authEndpoint = ConfigurationService . getFrameworkHomepage ( ) + response . data . endpoint ;
231+ return ImportRdfService . importFromEndpoint ( $scope . importEndpoint . sparqlQuery , authEndpoint , $scope . target . graph ) ;
232+ } ) ;
233+ }
234+ else
235+ importPromise = ImportRdfService . importFromEndpoint ( $scope . importEndpoint . sparqlQuery , $scope . importRdf . source , $scope . target . graph ) ;
236+
237+ }
221238 else if ( $scope . sourceType . value == 'localQuery' )
222239 importPromise = ImportRdfService . importFromLocal ( $scope . importRdf . source , $scope . target . graph , $scope . importLocal . sparqlQuery ) ;
223240
@@ -250,6 +267,7 @@ var ImportFormCtrl = function($scope, $http, $q, $timeout, ConfigurationService,
250267 } ) ;
251268
252269 } ,
270+ //error
253271 function ( response ) {
254272 flash . error = ServerErrorResponse . getMessage ( response ) ;
255273 importing = false ;
0 commit comments