-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
1,269 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import {ImportExport} from './dbconfiguration'; | ||
|
||
|
||
|
||
export const APP_DECLARATIONS = [ | ||
ImportExport | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
import {DBService, GraphService} from './core/services'; | ||
import {DBService, GraphService, SchemaService, CommandService} from './core/services'; | ||
import {FormatArrayPipe, FormatErrorPipe} from './core/pipes'; | ||
|
||
const APP_PIPES = [ | ||
FormatArrayPipe, | ||
FormatErrorPipe | ||
] | ||
|
||
const APP_SERVICES = [ | ||
DBService, | ||
GraphService | ||
GraphService, | ||
SchemaService, | ||
CommandService | ||
] | ||
|
||
|
||
export const APP_RESOLVER_PROVIDERS = [ | ||
...APP_SERVICES | ||
...APP_SERVICES, | ||
...APP_PIPES | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {downgradeInjectable} from '@angular/upgrade/static'; | ||
|
||
class FormatArrayPipe { | ||
|
||
transform(input) { | ||
if (input instanceof Array) { | ||
var output = ""; | ||
input.forEach(function (e, idx) { | ||
output += (idx > 0 ? ", " : " ") + e; | ||
}) | ||
return output; | ||
} else { | ||
return input; | ||
} | ||
} | ||
} | ||
|
||
angular.module('legacy.filters', []).factory( | ||
`FormatArrayPipe`, | ||
downgradeInjectable(FormatArrayPipe)); | ||
|
||
export {FormatArrayPipe}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {downgradeInjectable} from '@angular/upgrade/static'; | ||
|
||
class FormatErrorPipe { | ||
|
||
transform(input) { | ||
if (typeof input == 'string') { | ||
return input; | ||
} else if (typeof input == 'object') { | ||
return input.errors[0].content; | ||
} else { | ||
return input; | ||
} | ||
} | ||
} | ||
|
||
angular.module('legacy.filters', []).factory( | ||
`FormatErrorPipe`, | ||
downgradeInjectable(FormatErrorPipe)); | ||
|
||
export {FormatErrorPipe}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './formatArray.pipe'; | ||
export * from './formatError.pipe'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {downgradeInjectable} from '@angular/upgrade/static'; | ||
import {Http} from '@angular/http'; | ||
import 'rxjs/add/operator/toPromise'; | ||
|
||
import {API} from '../../../constants'; | ||
|
||
class CommandService { | ||
constructor(http) { | ||
this.http = http; | ||
} | ||
|
||
|
||
command({db, language, query, limit}) { | ||
let startTime = new Date().getTime(); | ||
limit = limit || 20; | ||
language = language || 'sql'; | ||
let url = API + 'command/' + db + "/" + language + "/-/" + limit + '?format=rid,type,version,class,graph'; | ||
query = query.trim(); | ||
return this.http.post(url, query).toPromise(); | ||
} | ||
} | ||
|
||
CommandService.parameters = [[Http]]; | ||
|
||
angular.module('command.services', []).factory( | ||
`CommandService`, | ||
downgradeInjectable(CommandService)); | ||
|
||
export {CommandService}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import {API} from '../../../constants'; | ||
|
||
|
||
|
||
class DBService { | ||
exportDB(db) { | ||
window.open(API + 'export/' + db); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export * from './graph.service'; | ||
export * from './database.service'; | ||
export * from './schema.service'; | ||
export * from './command.service'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
import {downgradeInjectable} from '@angular/upgrade/static'; | ||
import {CommandService} from './command.service'; | ||
import {FormatArrayPipe} from '../pipes'; | ||
|
||
class SchemaService { | ||
constructor(commandService, arrayPipe) { | ||
this.commandService = commandService; | ||
this.arrayPipe = arrayPipe; | ||
|
||
this.systems = ["OUser", | ||
"ORole", | ||
"OIdentity", | ||
"_studio", | ||
"OFunction", | ||
"ORestricted", | ||
"OShape", | ||
"OPoint", | ||
"OGeometryCollection", | ||
"OLineString", | ||
"OMultiLineString", | ||
"OMultiPoint", | ||
"OPolygon", | ||
"OMultiPolygon", | ||
"ORectangle", | ||
"OSchedule", | ||
"OSequence", | ||
"OTriggered"]; | ||
} | ||
|
||
createClass(db, {name, abstract, superClasses, clusters}) { | ||
|
||
let query = 'CREATE CLASS `' + name + "`"; | ||
let abstractSQL = abstract ? ' ABSTRACT ' : ''; | ||
let superClassesSQL = ''; | ||
if ((superClasses != null && superClasses.length > 0)) { | ||
superClassesSQL = ' extends ' + this.arrayPipe.transform((superClasses.map((c) => { | ||
return "`" + c + "`" | ||
}))); | ||
} | ||
let clusterSQL = ''; | ||
if (clusters) { | ||
clusterSQL = `CLUSTERS ${clusters}`; | ||
} | ||
|
||
query = query + superClassesSQL + clusterSQL + abstractSQL; | ||
return this.commandService.command({ | ||
db, | ||
query | ||
}) | ||
} | ||
|
||
alterClass(db, {clazz, name, value}) { | ||
let query = `ALTER CLASS \`${clazz}\` ${name} ${value} `; | ||
return this.commandService.command({ | ||
db, | ||
query | ||
}) | ||
} | ||
|
||
|
||
createProperty(db, {clazz, name, type, linkedType, linkedClass}) { | ||
|
||
linkedType = linkedType || ''; | ||
linkedClass = linkedClass || ''; | ||
let query = `CREATE PROPERTY \`${clazz}\`.\`${name}\` ${type} ${linkedType} ${linkedClass}`; | ||
return this.commandService.command({ | ||
db, | ||
query | ||
}) | ||
} | ||
|
||
isSystemClass(c) { | ||
return this.systems.indexOf(c) != -1; | ||
} | ||
|
||
genericClasses(classes) { | ||
return classes.filter((c) => { | ||
return !this.isGraphClass(classes, c.name); | ||
}) | ||
} | ||
|
||
isGraphClass(classes, clazz) { | ||
let sup = clazz; | ||
let iterator = clazz; | ||
while ((iterator = this.getSuperClazz(classes, iterator)) != "") { | ||
sup = iterator; | ||
if (sup == 'V' || sup == 'E') { | ||
return true; | ||
} | ||
} | ||
return sup == 'V' || sup == 'E'; | ||
} | ||
|
||
getSuperClazz(classes, clazz) { | ||
let clazzReturn = ""; | ||
for (var entry in classes) { | ||
var name = classes[entry]['name']; | ||
if (clazz == name) { | ||
clazzReturn = classes[entry].superClass; | ||
break; | ||
} | ||
} | ||
return clazzReturn; | ||
} | ||
|
||
|
||
isVertexClass(classes, clazz) { | ||
var sup = clazz; | ||
var iterator = clazz; | ||
while ((iterator = this.getSuperClazz(classes, iterator)) != "") { | ||
sup = iterator; | ||
} | ||
return sup == 'V'; | ||
} | ||
|
||
vertexClasses(classes) { | ||
return classes.filter((c) => { | ||
return this.isVertexClass(classes, c.name); | ||
}) | ||
} | ||
|
||
edgeClasses(classes) { | ||
return classes.filter((c) => { | ||
return this.isEdgeClass(classes, c.name); | ||
}) | ||
} | ||
|
||
isEdgeClass(classes, clazz) { | ||
var sup = clazz; | ||
var iterator = clazz; | ||
while ((iterator = this.getSuperClazz(classes, iterator)) != "") { | ||
sup = iterator; | ||
} | ||
return sup == 'E'; | ||
} | ||
} | ||
|
||
SchemaService | ||
.parameters = [CommandService, FormatArrayPipe]; | ||
|
||
|
||
angular.module('schema.services', []).factory(`SchemaService`, downgradeInjectable(SchemaService)); | ||
|
||
export {SchemaService}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import SCHEMA_COMPONENTS from './schema'; | ||
|
||
const COMPONENTS = [ | ||
SCHEMA_COMPONENTS.name | ||
] | ||
|
||
export default COMPONENTS; |
Oops, something went wrong.