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
Myna. Admin. authtype. validationa Myna.Validation object for validating Auth Type configs
Functions
Myna. Admin. authtype. existsreturns true if an AuthType with the supplied name exists.
Myna. Admin. authtype. getAllreturns an array of AUTHTYPE structures currently configured
Myna. Admin. authtype. getAdapterNamesreturns an array of Auth Adapter names available on the system
Myna. Admin. authtype. getAuthAdapterMapreturns a map of Auth Adapters available on the system, keyed by adapter name
Myna. Admin. authtype. getMapreturns a map of all AUTHTYPE structures currently configured
Myna. Admin. authtype.saveupdates an auth type
Myna. Admin. authtype. removeupdates an auth type
Myna. Admin. authtype. validatevalidates a data source config
Properties
Myna. Admin. ds. dsValidationa Myna.Validation object for validating data source configs
Functions
Myna. Admin. ds. createLocalDatabasecreate a local H2 databsae with the given name
Myna. Admin. ds. existsreturns true if a datasource with the supplied name exists.
Myna. Admin. ds. getAllreturns an array of DS structures currently configured
Myna. Admin. ds. getMapreturns a map of all DS structures currently configured
Myna. Admin. ds.testtests connecting to the named DS and returns a Myna.ValidationResult
Myna. Admin. ds.saveupdates a data source,
Myna. Admin. ds. validatevalidates a data source config
Properties
Myna. Admin. task. taskValidationa Myna.Validation object for validating Scheduled task
Functions
Myna. Admin. task. getAllreturns a JS object where the keys are task names and the values are task configs
Myna. Admin. task.savecreates/updates a task,
Myna. Admin. task. removeremoves a task,
Myna. Admin. task. nameToIDreturns a task name formated as an identifier
Myna. Admin. task. getStatereturns the state of the named task
Myna. Admin. task. saveStatesaves the state of the named task
getNextRunDatereturns the Date() a task should next be run, based on current state file
scheduleNextRunclears and re-schedules the next run of a given task (or all), based on the current state file
runruns a given task, and updates state

Properties

Myna. Admin. authtype. validation

a Myna.Validation object for validating Auth Type configs

Functions

Myna. Admin. authtype. exists

returns true if an AuthType with the supplied name exists.

Parameters

namename of a data source

Myna. Admin. authtype. getAll

returns an array of AUTHTYPE structures currently configured

Myna. Admin. authtype. getAdapterNames

returns an array of Auth Adapter names available on the system

Myna. Admin. authtype. getAuthAdapterMap

returns a map of Auth Adapters available on the system, keyed by adapter name

Myna. Admin. authtype. getMap

returns a map of all AUTHTYPE structures currently configured

Myna. Admin. authtype.save

updates an auth type

Parameters

configConfig Object, see Config below.  Some adapters support additional config properties
isNewset to true for new auth types.  This checks for the existence if a same-named type and prevents overwrites

Config

auth_typeName of auth type.  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 auth types.  Note that the auth types “myna” and “server_admin” are predefined and cannot be edited
prettyNameDisplay name for this auth type
adapterauth adapter name (see /shared/js/libOO/auth_adapters).  Note that the adapters “myna” and “server_admin” are predefined and cannot be used in new auth types
descOptional, default null A description of this data source

Note

individual adapters may have more config properties

Returns

Myna.ValidationResult

Myna. Admin. authtype. remove

updates an auth type

Parameters

auth_typeAuth type name to remove

Myna. Admin. authtype. validate

validates a data source config

Parameters

configJS Object representing the data for a data source, see <save>
isNewBoolean.  If true, AuthType name will also be checked for uniqueness

Returns

Myna.ValidationResult

Properties

Myna. Admin. ds. dsValidation

a Myna.Validation object for validating data source configs

Functions

Myna. Admin. ds. createLocalDatabase

create a local H2 databsae with the given name

Parameters

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

Returns Myna.ValidationResult

See

  • <save>

Myna. Admin. ds. exists

returns true if a datasource with the supplied name exists.

Parameters

namename of a data source

Myna. Admin. ds. getAll

returns an array of DS structures currently configured

Myna. Admin. ds. getMap

returns a map of all DS structures currently configured

Myna. Admin. ds.test

tests connecting to the named DS and returns a Myna.ValidationResult

Parameters

namename of DS to test

Myna. Admin. ds.save

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.ds.save({
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.ds.save({
name:"myna_log",
type:"postgresql",
server:"localhost",
port:5432,
username:"myna",
password:"nunyabidness"
})

//simple local H2 DB
if (!Myna.Admin.ds.exists("mmft.mynajs.org")){
Myna.Admin.ds.save({
name:"mmft.mynajs.org",
type:"h2",
location:"file",
file:"/WEB-INF/myna/local_databases/mmft.mynajs.org"
}))
}

Returns

Myna.ValidationResult

Myna. Admin. ds. validate

validates a data source config

Parameters

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

Returns

Myna.ValidationResult

Properties

Myna. Admin. task. taskValidation

a Myna.Validation object for validating Scheduled task

Functions

Myna. Admin. task. getAll

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

Myna. Admin. task.save

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

Myna. Admin. task. remove

removes a task,

Parameters

namename of task to remove

Myna. Admin. task. nameToID

returns a task name formated as an identifier

Parameters

namename of task to convert

Task ID is “task_” + task name with all non word characters replaced with single underbars, converted to lower case.  Id’s are used as the appname for Task logs and for the task state file names

Myna. Admin. task. getState

returns the state of the named task

Parameters

namename of task load

The “state” of a task is an object with nextRun and lastRun properties.  These are either Dates or null.  These properties are also available in the task configs returned from Myna.Admin.task.getAll()

Myna. Admin. task. saveState

saves the state of the named task

Parameters

namename of task load
statestate object

The “state” of a task is an object with nextRun and lastRun properties.  These are either Dates or null.  These properties are also available in the task configs returned from Myna.Admin.task.getAll()

getNextRunDate

getNextRunDate:function getNextRunDate(name)

returns the Date() a task should next be run, based on current state file

Parameters

namename of task to check

scheduleNextRun

scheduleNextRun:function scheduleNextRun(taskName)

clears and re-schedules the next run of a given task (or all), based on the current state file

Parameters

nameOptional, default null name of task to run, or null to reschedule all tasks

run

run:function runTask(name)

runs a given task, and updates state

Parameters

namename of task to run
A store for validation functions that can be used to validate objects
Stores the results of one or more validation operations
getNextRunDate:function getNextRunDate(name)
returns the Date() a task should next be run, based on current state file
scheduleNextRun:function scheduleNextRun(taskName)
clears and re-schedules the next run of a given task (or all), based on the current state file
run:function runTask(name)
runs a given task, and updates state
Static Global database vendor properties
returns a JS object where the keys are task names and the values are task configs