CitizenModel

CitizenModel

Class to operate on citizen data

Constructor

new CitizenModel()

Source:

Extends

Members

prefixes :Object

Source:
Overrides:

Key - value pairs containing default prefixes we always need

Type:
  • Object

prefixRegex :RegExp

Source:
Overrides:
To Do:
  • move this out

Regular expression to match prefixes that need to be adjusted to the server's url

Only used once at startup in app.js

Type:
  • RegExp

replacementPrefixes :Object

Source:
Overrides:
To Do:
  • move this out, only used on startup

The prefixes which depend on the server's current URL and thus always need to point to the right address.

Type:
  • Object

subpathlinkRegex :RegExp

Source:
Overrides:
To Do:
  • move this out

Regular expression to match 'subpathlinks' that need to be adjusted to the server's url

Only used once at startup in app.js

Type:
  • RegExp

Methods

(async) addInfoByN3String(n3string) → {Promise.<void>}

Source:

Add new information on a user

Parameters:
Name Type Description
n3string string

N3-string to be added to the users profile file

Returns:
  • Returns promise resolving to a value that can be discarded
Type
Promise.<void>

(async) deleteAllInfo() → {Promise.<void>}

Source:

Delete all info on user, ! currently clears the entire storage file

Returns:
  • Returns promise resolving to a value that can be discarded
Type
Promise.<void>

(async) deleteQuadsByInputPatterns(inputPatterns) → {void}

Source:
To Do:
  • Use removeMatches instead of manually retrieving quads by quadsPerInputPattern and deleting them

Delete all stored quads matching the input patterns templates provided

Parameters:
Name Type Description
inputPatterns Array

Array of patterns to remove

Returns:
Type
void

(async) editInfoByQuad(quad, value) → {Promise.<void>}

Source:

Edit info of a user Replaces old quad with new quad with new value and persists this to disk

Parameters:
Name Type Description
quad Quad

the old quad we want to edit

value

new value for the object field of the quad

Returns:
  • Returns promise resolving to a value that can be discarded
Type
Promise.<void>

(async) editInfoByQuads(quads, values) → {Promise.<void>}

Source:

Edit info of a user

Parameters:
Name Type Description
quads Array.<Quad>

old quads that should change

values Array

new values to apply to old quad

Returns:
  • Returns promise resolving to a value that can be discarded
Type
Promise.<void>

(async) getAll(req) → {Object}

Source:
Overrides:

gets all of the items from this model and converts to jsonLD

Parameters:
Name Type Description
req Object

Request, currently unused

Returns:
  • Json representation of data
Type
Object

getAllQuadsByInputPattern(inputPattern) → {Array}

Source:

Retrieves all stored quads that match the pattern

Parameters:
Name Type Description
inputPattern String

N3 pattern used to match stored quads

Returns:
  • The found quads or an empty array if no patterns were found
Type
Array

(async) getInfoByStep(stepName) → {Promise.<string>}

Source:

Returns a promise resolving to all the information available about a specific step Invokes the reasoner to achieve this

Parameters:
Name Type Description
stepName string

name of the step (without "step:" prefix)

Returns:
  • Promise resolving to N3-string containing all the information
Type
Promise.<string>

(async) quadsPerInputPattern(inputPattern) → {Array}

Source:

Retrieves all stored quads that match the supplied patterns

Parameters:
Name Type Description
inputPattern Array.<string>

N3 pattern used to match stored quads

Returns:
  • An array of Quads for every input pattern (this is an array of arrays) or an empty array if no patterns were supplied
Type
Array

replacePrefixesInFile(file)

Source:
Overrides:
To Do:
  • - replacing the sublinkpath links won't work if there are references to links not pointing to a 'plan' - pull this out of baseModel as it's only used once on startup but never in any of the derived classes

Replaces all "@prefix..." and "ex:sublinkpath..." lines in the supplied file with the correct links as these links depend on the hostname of the server

Parameters:
Name Type Description
file string

name of the file whose contents we will be replacing