Myna. Admin

API for Administrative functions

This library contains the functions used by the Myna Administrator for tasks such as DataSource and Scheduled Task management

Summary
Myna. AdminAPI for Administrative functions
Properties and Functions
dsValidationa Myna.Validation object for validating data source configs
createLocalDatabasecreate a local H2 databsae with the given name
dsExistsreturns true if a datasource with the supplied name exists.
getDataSourcesreturns an array of DS structures currently configured
saveDataSourceupdates a data source,
validateDataSourcevalidates a data source config
taskValidationa Myna.Validation object for validating Scheduled task
getTasksreturns a JS object where the keys are task names and the values are task configs
saveTaskcreates/updates a task,
removeTaskremoves a task,

Properties and Functions

dsValidation

a Myna.Validation object for validating data source configs

createLocalDatabase

createLocalDatabase:function(name)

create a local H2 databsae with the given name

Parameters

namename of datasource.  Should only contain letters, number and (_)

Returns Myna.ValidationResult

See

dsExists

dsExists:function(name)

returns true if a datasource with the supplied name exists.

Parameters

namename of a data source

getDataSources

getDataSources:function getDataSources()

returns an array of DS structures currently configured

saveDataSource

saveDataSource:function(config,
isNew)

updates a data source,

Parameters

configConfig Object, see Config below
isNewset to true for new datasources.  This checks for the existence if a same-named data source and prevents overwrites

Config

nameName of data source.  Must start with at least one letter and consist of only numbers, letters and the underbar(_) Must also be unique in regards to all other datasources
typeVendor Type name as defined in Myna.Database.dbProperties
driverOptional, default from dbProperties A valid driver className, e.g.  “org.postgresql.Driver”.
descOptional, default null A description of this data source
locationOptional, default “network” either “file” or “network”.  This switch determines which url template to use
fileOptional, default null File path to the database file.  This should be an OS native path or a relative MynaPath such as “/WEB-INF/myna/local_databases/mydb”.  Only makes sense for location=”file”
serverOptional, default null server name of DB.  Only makes sense for location=”network”
portOptional, default from dbProperties
dbOptional, default from dbProperties
usernameOptional, null
passwordOptional, null
urlOptional, default from dbProperties

Note

Only name, type, driver, url, username, and password are required for successful operation.  The other fields are used to populate the DS UI, in MynaAdaminstrator and as a convenience for autogenerating url.  See the examples below

Examples

//bare minimum, but requires knowledge of how the url string works
var result = Myna.Admin.saveDataSource({
name:"myna_log",
type:"postgresql",
url="jdbc:postgresql://localhost:5432/myna",
driver="org.postgresql.Driver",
username:"myna",
password:"nunyabidness"
})

//more verbose, but also more readable for GUI
//URL and driver are comuted from Myna.Database.dbProperties
var result = Myna.Admin.saveDataSource({
name:"myna_log",
type:"postgresql",
server:"localhost",
port:5432,
username:"myna",
password:"nunyabidness"
})

Returns

Myna.ValidationResult

validateDataSource

validateDataSource:function(config,
isNew)

validates a data source config

Parameters

configJS Object representing the data for a data source, see saveDataSource
isNewBoolean.  If true, Ds name will also be checked for uniqueness

Returns

Myna.ValidationResult

taskValidation

a Myna.Validation object for validating Scheduled task

getTasks

getTasks:function getTasks()

returns a JS object where the keys are task names and the values are task configs

saveTask

saveTask:function(config,
isNew)

creates/updates a task,

Parameters

configConfig Object, see Config below
isNewset to true for new tasks.  This checks for the existence if a same-named data source and prevents overwrites

Returns

Myna.ValidationResult

removeTask

removes a task,

Parameters

namename of task to remove
A store for validation functions that can be used to validate objects
createLocalDatabase:function(name)
create a local H2 databsae with the given name
dsExists:function(name)
returns true if a datasource with the supplied name exists.
getDataSources:function getDataSources()
returns an array of DS structures currently configured
saveDataSource:function(config,
isNew)
updates a data source,
validateDataSource:function(config,
isNew)
validates a data source config
getTasks:function getTasks()
returns a JS object where the keys are task names and the values are task configs
saveTask:function(config,
isNew)
creates/updates a task,
Stores the results of one or more validation operations
Static Global database vender properties