Welcome to the MOTECH Documentation¶
The topics below will give you an introduction to MOTECH, an open source mHealth platform developed by the Grameen Foundation. Some of these topics are quite technical in nature (i.e. aimed at software developers), while others are more accessible to people who aren’t familiar with software code.
About MOTECH¶
Mobile Technology for Community Health (MOTECH) is a modular, extensible open source software project originally designed for mobile health (mHealth), which can also be used outside of the health domain. It allows organizations to use mobile technology to communicate information to patients, collect data about patients, alert caregivers to patients’ status, and schedule caregivers’ work. The modular system allows organizations to choose among multiple mHealth technologies and to enable data sharing for users of the system.
MOTECH Architecture Overview¶
MOTECH consists of the core platform and several modules, each providing use of a technology such as SMS or email, or access to an external system such as CommCare. Organizations can choose to install one or more modules, and developers can extend MOTECH by writing new modules. MOTECH is written in Java. It depends on open source systems including Apache Tomcat, Apache ActiveMQ, and Quartz. For more information about MOTECH architecture, see Core Architecture and Modules Architecture.
What can MOTECH do?¶
The MOTECH Platform can be used for setting appointments, tracking any scheduled activity, and managing workers deployed in the field. Its initial implementations have been for mHealth projects that improve health by sending messages to patients and caregivers based on an evaluation of the recommended schedule of care compared to the patient’s health-related actions. Some features of typical MOTECH-based applications are:
Communicate information to patients via voice or SMS according to a schedule of care defined for the patient’s condition, e.g.:
- Reminders for ANC appointments, lab visits, etc.
- Reminders to take medication on schedule, e.g., DOTS, ART, etc.
- Reminder notices to take children for scheduled immunization services
Collect data from patients or caregivers, e.g.:
- Patients report their symptoms prior to treatment or during treatment (adverse events)
- Patients give feedback on service delivery
- Caregivers report what service was delivered to a patient and on what date
Alert caregivers of the status of their patients, e.g.:
- Notify Community Health Worker when patient has not taken ART, DOTS or other drugs
- Notify nurse when patient has not kept a scheduled appointment (e.g., ANC visit)
Facilitate communication between patients, caregivers, and/or health administrators, e.g.:
- Establish secure peer networks for patients who share similar health concerns
- Initiate conversations between patients and caregivers in a way that allows the caregiver to manage the workload effectively
Creating Applications¶
This section is intended to help implementers of MOTECH get started creating custom solutions. The topics below cover some of the common features that need to be configured for a MOTECH app.
As the platform matures, most of the features below will be usable by implementers without developing any software code. As of now, a number of these features do require some coding in order to use (the topics below provide sample code where appropriate).
Introduction¶
Motech provides Maven archetypes in its Nexus repository which you can use to create a new Motech module. The archetypes supply basic source code needed for a new module, as well as configuration files for packaging the module as a bundle to be loaded into a Motech server.
The first archetype is the minimal bundle archetype. This supplies just enough source code and configuration to make a “Hello World” module.
- Additional archetypes can add functionality to the minimal archetype:
- The http bundle archetype adds a servlet to respond to HTTP requests, and a simple web user interface.
- The repository bundle archetype adds a repository layer for storing and retrieving data from MOTECH’s data services.
- The settings bundle archetype adds a properties file to store custom module configuration, and exposes the configuration through Motech’s web user interface
Any combination of these additional archetypes may be added to the minimal archetype.
Minimal Bundle Archetype¶
To create a new minimal bundle from the minimal bundle archetype, use the following command:
mvn archetype:generate -DinteractiveMode=false -DarchetypeRepository=http://nexus.motechproject.org/content/repositories/releases -DarchetypeGroupId=org.motechproject -DarchetypeArtifactId=minimal-bundle-archetype -DarchetypeVersion=0.24-SNAPSHOT -DgroupId=org.motechproject -DartifactId=motech-test-module -Dpackage=archetype.test -Dversion=0.1-SNAPSHOT -DbundleName="Archetype Test Module"
This will create a new Maven project in your current directory.
This is a long command. Here is an explanation of the parameters:
parameter | value | explanation |
---|---|---|
-DinteractiveMode | false | no need to wait for user input |
-DarchetypeRepository | http://nexus.motechproject.org/content/repositories/releases | where to find the archetype |
-DarchetypeGroupId | org.motechproject | group name for the archetype |
-DarchetypeArtifactId | minimal-bundle-archetype | which archetype to use |
-DarchetypeVersion | 0.24-SNAPSHOT | Motech version to use with the new module |
-DgroupId | org.motechproject | group name for the new module |
-DartifactId | motech-test-module | artifact name for the new module |
-Dpackage | archetype.test | Java package for new module classes |
-Dversion | 0.1-SNAPSHOT | version of the new module itself |
-DbundleName | “Archetype Test Module” | name of the new module |
HTTP Bundle Archetype¶
To create a new bundle that has HTTP support, use the following two commands from the same directory.
Create a minimal bundle with configuration modified for HTTP:
mvn archetype:generate -DinteractiveMode=false -DarchetypeRepository=http://nexus.motechproject.org/content/repositories/releases -DarchetypeGroupId=org.motechproject -DarchetypeArtifactId=minimal-bundle-archetype -DarchetypeVersion=0.24-SNAPSHOT -DgroupId=org.motechproject -DartifactId=motech-test-module -Dpackage=archetype.test -Dversion=0.1-SNAPSHOT -DbundleName="Archetype Test Module" -Dhttp=true
Note the new parameter:
-Dhttp | true |
Add new source files from the HTTP archetype:
mvn archetype:generate -DinteractiveMode=false -DarchetypeRepository=http://nexus.motechproject.org/content/repositories/releases -DarchetypeGroupId=org.motechproject -DarchetypeArtifactId=http-bundle-archetype -DarchetypeVersion=0.24-SNAPSHOT -DgroupId=org.motechproject -DartifactId=motech-test-module -Dpackage=archetype.test -Dversion=0.1-SNAPSHOT -DbundleName="Archetype Test Module"
Note the new archetype Id:
-DarchetypeArtifactId | http-bundle-archetype |
Repository Bundle Archetype¶
To create a new bundle that has support for MOTECH’s data services, use the following two commands from the same directory.
Create a minimal bundle with configuration modified for repository:
mvn archetype:generate -DinteractiveMode=false -DarchetypeRepository=http://nexus.motechproject.org/content/repositories/releases -DarchetypeGroupId=org.motechproject -DarchetypeArtifactId=minimal-bundle-archetype -DarchetypeVersion=0.24-SNAPSHOT -DgroupId=org.motechproject -DartifactId=motech-test-module -Dpackage=archetype.test -Dversion=0.1-SNAPSHOT -DbundleName="Archetype Test Module" -Drepository=true
Add new source files from the repository archetype:
mvn archetype:generate -DinteractiveMode=false -DarchetypeRepository=http://nexus.motechproject.org/content/repositories/releases -DarchetypeGroupId=org.motechproject -DarchetypeArtifactId=repository-bundle-archetype -DarchetypeVersion=0.24-SNAPSHOT -DgroupId=org.motechproject -DartifactId=motech-test-module -Dpackage=archetype.test -Dversion=0.1-SNAPSHOT -DbundleName="Archetype Test Module"
Settings Bundle Archetype¶
To create a new bundle that has module settings support, use the following two commands from the same directory.
Create a minimal bundle with configuration modified for settings:
mvn archetype:generate -DinteractiveMode=false -DarchetypeRepository=http://nexus.motechproject.org/content/repositories/releases -DarchetypeGroupId=org.motechproject -DarchetypeArtifactId=minimal-bundle-archetype -DarchetypeVersion=0.24-SNAPSHOT -DgroupId=org.motechproject -DartifactId=motech-test-module -Dpackage=archetype.test -Dversion=0.1-SNAPSHOT -DbundleName="Archetype Test Module" -Dsettings=true
Add new source files from the settings archetype:
mvn archetype:generate -DinteractiveMode=false -DarchetypeRepository=http://nexus.motechproject.org/content/repositories/releases -DarchetypeGroupId=org.motechproject -DarchetypeArtifactId=settings-bundle-archetype -DarchetypeVersion=0.24-SNAPSHOT -DgroupId=org.motechproject -DartifactId=motech-test-module -Dpackage=archetype.test -Dversion=0.1-SNAPSHOT -DbundleName="Archetype Test Module"
Combined Bundle Archetype¶
The minimal bundle archetype can be supplemented with any combination of additional archetypes. To create a bundle that uses them all, use all the following commands from the same directory.
Create a minimal bundle with configuration modified for all additional archetypes:
mvn archetype:generate -DinteractiveMode=false -DarchetypeRepository=http://nexus.motechproject.org/content/repositories/releases -DarchetypeGroupId=org.motechproject -DarchetypeArtifactId=minimal-bundle-archetype -DarchetypeVersion=0.24-SNAPSHOT -DgroupId=org.motechproject -DartifactId=motech-test-module -Dpackage=archetype.test -Dversion=0.1-SNAPSHOT -DbundleName="Archetype Test Module" -Dhttp=true -Drepository=true -Dsettings=true
Add source files from all the additional archetypes:
mvn archetype:generate -DinteractiveMode=false -DarchetypeRepository=http://nexus.motechproject.org/content/repositories/releases -DarchetypeGroupId=org.motechproject -DarchetypeArtifactId=http-bundle-archetype -DarchetypeVersion=0.24-SNAPSHOT -DgroupId=org.motechproject -DartifactId=motech-test-module -Dpackage=archetype.test -Dversion=0.1-SNAPSHOT -DbundleName="Archetype Test Module"
mvn archetype:generate -DinteractiveMode=false -DarchetypeRepository=http://nexus.motechproject.org/content/repositories/releases -DarchetypeGroupId=org.motechproject -DarchetypeArtifactId=repository-bundle-archetype -DarchetypeVersion=0.24-SNAPSHOT -DgroupId=org.motechproject -DartifactId=motech-test-module -Dpackage=archetype.test -Dversion=0.1-SNAPSHOT -DbundleName="Archetype Test Module"
mvn archetype:generate -DinteractiveMode=false -DarchetypeRepository=http://nexus.motechproject.org/content/repositories/releases -DarchetypeGroupId=org.motechproject -DarchetypeArtifactId=settings-bundle-archetype -DarchetypeVersion=0.24-SNAPSHOT -DgroupId=org.motechproject -DartifactId=motech-test-module -Dpackage=archetype.test -Dversion=0.1-SNAPSHOT -DbundleName="Archetype Test Module"
Using Archetypes Locally¶
You can also use the archetypes locally, without the Motech Nexus repository. First, you must build the archetypes locally. You can either follow the developer guidelines to set up your developer environemt, or to build locally without commiting:
git clone https://code.google.com/p/motech/
cd motech
mvn clean install
Then you can use the archetypes from your Maven local catalog:
mvn archetype:generate -DinteractiveMode=false -DarchetypeCatalog=local -DarchetypeGroupId=org.motechproject -DarchetypeArtifactId=minimal-bundle-archetype -DarchetypeVersion=0.24-SNAPSHOT -DgroupId=org.motechproject -DartifactId=motech-test-module -Dpackage=archetype.test -Dversion=0.1-SNAPSHOT -DbundleName="Archetype Test Module"
Note the new parameter:
-DarchetypeCatalog | local |
Installing and Upgrading MOTECH¶
There will be more text here.
Modeling Data with MOTECH Data Services¶
There will be more text here.
Javadoc¶
org.motechproject.mds.annotations
org.motechproject.mds.enhancer
org.motechproject.mds.repository
/org/motechproject/mds/web/package-index
Configuring Messaging: SMS¶
There will be more text here.
Configuring Messaging: IVR¶
There will be more text here.
Connecting MOTECH to OpenMRS¶
There will be more text here.
Integrating MOTECH with CommCare¶
There will be more text here.
Using the Tasks Module¶
There will be more text here.
Configuring Pill Reminders¶
There will be more text here.
Configuring Your MOTECH App to be HIPAA Compliant¶
There will be more text here.
MOTECH Mailing Lists¶
The mailing lists below are the best way to keep in touch with us. Please join the discussion!
MOTECH Developers¶
Mailing list for regular contributors to the MOTECH Platform source repository - used for design discussions and other issues impacting the developer community.
motech-dev@googlegroups.com | Join Dev List |
MOTECH Implementers¶
Mailing list for implementers and other users of MOTECH - used mostly for communication related to releases. Traffic is moderated and very low volume.
motech-implementers@googlegroups.com | Join Implementers List |
Architecture and Technical Overviews¶
Core Architecture¶
Architecture Overview¶
MOTECH can logically be broken into the core platform and modules. The core platform wraps several well-known open source systems, and augments and exposes their features to the other components. The main functions of the core are to wrap ActiveMQ (which provides the message queue) and present an internal pub/sub like event interface to the module and implementation layers. The core also provides a module loading environment (OSGi), an interface to the Scheduler, and access to the database.
Modules within MOTECH are self-contained bits of functionality that are loaded into the server via the OSGi host. Typically a module provides one type of functionality, such as SMS or access to an external health system. For more information, see Modules Architecture. For a list of current and planned modules, see Modules.
MOTECH is designed to be horizontally scalable with multiple MOTECHs all acting as workers connecting to the same message queue.
Design Philosophy¶
Stateless¶
A core design principle of the MOTECH platform is that the server should be stateless across requests to allow for horizontal scalability. It is expected that code running within the MOTECH server should perform a single action per request and then return. The module should never persist any state in memory or local disk and expect that state to be available to later requests.
Events¶
To aid in the development of stateless services, the MOTECH engine provides a pub/sub like event system. (The event system follows the publish-subscribe pattern but does not implement the standard Java pub/sub protocol.) It helps to decouple emitters of events from the modules that wish to consume them. Any module can emit an event by calling the EventRelay and passing it a MotechEvent and a subject. To register for an event, a module just needs to annotate a method with the list of event subjects of interest.
For more information, see Event and Scheduler Architecture.
Scheduled Events & Timers¶
To assist in the development of a stateless event-based server, the MOTECH platform provides access to a flexible scheduling system. Using the open source Quartz engine, MOTECH can easily schedule events for future consumption. For more information, see Event and Scheduler Architecture.
Subsystems¶
Tasks System¶
The Tasks system allows you to connect modules without code by using tasks. Each task consists of three parts:
- Trigger: an event raised by Module A (or the Scheduler)
- Filter: a conditional statement specifying whether the task should run
- Action: an action executed by Module B in response
In between the trigger and the action, tasks may use data loaders to look up data from other modules that are registered as data sources.
Data Services¶
MOTECH Data Services is a flexible data modeling system that allows users to define and share custom schemas without code, and provides auditing and revision tracking. It is a JDBC-based user configurable database abstraction layer on top of a standard SQL database. It provides generated POJOs and OSGi service interfaces for the data objects, generated CRUD events, and generated user interface for data browsing and editing. In a future release it will also support auto-generation of REST APIs.
Dependencies on Third-Party Systems¶
Quartz Scheduler¶
Quartz is an open source job scheduling engine that enables MOTECH modules to schedule events for future consumption.
Tomcat¶
Apache Tomcat provides the application container for MOTECH.
ActiveMQ¶
Apache ActiveMQ is an open source message broker that provides the message queue.
OSGi¶
Each MOTECH module is an OSGi bundle. Using OSGi allows the platform to manage the bundle lifecycle (adding, removing, starting, and stopping modules), and allows modules to expose service interfaces. For more information, see Modules Architecture.
Event and Scheduler Architecture¶
Event Handling and Scheduling among Modules¶
The following diagram provides three examples of Motech modules:
Motech module A publishes events, schedules new jobs and listens for events. An example of a Motech platform that has these three responsibilities is the Message Campaign module.
Motech module B schedules new jobs.
Motech module C listens to events of subject X and Y: listener X listens to events of subject X, and listener Y listens to events of subject Y.
Event Handling and Scheduling Architecture¶
To schedule a job in MOTECH, the core platform exposes the MotechSchedulerService. Clients of the service have an instance of it injected into the class that uses it. This service employs Quartz to schedule MotechScheduledJobs. When triggered, MotechScheduledJobs raise events that are sent through an event relay to the event queue. These messages are dequeued and then received by a consumer, the event listener registry, which in turn discovers all of the listeners on the event and invokes the appropriate method that was listening on that event.
Notes¶
- The scheduler service retrieves the Quartz Scheduler from the SchedulerFactoryBean. The service can only schedule MotechScheduledJobs, which all must include a MotechEvent.
- When the trigger for the scheduled job is satisfied, the job is executed and the accompanying Motech event is sent to the SchedulerFireEventGateway interface. This gateway is defined in schedulerFiredEventChannelAdapter.xml and a proxy is generated by Spring at runtime.
- The SchedulerFireEventGateway serves as an outbound message gateway to shuttle messages to the event relay, which then sends JMS messages to the event queue.
- The event queue dequeues messages and routes them to the event listener registry. The core platform has one consumer for events, a channel that routes messages to an event listener registry.
- The event listener registry retrieves the listeners that are listening on the motech event it is relaying (listening is based on the value bound to the motech event’s subject key).
- The core platform scans new bundles for any method annotated as a MotechListener, and registers those methods with the listener registry.
- If the event has a specific destination or only one listener, the listener’s handle method is called. This will invoke the method that was annotated as a MotechListener. These listener classes can be project specific and will reside outside of the core platform.
- If the event has multiple listeners, a separate event is raised for each listener. The original event object is not handled by a listener in this case.
- The EventListener’s handle method will invoke the method that was annotated as a MotechListener. The MotechEvent will be passed to that method as a parameter.
Modules Architecture¶
Modules within MOTECH are self-contained bundles of functionality that are loaded into the server via the OSGi host. Modules interact with the core platform through its APIs and with other modules, either through their APIs or by consuming their events. Modules can expose service interfaces of their own as well as emit their own events. Modules may also register servlet controllers, which allow them to respond to HTTP requests.
Through MOTECH Data Services, a modules may expose entities from its data model. This allows a module to provide a data editor, REST APIs, record-level security, and field-level auditing. Via the Tasks system, modules can expose triggers, data and actions to be orchestrated by other modules.
See Modules for the list of current and planned modules.
Reasons to create a module include developing application-specific UI, business logic, and data models. Another reason is to develop generic reusable functionality to share with the MOTECH community.
Data Services Architecture¶
There will be text here.
Security Model¶
There will be text here.
Modules¶
Alerts¶
Collects alerts for users in an inbox-like container
Appointments¶
Provides appointment scheduling and reminding
Call Flow¶
Manages the sequence of greetings and prompts for an Interactive Voice Response (IVR) call
CMS Lite¶
Provides basic content storage and retrieval
CommCare¶
Integrates the MOTECH platform with CommCareHQ, an open-source platform to help manage community health workers
Data Services¶
Integrates data from external data sources and provides sharable data schemas
Decision Tree[Deprecated]¶
Provides APIs for constructing an IVR decision tree
Event Aggregation¶
Groups common events and republishes them as a single event at a specified time
Event Logging¶
Allows MOTECH modules to easily see each others’ events
IVR¶
Integrates the MOTECH platform with Interactive Voice Response (IVR) services
IVR Asterisk¶
Connects the MOTECH platform IVR with an Asterisk server using the VoiceGlue VoiceXML browser
IVR Kookoo¶
Integrates the MOTECH platform with Kookoo’s hosted IVR service
IVR Verboice¶
Integrates the MOTECH platform with Verboice’s hosted IVR service
IVR Voxeo¶
Integrates the MOTECH platform with Voxeo’s hosted IVR service
Message Campaign¶
Enrolls users in message campaigns with flexible content-scheduling rules
Metrics¶
Displays web site metrics using logging and the open source tools StatsD and Graphite
Mobile Forms¶
Supports configurable forms and data collection through mobile devices that support the OpenXData format
MRS (Medical Record System)¶
Provides a basic specification for integrating the platform with a medical record system
OpenMRS¶
Integrates the MOTECH platform with OpenMRS, an open source electronic medical record platform
Outbox¶
A voicemail-like messaging system for end users
Pill Reminder¶
A flexible reminder system focused on medication
Schedule Tracking¶
Enrolls users for alerts based on complex scheduling rules
SMS¶
Provides a basic specification for integrating the MOTECH platform with an SMS provider to send/receive SMS messages
Developing the MOTECH Platform¶
This section of the documentation is aimed at developers and maintainers of the MOTECH Platform. These docs help MOTECH devs get up and running, from configuring a machine, to getting the code, and committing and reviewing changes. If you find any errors in the topics below, or you have any other questions about MOTECH development, please contact us via the mailing list.
Setting up a Development Environment¶
The topics below will walk you through installing MOTECH on a Mac or Linux machine. Note that the Docker-based setup is much faster than the “official” method but the instructions are in beta. If you have any trouble with either approach, please feel free to contact us via motech-dev@googlegroups.com.
Installing MOTECH for Developers (“Official” Method)¶
Table of Contents
Installing on Ubuntu¶
The versions below may change, most likely the latest stable release will work for your purposes. If they do not, please feel free to send in feedback.
- Install Ubuntu Desktop 12.04.2 LTS 64bit
-
Note
64-bit is required for Motech’s installation
Install Maven, Git, Curl, Activemq, and mysql
In terminal, type
sudo apt-get install curl git maven activemq mysql-server
On a fresh Ubuntu installation, you may need to run the following first
sudo apt-get update
Configure ActiveMQ
Run the following
sudo ln -s /etc/activemq/instances-available/main /etc/activemq/instances-enabled/main
Note
For ActiveMQ scheduled delivery to work, you must set the attribute: schedulerSupport=”true” for the broker element in your activemq.xml config file. This file should be located at (active-mq-folder)/conf/activemq.xml.See ActiveMQ docs.
Install JDK 7
Go to The Java JDK Download Page
Accept License Agreement
Click on jdk-7u51-linux-x64.tar.gz (or latest stable version)
Extract the file into your home directory, ie: /home/*<user>*/jdk1.7.0_51
Set the proper Java environment and change maven options:
Start a new terminal session
Edit your .profile file
nano ~/.profile
append the following at the end of the file:
export PATH="$HOME/jdk1.7.0_21/bin:$PATH" export JAVA_HOME=$HOME/jdk1.7.0_21 export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m"
Save the changes (Ctrl+X) and quit
Confirm the settings are right
Log out & log back in & start a new terminal
Type
java -version && env | grep MAVEN_OPTS
You should see something like:
java version "1.7.0_51" Java(TM) SE Runtime Environment (build 1.7.0_51-b11) Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode) MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=128m
Install Tomcat7
Go to Tomcat’s download page
Under 7.0.52 (or the latest stable version) - Binary Distributions - Core, click on tar.gz
Once downloaded, expand the file to your home directory, i.e.: /home/*<user>*/apache-tomcat-7.0.52
Edit the tomcat-users.xml file (located under \etc\tomcat7\conf\) to add an admin user:
In the terminal type
nano ~/apache-tomcat-7.0.52/conf/tomcat-users.xml
Insert a line similar to the following before the closing </tomcat-users> tag:
<user username="*<username>*" password="*<password>*" roles="manager-gui"/>
Save the changes (Ctrl+X) then quit
Now edit ~/.bashrc to setup tomcat’s environment variable
nano ~/.bashrc
Append the following line:
export CATALINA_HOME=$HOME/apache-tomcat-7.0.52
Save the changes (Ctrl+X) then quit
Start a new terminal session or type
source ~/.bashrc
Install CouchDB
Download the latest stable sources from http://couchdb.apache.org and then follow the instructions in the INSTALL.Unix file.
For Ubuntu 13.10, just run:
sudo apt-get install couchdb
Once this is done, navigate to http://localhost:5984 to verify that the installation completed successfully.
{"couchdb":"Welcome","uuid":"52068def93b82a2653dcf352a4f9273a","version":"1.4.0","vendor":{"version":"1.4.0","name":"The Apache Software Foundation"}}
Install CouchDB-Lucene
Follow these instructions also be sure to follow the proxy handler instructions
Once the proxy has been configured, restart couchdb with:
sudo service couchdb restart
After restarting couchdb, navigate to http://localhost:5984/_fti and you should see something like this:
{"couchdb-lucene":"Welcome","version":"0.10.0-SNAPSHOT"}
Setup MySQL
In your motech source root directory, type in the terminal:
$ mysql -u root -p
then type:
sql> create database motechquartz; sql> create database motech_data_services; sql> create user 'quartz'@'localhost' identified by 'quartz2123'; sql> grant all privileges on motechquartz.* to 'quartz'@'localhost'; sql> exit;
then type:
mysql -u root -p motechquartz < modules/scheduler/scheduler/sql/create_db_schema_quartz_v2.1.sql
- Start Tomcat
In terminal, type:
~/apache-tomcat-7.0.52/bin/catalina.sh jpda start
You should see messages similar to:
Using CATALINA_BASE: /home/*<user>*/apache-tomcat-7.0.52 Using CATALINA_HOME: /home/*<user>*/apache-tomcat-7.0.52 Using CATALINA_TMPDIR: /home/*<user>*/apache-tomcat-7.0.52/temp Using JRE_HOME: /home/*<user>*/jdk1.7.0_51 Using CLASSPATH: /home/*<user>*/apache-tomcat-7.0.52/bin/bootstrap.jar:/home/*<user>*/...
You can also confirm tomcat was started by going to http://localhost:8080 in a browser
Jump to the Building and Installing MOTECH section to install MOTECH
Installing on a Macintosh¶
Installing Prerequisites for MOTECH
Installing HomeBrew
To install Homebrew, run the following in the terminal
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
- Use Homebrew to install git, erlang, ActiveMQ, and Apache Tomcat:
brew install git brew install activemq brew install tomcat brew install maven
Homebrew installations are located in /usr/local/Cellar` with symlinks in ``/usr/local/bin, which should already be part of your $PATH environment variable.
Note
Homebrew provides instructions about how to run these applications, as well as how to have launchd start them automatically on system startup.
Configuring Tomcat:
Edit the tomcat-users.xml file to add an admin user. Insert a line similar to the following before the closing </tomcat-users> tag:
<user username="motech" password="motech" roles="manager-gui"/>
Installing JDK 7:
Mac OS includes JDK6 by default, however JDK 7 is required for MOTECH. Use these instructions to install the latest version of the JDK.
Installing MySQL:
Before installing MySQL, you will need Xcode from the App Store. This can take a while; it’s a big download.
Next start Xcode from the Launchpad (rocketship icon in the dock) and select Install. Then you can quit Xcode; you don’t need to keep it running.
Note
(Command Line Tools using Xcode are included in OS X Mavericks, but not previous OS versions. If you are running Mountain Lion, you can follow these instructions: http://blog.mclaughlinsoftware.com/2012/12/10/mountain-lion-pre-mysql/)
Go to http://dev.mysql.com/downloads/mysql/ and download the appropriate DMG archive. Open it, double-click on the installer, and follow directions.
Once mysql has finished installing, double-click the MySQL preferences pane in the DMG and follow instructions. For more details see ‘these instructions’_ .
Note
Homebrew can be used to install MySQL, however Homebrew will not install the Mysql System Preferences control panel.
Setting up Symbolic Link and Environment Variables
Create a symbolic link from the Tomcat directory (Homebrew installs into /usr/local/Cellar/tomcat/<version number>/libexec) to /usr/local/tomcat:
ln -s /usr/local/Cellar/tomcat/`brew info tomcat | grep stable | awk '{print $3}' | sed 's/,//'`/libexec /usr/local/tomcat
Edit your ~/.bash_profile to set environment variables (catalina is Tomcat):
export JAVA_HOME="/Library/Java/Home" export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m" export CATALINA_HOME="/usr/local/tomcat" export CATALINA_OPTS="-Xms1024m -Xmx2048m -XX:MaxPermSize=1024m" export PATH=/usr/local/mysql/bin:$PATH
- When you’re done editing:
source ~/.bash_profile
Jump to the Building and Installing MOTECH section to install MOTECH
Building and Installing MOTECH¶
Getting the MOTECH code
Building MOTECH
Assuming you issued the git clone command in your home directory root, in the terminal
$ cd ~/motech $ mvn install
b.) It takes some time to build MOTECH, but eventually you should see:
[INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 29:19.284s [INFO] Finished at: Fri Jun 07 12:12:43 PDT 2013 [INFO] Final Memory: 152M/378M [INFO] ------------------------------------------------------------------------
Note
Should you get a java.lang.OutOfMemoryError exception, it may be because you forgot to set MAVEN_OPT as described in [3.5]. But you may need to increase -Xmx. So something like -Xmx1024m might work.
Install MOTECH
In a browser, go to http://localhost:8080
Click on Manager App
Type the user/password you used in tomcat-users.xml
temporary hack you need to remove ~/.motech/config/motech-settings.conf to allow the create initial user wizard.
In the Tomcat Web Application Manager, scroll down to the Deploy section and the WAR file to deploy subsection, click on Browseand select or navigate to ~/motech/platform/server/target/motech-platform-server.war then click on Deploy
Depending on your machine it could take a while for motech-platform-server to deploy
In the Tomcat Web Application Manager page, click on /motech-platform-server, you get the MOTECH initial user screen
Installing the IDE, Intellij IDEA Community Edition & open MOTECH project¶
Go to the Jetbrains home page and click on Download Now in the Community Edition box, then expand the file to your home directory.
From a terminal, assuming you extracted IntelliJ to ~/idea-IC-129.713, start IntelliJ
$ ~/idea-IC-129.713/bin/idea.shSelect Import Project
![]()
Select ~/motech/pom.xml, a dialog box will appear. Set the options as shown:
Click Next
In Select Profiles, do not select any profile, click Next
In Select Maven projects to Import, there should only be one project: org.motechproject:motech:0.20-SNAPSHOT, click Next
In Please select project SDK, if the 1.7.0_21 is present, select it, otherwise add it:
Click +
Select JDK
Select /home/frank/jdk1.7.0_21, then click OK
Click Next
Click Finish
Background processes will take a long time
You can also create a menu launcher, so you can start IntelliJ from the gui:
From the Tools menu select Create Desktop Entry
A IntelliJ menu item will be created in the Development application group
Debug demo module in IntelliJ
Start IntelliJ (from the command line, or from launcher icon if you created one)
It’ll automatically open the motech project (if it was the last project you worked on)
From the Run menu select Edit Configurations
Click on the green +
Select Remote
Give a name to your Run/Debug configuration and change the port to 8000 as:
Hit OK
Set a breakpoint somewhere in the demo module code, i.e.:
From the Run menu, select Debug ‘Tomcat’ where Tomcat is the name of your configuration.
In the browser go to the place that will hit the breakpoint, i.e.: if you setup a breakpoint as in the previous screen, then in the Demo module, click the Decision Trees tab, and you should hit the breakpoint!
Installing MOTECH Using Docker (“Beta”)¶
Note
These instructions assume you’re running on Ubuntu. This setup is also possible on Mac OSX but the steps are slightly different. We hope to provide OSX instructions in future.
This document provides instructions for creating a MOTECH environment using Docker containers. These instructions are “in beta” (the official installation guide is still the one here), but many members of the MOTECH dev team have been following this approach with success. This installation method is much faster than the official route.
There are two supported ways to install MOTECH with Docker:
- As an implementer - follow this approach if you want to install a released version of MOTECH.
- As a developer - follow this approach if you will be developing MOTECH and want to build the platform and modules from source code.
Get Docker, Fig and motech-docker¶
Whether you’re installing as an implementer or a developer, you’ll need Docker and Fig:
Docker¶
Follow the instructions on the Docker website to get the latest version of Docker.
Execute the following to configure Docker to work for non-root users:
sudo groupadd docker sudo gpasswd -a ${USER} docker (logout and re-login) sudo service docker restart
Fig¶
Execute the following to install Fig:
sudo apt-get install python-pip python-dev build-essential
sudo pip install -U fig
motech-docker¶
Clone the motech-docker project from GitHub or download it as a zip file and extract it. You’ll need to run all Fig commands from the motech-docker directory.
Implementer Setup¶
Go to your motech-docker directory. To setup as an implementer (everything is automagically installed):
./setup_as_imp.sh
Type the following to start MOTECH in the background:
fig up -d
Voila! MOTECH has started. Wait a little bit (about 30s) then direct your browser to: http://localhost:8080/motech-platform-server
Note
‘fig up’ ERASES ALL YOUR DATA (well not really all, but pretend it does). You have to run it at least once to setup MOTECH. If you run it again, it’ll erase everything you did in MOTECH. It’s useful to start afresh, but remember: it nukes everything!
Developer Setup¶
Go to your motech-docker directory. To setup as a dev:
./setup_as_dev.sh
Type the following to start all the pieces that MOTECH needs to run in the background:
fig up -d
Once you start the containers with the fig up -d command above and before you build MOTECH for the first time, you need to copy the MOTECH binaries into the container’s /root/.motech/bundles directory.
Conveniently, the container’s /root/.motech/bundles directory is exposed as the docker-motech-bundles directory (with a-rw access) in your home directory (also note that the container’s /root/.motech/config dir is also exposed as ~/docker-motech-config). So, you can either manually copy the necessary binaries, or you can create a symbolic link to ~/docker-motech-bundles from ~/.motech/bundles.
Assuming the latter, and that you never built MOTECH before, you’d run the following commands:
# go to your home dir
cd
# create the .motech dir
mkdir .motech
# create the symlink
ln -s ~/docker-motech-bundles .motech/bundles
If you built MOTECH before, you can just delete the bundles directory and create the symlink using the command above.
Build, deploy and run MOTECH: see :doc:dev_install.
Configuring MOTECH¶
There will be more text here. This doc may belong in “Setting up a Development Environment” or in “Getting Started”.
Developing and Submitting a Patch¶
We use a web-based code review system called Gerrit. Using this system, anyone can comment on a proposed change before it is merged to our Git repository. It’s pretty easy to use; the instructions below will get you started.
Create a Gerrit Account¶
- Navigate to http://review.motechproject.org/
- Click sign in on top-right
- Select Open ID provider (only Google accounts are enabled)
- Select user name
- Upload your SSH public key
Configuring Your Git Client to Use Gerrit¶
Follow these steps once for each MOTECH code repository that you clone.
Get source code
git clone ssh://<userid>@review.motechproject.org:29418/motech
Set up review branch
cd motech git config remote.origin.push refs/heads/*:refs/for/*
Install change-id generation hook
scp -p -P 29418 <userid>@review.motechproject.org:hooks/commit-msg .git/hooks/
Development Workflow¶
Checkout to feature branch
git checkout -b newfeature
Make changes/test/multiple commits
When ready to submit changes: update master, squash commits and merge feature branch
git checkout master && git pull --rebase git merge --squash newfeature git gui
Edit commit message using the proper commit message format
Push changes
git push origin
Submitting Changes (Patch Set) to Incorporate Review Comments¶
If you’ve received some code review feedback and you’d like to make some changes, follow the steps below to add your changes as a new “patch set” to the existing Gerrit code review.
- Checkout patch from gerrit change:
- Navigate to http://review.motechproject.org/#/c/<change id>/
- Copy pull url under patch set section and run
Make changes
Copy change ID from Gerrit (top section in Gerrit change page)
Amend change ID in commit message
Push changes
Pushing to Remote Branches (Not for Review)¶
This practice enables developers to share in-progress feature work with others without actually submitting the changes for review.
Use branch namespace dev
git checkout -b dev/newfeature git add . && git commit -m "message" git push -u origin dev/newfeature:dev/newfeature
Once done with feature, squash commits and merge with master. Submit for review as mentioned above.
MOTECH Code Repositories¶
Each repository can be cloned from either GitHub/Google Code or Gerrit. If you’re only interested in a copy of the code and will not be contributing, use the GitHub repo (no sign-in required). Otherwise use the Gerrit repo (sign-in required) where each commit will trigger a Jenkins build and be submitted for code review. Jenkins is our continuous integration (CI) system. Once your change is approved and merged by an authorized Gerrit reviewer, it will show up on the GitHub/Google Code repo.
MOTECH Platform¶
The platform repo contains the motech-platform-server Tomcat servlet. In addition it also contains the essential Admin, Config, Tasks, Motech Data Services, Email, and Scheduler modules.
Google Code Repository
git clone https://code.google.com/p/motech
Gerrit Repository
git clone ssh://<userid>@review.motechproject.org:29418/motech
MOTECH Modules¶
This repo is the home of all optional MOTECH modules.
GitHub Repository
git clone https://github.com/motech/modules
Gerrit Repository
git clone ssh://<userid>@review.motechproject.org:29418/modules
Commit Message Format¶
To ensure that our commit messages are both concise and informative, all MOTECH committers are asked to follow the git commit message format outlined below. For reference, Linus Torvalds provides a description of a good commit message here.
Format¶
- First line is the Jira issue ID + subject (max 50 chars)
- Leave a blank line (if not, the entire message is interpreted as subject)
- Summary (ensure it is wrapped to a reasonable number of characters, e.g. 72, because git log does not handle wrapping).
The description of the change should be both brief and informative. The Linux kernel documentation has this to say about good commit summaries:
...the “summary” must be no more than 70-75 characters, and it must describe both what the patch changes, as well as why the patch might be necessary. It is challenging to be both succinct and descriptive, but that is what a well-written summary should do.
Author/Committer¶
There is no need to include the names of the developers who developed the change in the subject line. If there is more than one person working on a change, the committer is asked to include the –author parameter in his/her git commit to specify the second person’s name.
Example¶
Here is an example of a MOTECH commit message:
MOTECH-678 Moves campaign modules to github
Disables pillreminder, message-campaign and scheduletracking modules from main pom.xml as they’ve moved to a new repo on github - https://github.com/motech/platform-campaigns
Change-Id: I5964249887160c868fa9598c413aebb93a49fa32
Coding Conventions¶
Text to come
Code Review Workflow and Checklist¶
Text to come
Authoring Documentation¶
This document provides information specific to setting up and authoring Sphinx documentation for MOTECH. The Sphinx Documentation Guide is also a good resource.
Each MOTECH repository contains a docs directory populated with reStructured Text (reST) files. These files are built by Sphinx and hosted at http://readthedocs.org. A Sphinx plugin, called Javasphinx, builds Javadoc for the MOTECH codebase.
Installing Sphinx and Javasphinx¶
If you are working on MOTECH documentation, it is helpful to build the docs locally and review changes in advance of checkin. The steps below will get your environment configured to build Sphinx docs.
Install python utils
sudo apt-get install python-setuptools
sudo apt-get install python-dev
sudo apt-get install python-pip
Install sphinx
sudo easy_install sphinx
Install javasphinx and motechjavasphinx
sudo apt-get install libxslt-dev
sudo apt-get install libxml2-dev
sudo apt-get install zlib1g-dev
cd docs
sudo pip install -r requirements.txt
Building Docs¶
ReadTheDocs.org automatically builds Sphinx projects, but it is a good idea to build your documents and make sure they render correctly before you push your changes up to the code repository.
To build Sphinx docs, go to the docs directory and type:
make html
You can then use a web browser to view docs/build/html/index.html and make sure everything looks good.
Authoring and Submitting New Documents¶
To create a new documentation topic, simply create a file with extension .rst under the docs directory. Create a table-of-contents entry for your new doc in the appropriate index.rst file. The reStructuredText Primer is good to have handy as you write your doc.
When your document is ready for review, follow the instructions for creating and submitting a patch to submit it for code review.
Project Management¶
There will be text here.
Release Strategy and Procedure¶
Text to come
Browser Compatibility¶
Text to come
Demos¶
Javadoc¶
org.motechproject.admin.domain¶
AdminSettings¶
- public class AdminSettings¶
AdminSettings class is used to store settings for Admin module and specifies that these settings are read-only (by checking config source from bootstrap)
NotificationRule¶
- public class NotificationRule¶
A notification rule persisted in the database. Represents a rule for sending out a single notification. Contains information about this notification’s recipient and the ActionType representing a method used for notifying the recipient.
Constructors¶
Methods¶
getActionType¶
- public ActionType getActionType()¶
matches¶
- public boolean matches(StatusMessage message)¶
setActionType¶
- public void setActionType(ActionType actionType)¶
QueueMBean¶
- public class QueueMBean¶
Represents a JMS queue. Holds information about the queue statistics.
Methods¶
StatusMessage¶
- public class StatusMessage¶
Represents a message displayed in the ‘messages’ section of the Admin UI. Persisted by MDS module. Apart from the message and its Level, contains also information about the module that sent the message. The timeout field represents the DateTime of the message expiration.
Constructors¶
Methods¶
org.motechproject.admin.messages¶
ActionType¶
- public enum ActionType¶
Represents an action which should be taken for a notification, in particular which message channel should be used to communicate the notification.
Enum Constants¶
EMAIL¶
- public static final ActionType EMAIL¶
SMS¶
- public static final ActionType SMS¶
Level¶
- public enum Level¶
Represents the level of a org.motechproject.admin.domain.StatusMessage, which is reflected on the UI. Posting a org.motechproject.admin.domain.StatusMessage with a CRITICAL level will trigger notifications.
org.motechproject.admin.service¶
NotificationRulesDataService¶
- public interface NotificationRulesDataService extends MotechDataService<NotificationRule>¶
MDS data service for NotificationRules.
StatusMessageService¶
- public interface StatusMessageService¶
Methods¶
getActiveMessages¶
- List<StatusMessage> getActiveMessages()¶
getAllMessages¶
- List<StatusMessage> getAllMessages()¶
getNotificationRules¶
- List<NotificationRule> getNotificationRules()¶
postMessage¶
- void postMessage(StatusMessage message)¶
removeMessage¶
- void removeMessage(StatusMessage message)¶
saveNotificationRules¶
- void saveNotificationRules(List<NotificationRule> notificationRules)¶
saveRule¶
- void saveRule(NotificationRule notificationRule)¶
StatusMessagesDataService¶
- public interface StatusMessagesDataService extends MotechDataService<StatusMessage>¶
MDS data service for StatusMessages.
org.motechproject.bundle.extender¶
MotechExtenderConfigFactory¶
- public class MotechExtenderConfigFactory implements FactoryBean<Properties>¶
Creates the extender configuration for Motech, currently only blueprint dependency wait time. In order to change the blueprint extender dependency wait time used during platform runtime, org.motechproject.blueprint.dependencies.waittime should be set with the wait time in milliseconds. The default blueprint timeout is 5 minutes.
Fields¶
MotechOsgiApplicationContextCreator¶
- public class MotechOsgiApplicationContextCreator implements OsgiApplicationContextCreator¶
MotechOsgiConfigurableApplicationContext¶
- public class MotechOsgiConfigurableApplicationContext extends OsgiBundleXmlApplicationContext implements ConfigurableWebApplicationContext¶
Constructors¶
Methods¶
getServletConfig¶
- public ServletConfig getServletConfig()¶
getServletContext¶
- public ServletContext getServletContext()¶
setServletConfig¶
- public void setServletConfig(ServletConfig servletConfig)¶
setServletContext¶
- public void setServletContext(ServletContext servletContext)¶
org.motechproject.commons.api¶
AbstractDataProvider¶
- public abstract class AbstractDataProvider extends MotechObject implements DataProvider¶
Methods¶
ApplicationContextServiceReferenceUtils¶
- public final class ApplicationContextServiceReferenceUtils¶
Methods¶
isNotValid¶
- public static boolean isNotValid(ServiceReference serviceReference)¶
isValid¶
- public static boolean isValid(ServiceReference serviceReference)¶
CsvConverter¶
- public final class CsvConverter¶
The CsvConverter class, provides methods responsible for conversion to CSV-formatted strings.
MotechEnumUtils¶
- public final class MotechEnumUtils¶
Misc enum-related helper functions
Methods¶
toEnumSet¶
toEnumSet¶
- public static <T extends Enum> Set<T> toEnumSet(Class<T> enumClass, String csv)¶
Returns a set of enums given a comma separated string and an enum class
Parameters: - enumClass – the enum class
- csv – a comma separated string representing a set of enum values
Returns: the enum set constructed from the given string
toString¶
MotechException¶
- public class MotechException extends RuntimeException¶
MotechMapUtils¶
- public final class MotechMapUtils¶
The MotechMapUtils class contains methods that allow modifications and operations on maps
Methods¶
asProperties¶
- public static Properties asProperties(Map<Object, Object> map)¶
Converts java.util.Map into java.util.Properties
Parameters: - map – Map to convert
Returns: Properties, created from given map
mergeMaps¶
- public static Map<Object, Object> mergeMaps(Map<Object, Object> overridingMap, Map<Object, Object> baseMap)¶
Null-safe merge of two maps. If both parameters are null it returns empty map. If one of the maps is null, it returns the other one. If a key is present in two maps, the value in the merged map will be taken from the overriding map.
Parameters: - overridingMap – The map overriding values in the base map
- baseMap – The base map
Returns: merged map
MotechObject¶
- public class MotechObject¶
LayerSupertype for entire motech project. Used optionally through the motech project.
Methods¶
SystemIdentityProvider¶
- public class SystemIdentityProvider implements IdentityProvider¶
org.motechproject.commons.api.json¶
org.motechproject.commons.api.model¶
org.motechproject.commons.couchdb.dao¶
BusinessIdNotUniqueException¶
- public class BusinessIdNotUniqueException extends RuntimeException¶
Constructors¶
org.motechproject.commons.couchdb.lucene.query¶
CouchDbLuceneQuery¶
- public class CouchDbLuceneQuery¶
Methods¶
build¶
- public StringBuilder build()¶
with¶
- public CouchDbLuceneQuery with(String field, String value)¶
withDate¶
- public CouchDbLuceneQuery withDate(String field, DateTime value)¶
withInt¶
- public CouchDbLuceneQuery withInt(String field, int value)¶
org.motechproject.commons.couchdb.model¶
org.motechproject.commons.couchdb.query¶
org.motechproject.commons.date¶
org.motechproject.commons.date.model¶
org.motechproject.commons.date.util¶
DateUtil¶
- public final class DateUtil¶
JodaFormatter¶
- public class JodaFormatter¶
Methods¶
formatPeriod¶
parse¶
- public Period parse(String intervalString, Locale locale)¶
Parse time interval in different units, eg: “1 year”
Parameters: - intervalString – time interval format number: integer unit : year, month, week, day, hour, minute, second (can use plural forms also) currently compound units like 1 year and 2 months are not supported
org.motechproject.commons.date.valueobjects¶
WallTimeUnit¶
- public enum WallTimeUnit¶
Enum Constants¶
Day¶
- public static final WallTimeUnit Day¶
Hour¶
- public static final WallTimeUnit Hour¶
Minute¶
- public static final WallTimeUnit Minute¶
Week¶
- public static final WallTimeUnit Week¶
org.motechproject.commons.sql.service¶
SqlDBManager¶
- public interface SqlDBManager¶
Classes inheriting this interface are responsible for getting sql properties from the bootstrap configuration.
Methods¶
getSqlProperties¶
- Properties getSqlProperties(Properties propertiesToUpdate)¶
org.motechproject.config.core¶
MotechConfigurationException¶
- public class MotechConfigurationException extends RuntimeException¶
The object of this class is thrown when there is a problem with reading the configuration from the predefined sources.
org.motechproject.config.core.constants¶
org.motechproject.config.core.domain¶
AbstractDBConfig¶
- public abstract class AbstractDBConfig¶
This abstract class encapsulates the database configuration, composed of as db url, username and password.
Constructors¶
BootstrapConfig¶
- public class BootstrapConfig¶
Represents the bootstrap configuration object. It is composed of:
- DBConfig - represents the database related bootstrap object.
- Tenant ID - represents the identifier of the tenant.
- Configuration source - represents the source of configuration (FILE / UI).
Fields¶
Constructors¶
BootstrapConfig¶
- public BootstrapConfig(DBConfig couchDbConfig, SQLDBConfig sqlConfig, String tenantId, ConfigSource configSource)¶
Parameters: - couchDbConfig –
- sqlConfig –
- tenantId –
- configSource –
Throws: - org.motechproject.config.core.MotechConfigurationException – if dbConfig is null.
Methods¶
getConfigSource¶
- public ConfigSource getConfigSource()¶
getSqlConfig¶
- public SQLDBConfig getSqlConfig()¶
ConfigLocation¶
- public class ConfigLocation¶
Defines a MOTECH configuration location. If the given location starts with a leading file separator character, the location is treated as a file system directory. Otherwise, it is treated as a classpath location.
Methods¶
getFile¶
- public File getFile(String fileName, FileAccessType accessType)¶
This method Returns the java.io.File object for the given file name relative to the config location. It also checks for the requested file accessibility. If the requested access type check is ConfigLocation.FileAccessType.READABLE, the file’s existence and readability will be checked. Similarly, if the requested access type check is ConfigLocation.FileAccessType.WRITABLE, then the write accessibility to the file will be checked. If the file does not exists, write accessibility of its ancestors will be checked.
Parameters: - fileName – Name of the file to be added to the config location.
- accessType – One of ConfigLocation.FileAccessType.READABLE or ConfigLocation.FileAccessType.WRITABLE.
Throws: - MotechConfigurationException – if the file is not readable or writable depending on the given access type.
Returns: File relative to the config location.
getUrlResource¶
- UrlResource getUrlResource()¶
toResource¶
ConfigLocation.FileAccessType¶
- public static enum FileAccessType¶
Defines the access check required.
Enum Constants¶
READABLE¶
- public static final ConfigLocation.FileAccessType READABLE¶
WRITABLE¶
- public static final ConfigLocation.FileAccessType WRITABLE¶
ConfigSource¶
- public final class ConfigSource¶
Represents the source from which MOTECH configuration should be read.
DBConfig¶
- public class DBConfig extends AbstractDBConfig¶
DBConfig encapsulates the database configuration, composed of as db url, username and password.
SQLDBConfig¶
- public class SQLDBConfig extends AbstractDBConfig¶
This class encapsulates the SQL database configuration, composed of as db url, username and password.
org.motechproject.config.core.filestore¶
ConfigLocationFileStore¶
- public class ConfigLocationFileStore¶
Used to read default platform config location(s) from config-location.properties and also to save in the file in the default location.
config-location.properties file will be loaded according to the behaviour of org.apache.commons.configuration.PropertiesConfiguration as specified here.
Constructors¶
org.motechproject.config.core.filters¶
org.motechproject.config.core.service¶
CoreConfigurationService¶
- public interface CoreConfigurationService¶
Loads and saves the core configuration required to start the Motech instance.
Methods¶
addConfigLocation¶
getConfigLocation¶
- ConfigLocation getConfigLocation()¶
Returns the config location where all the config files are present.
Returns: configLocation.
loadBootstrapConfig¶
- BootstrapConfig loadBootstrapConfig()¶
Loads the bootstrap configuration.
Returns: bootstrap configuration.
saveBootstrapConfig¶
- void saveBootstrapConfig(BootstrapConfig bootstrapConfig)¶
Saves the bootstrap configuration
Parameters: - bootstrapConfig – Bootstrap config
org.motechproject.config.domain¶
org.motechproject.config.monitor¶
org.motechproject.config.service¶
ConfigurationService¶
- public interface ConfigurationService¶
Central configuration service that monitors and manages configurations.
Methods¶
addOrUpdate¶
addOrUpdateModuleRecord¶
- void addOrUpdateModuleRecord(ModulePropertiesRecord record)¶
addOrUpdateModuleRecords¶
- void addOrUpdateModuleRecords(List<ModulePropertiesRecord> records)¶
addOrUpdateProperties¶
- void addOrUpdateProperties(String module, String version, String bundle, String filename, Properties newProperties, Properties defaultProperties)¶
Depending on the config source, it will either store properties in the DB or file. Only properties that are different from the default ones are stored. If the properties database record or file doesn’t exist yet for the given module, it will be created.
Parameters: - module – The module we wish to update properties for
- version – Version of updated bundle
- bundle – Symbolic name of updated bundle
- filename – Resource filename
- newProperties – New properties to store
- defaultProperties – Default properties of the module
Throws: - IOException – if module properties cannot be retrieved from file
createZipWithConfigFiles¶
- FileInputStream createZipWithConfigFiles(String propertyFile, String fileName)¶
Uses current configuration and default one to find changed properties and then connects them with annotations. Moreover creates file with non default configurations and packs is into the zip file.
Parameters: - propertyFile – name of exported file
Throws: - IOException –
Returns: FileInputStream that contains zip file
deleteByBundle¶
getAllModuleProperties¶
- Map<String, Properties> getAllModuleProperties(String module, Map<String, Properties> defaultProperties)¶
Retrieves all the module properties and returns them as Map, where key is the filename.
Parameters: - module – The module we wish to retrieve properties for
- defaultProperties – Default properties of the module
Throws: - IOException – if any of the module properties file cannot be read
Returns: Properties mapped by filename
getConfigSource¶
- ConfigSource getConfigSource()¶
This method allows to check whether MOTECH is currently running in the FILE or UI mode
Returns: Current Config Source
getModuleProperties¶
- Properties getModuleProperties(String module, String filename, Properties defaultProperties)¶
Retrieves merged properties, given default set. Depending on the ConfigSource, it will either merge default properties with the properties from DB or get properties from file.
Parameters: - module – The module we wish to retrieve properties for
- filename – Resource filename
- defaultProperties – Default properties of the module
Throws: - IOException – if module properties cannot be read from file
Returns: Merged properties of the certain module
getPlatformSettings¶
- MotechSettings getPlatformSettings()¶
getRawConfig¶
- InputStream getRawConfig(String module, String filename, Resource resource)¶
Allows to retrieve raw JSON data either from the database or file, depending on the specified ConfigSource mode.
Parameters: - module – Module we wish to retrieve raw data for
- filename – Resource filename
- resource – Resource file containing default rawConfig, in case no other has been found
Throws: - IOException –
Returns: Raw JSON data as InputStream
listRawConfigNames¶
- List<String> listRawConfigNames(String module)¶
Depending on the selected ConfigSource mode, this method looks for all registered raw data properties within the specified module.
Parameters: - module – Module we wish to perform look for
Returns: List of filenames that register raw config for specified module
loadBootstrapConfig¶
- BootstrapConfig loadBootstrapConfig()¶
Loads bootstrap config that is used to start up the Motech server.
The bootstrap configuration is loaded in the following order:
Load the configuration from bootstrap.properties from the config directory specified by the environment variable MOTECH_CONFIG_DIR. bootstrap.properties contains the following properties:
couchDb.url (Mandatory) couchDb.username (If required) couchDb.password (If required) sql.url (Mandatory) sql.username (If required) sql.password (If required) tenant.id (Optional. Defaults to 'DEFAULT') config.source (Optional. Defaults to 'UI')
An example bootstrap.properties is given below:
couchDb.url=http://localhost:5984 couchDb.username=motech couchDb.password=motech sql.url=jdbc:mysql://localhost:3306/ sql.username=motech sql.password=motech tenant.id=MotherChildCare config.source=FILE
If MOTECH_CONFIG_DIR environment variable is not set, load the specific configuration values from the following environment variables:
MOTECH_COUCHDB_URL (Mandatory) MOTECH_COUCHDB_USERNAME (If required) MOTECH_COUCHDB_PASSWORD (If required) MOTECH_SQL_URL (Mandatory) MOTECH_SQL_USERNAME (If required) MOTECH_SQL_PASSWORD (If required) MOTECH_TENANT_ID (Optional. Defaults to 'DEFAULT') MOTECH_CONFIG_SOURCE (Optional. Defaults to 'UI')
If MOTECH_DB_URL environment is not set, load the configuration from bootstrap.properties from the default MOTECH config directory specified in the file config-locations.properties.
Throws: - org.motechproject.config.core.MotechConfigurationException – if bootstrap configuration cannot be loaded.
Returns: Bootstrap configuration
loadConfig¶
- SettingsRecord loadConfig()¶
loadDefaultConfig¶
- SettingsRecord loadDefaultConfig()¶
processExistingConfigs¶
rawConfigExists¶
registersProperties¶
removeModuleRecords¶
- void removeModuleRecords(List<ModulePropertiesRecord> records)¶
removeProperties¶
retrieveRegisteredBundleNames¶
save¶
- void save(BootstrapConfig bootstrapConfig)¶
Saves the given BootstrapConfig in the bootstrap.properties file located in default MOTECH config location. The default motech config location is specified in the file config-locations.properties.
Parameters: - bootstrapConfig – Bootstrap configuration.
Throws: - org.motechproject.config.core.MotechConfigurationException – if bootstrap configuration cannot be saved.
savePlatformSettings¶
- void savePlatformSettings(Properties settings)¶
savePlatformSettings¶
- void savePlatformSettings(MotechSettings settings)¶
saveRawConfig¶
- void saveRawConfig(String module, String version, String bundle, String filename, InputStream rawData)¶
Allows persisting of raw json properties either in the database or file, depending on the selected ConfigSource mode.
Parameters: - module – Module we wish to save properties for
- filename – Resource filename
- rawData – Raw JSON data to persist
Throws: - IOException –
updateConfigLocation¶
updatePropertiesAfterReinstallation¶
- void updatePropertiesAfterReinstallation(String module, String version, String bundle, String filename, Properties defaultProperties, Properties newProperties)¶
Works similar to addOrUpdateProperties but instead of just adding / updating properties checks database for any deprecated properties and removes to ensure that only current ones are available
Parameters: - module – The module we wish to update properties for
- version – Version of updated bundle
- bundle – Symbolic name of updated bundle
- filename – Resource filename
- newProperties – New properties to store
- defaultProperties – Default properties of the module
Throws: - IOException – if module properties cannot be retrieved from file
ModulePropertiesService¶
- public interface ModulePropertiesService extends MotechDataService<ModulePropertiesRecord>¶
org.motechproject.email.builder¶
EmailRecordSearchCriteria¶
- public class EmailRecordSearchCriteria¶
The EmailRecordSearchCriteria class represents search criteria that may be used for searching org.motechproject.email.domain.EmailRecord entities in Motech Data Services. A consumer of this class may create search criteria to query on multiple fields by calling several of the with* methods. To perform the search, use org.motechproject.email.service.EmailAuditService.findEmailRecords(EmailRecordSearchCriteria).
Methods¶
getDeliveryStatuses¶
- public Set<DeliveryStatus> getDeliveryStatuses()¶
Gets the delivery statuses criterion.
Returns: the delivery statuses criterion for this search criteria
getDeliveryTimeRange¶
getFromAddress¶
getMessage¶
getQueryParams¶
- public QueryParams getQueryParams()¶
Gets the query paramaters that are used for controlling order and size of the query results for this search criteria.
Returns: the query params for this search criteria
getSubject¶
getToAddress¶
withDeliveryStatuses¶
- public EmailRecordSearchCriteria withDeliveryStatuses(Set<DeliveryStatus> deliveryStatuses)¶
Sets the delivery statuses criterion to the set specified
Parameters: - deliveryStatuses – the delivery statuses on which to search
Returns: this EmailRecordSearchCriteria with its deliveryStatuses criterion set to the provided statuses
withDeliveryStatuses¶
- public EmailRecordSearchCriteria withDeliveryStatuses(DeliveryStatus... deliveryStatuses)¶
Sets the delivery statuses criterion to the set specified
Parameters: - deliveryStatuses – the delivery statuses on which to search
Returns: this EmailRecordSearchCriteria with its deliveryStatuses criterion set to the provided statuses
withFromAddress¶
- public EmailRecordSearchCriteria withFromAddress(String fromAddress)¶
Sets the fromAddress criterion to the address specified
Parameters: - fromAddress – the sender email address on which to search
Returns: this EmailRecordSearchCriteria with its fromAddress criterion set to the provided address
withMessage¶
- public EmailRecordSearchCriteria withMessage(String message)¶
Sets the message criterion to the message specified
Parameters: - message – the email message body on which to search
Returns: this EmailRecordSearchCriteria with its message criterion set to the provided message
withMessageTime¶
- public EmailRecordSearchCriteria withMessageTime(DateTime deliveryTimeRange)¶
Sets the send time criterion to the time specified. Use this method to search on a specific date/time; if a range is needed, use withMessageTimeRange instead.
Parameters: - deliveryTimeRange – the specific time on which to search
Returns: this EmailRecordSearchCriteria with its deliveryTimeRange criterion set to the specified date/time
withMessageTimeRange¶
- public EmailRecordSearchCriteria withMessageTimeRange(Range<DateTime> deliveryTimeRange)¶
Sets the sent time criterion to the range specified. Use this method to search on a time range; if searching on a specific date/time is needed, use withMessageTime instead.
Parameters: - deliveryTimeRange – the date/time range on which to search
Returns: this EmailRecordSearchCriteria with its deliveryTimeRange criterion set to the specified date/time range
withQueryParams¶
- public EmailRecordSearchCriteria withQueryParams(QueryParams queryParams)¶
Sets the queryParams of the search criteria to the parameters specified. Use this method when it is necessary to specify order and size of query results. This is used mainly for paging/ordering queries from the UI.
Parameters: - queryParams – the query parameters to include with the search criteria
Returns: this EmailRecordSearchCriteria with its queryParams set to the provided parameters
withSubject¶
- public EmailRecordSearchCriteria withSubject(String subject)¶
Sets the subject criterion to the subject specified
Parameters: - subject – the subject on which to search
Returns: this EmailRecordSearchCriteria with its subject criterion set to the provided subject
withToAddress¶
- public EmailRecordSearchCriteria withToAddress(String toAddress)¶
Sets the toAddress criterion to the address specified
Parameters: - toAddress – the recipient email address on which to search
Returns: this EmailRecordSearchCriteria with its toAddress criterion set to the provided address
org.motechproject.email.contract¶
Mail¶
- public class Mail¶
The Mail class represents an email message.
Constructors¶
Mail¶
- public Mail(String fromAddress, String toAddress, String subject, String message)¶
Creates a new instance of Mail, with all fields set to the values specified in the parameters.
Parameters: - fromAddress – the email address of the sender
- toAddress – the email address of the recipient
- subject – the subject of the email
- message – the body of the email
Methods¶
equals¶
- public boolean equals(Object obj)¶
Indicates whether some other object is “equal to” this one. Returns true if this Mail and the object to compare have reference equality or their field values are all equal.
Parameters: - obj – The reference object with which to compare
Returns: true if this object is the same as the obj argument; false otherwise.
getFromAddress¶
getSubject¶
getToAddress¶
org.motechproject.email.domain¶
DeliveryStatus¶
- public enum DeliveryStatus¶
The DeliveryStatus Enum contains the possible delivery states for an email message.
Enum Constants¶
ERROR¶
- public static final DeliveryStatus ERROR¶
There was an error sending the message.
RECEIVED¶
- public static final DeliveryStatus RECEIVED¶
The message was received.
SENT¶
- public static final DeliveryStatus SENT¶
The message was sent.
EmailRecord¶
- public class EmailRecord¶
The EmailRecord class represents a record of a sent Email. This class is exposed as an org.motechproject.mds.annotations.Entity through Motech Data Services.
See also: org.motechproject.mds.annotations
Constructors¶
EmailRecord¶
- public EmailRecord()¶
Creates a new instance of EmailRecord, with all fields set to null.
EmailRecord¶
- public EmailRecord(String fromAddress, String toAddress, String subject, String message, DateTime deliveryTime, DeliveryStatus deliveryStatus)¶
Creates a new instance of EmailRecord, with all fields set to the values specified in the parameters.
Parameters: - fromAddress – the email address of the sender
- toAddress – the email address of the recipient
- subject – the subject of the email
- message – the body of the email
- deliveryTime – the date and time that the email was sent
- deliveryStatus – the delivery status of the email
Methods¶
equals¶
- public boolean equals(Object obj)¶
Indicates whether some other object is “equal to” this one. Returns true if this EmailRecord and the object to compare have reference equality or their field values are all equal.
Parameters: - obj – The reference object with which to compare.
Returns: true if this object is the same as the obj argument; false otherwise.
getDeliveryStatus¶
- public DeliveryStatus getDeliveryStatus()¶
Gets the delivery status.
Returns: the delivery status of the message
getDeliveryTime¶
getFromAddress¶
getSubject¶
getToAddress¶
hashCode¶
- public int hashCode()¶
Returns a hash code value for this EmailRecord object.
Returns: a hash code value for this EmailRecord object
setFromAddress¶
setMessage¶
setSubject¶
setToAddress¶
EmailRecordComparator¶
- public class EmailRecordComparator implements Comparator<EmailRecord>¶
The EmailRecordComparator class is an implementation of the Comparator interface, that allows callers to compare org.motechproject.email.domain.EmailRecord objects by a single field.
Constructors¶
EmailRecordComparator¶
- public EmailRecordComparator(Boolean ascending, String compareField)¶
Creates a new EmailRecordComparator that supports comparison based on the specified field.
Parameters: - ascending – boolean indicating whether comparisons should be ascending or descending
- compareField – the field for which comparisons should be performed
Methods¶
compare¶
- public int compare(EmailRecord o1, EmailRecord o2)¶
Compares its two arguments for order. If ascending is true, returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second. If ascending is false, returns a positive integer, zero, or negative integer as the first argument is less than, equal to, or greater than the second.
Parameters: - o1 – the first EmailRecord to be compared
- o2 – the second EmailRecord to be compared
Returns: a positive integer, zero, or negative integer indicating the result of comparing the objects
EmailRecords¶
- public class EmailRecords<T>¶
The EmailRecords class wraps the EmailRecord list and stores the current item count.
Constructors¶
EmailRecords¶
- public EmailRecords()¶
Creates a new instance of EmailRecords, which contains no records.
EmailRecords¶
- public EmailRecords(Integer totalRecords, Integer page, Integer totalPages, List<T> allRecords)¶
Creates a new instance of EmailRecords, with all fields set to the values specified in the parameters. The page and totalPages parameters are for the purposes of paginating the list of records in the UI.
Parameters: - totalRecords – the total number of records
- page – the current page
- totalPages – the total number of pages
- allRecords – the list of records
org.motechproject.email.service¶
EmailAuditService¶
- public interface EmailAuditService¶
The EmailAuditService interface provides methods for logging email activity, as well as searching and deleting the email logs.
Methods¶
countEmailRecords¶
- long countEmailRecords(EmailRecordSearchCriteria criteria)¶
Returns the count of EmailRecord entries matching the specified search criteria.
Returns: the count of email records matching the provided criteria
delete¶
- void delete(EmailRecord emailRecord)¶
Deletes the specified EmailRecord entry from the email log.
findAllEmailRecords¶
- List<EmailRecord> findAllEmailRecords()¶
Finds and returns all EmailRecord entries in the email log.
Returns: all email records in the email log
findById¶
- EmailRecord findById(long id)¶
Finds an EmailRecord in the log by ID.
Parameters: - id – the identifier of the record to find
Returns: the email record that matches the provided identifier, or null if no matching record exists
findEmailRecords¶
- List<EmailRecord> findEmailRecords(EmailRecordSearchCriteria criteria)¶
Finds and returns all EmailRecord entries matching the specified search criteria.
Returns: all email records matching the provided criteria
log¶
- void log(EmailRecord mailRecord)¶
Adds the provided EmailRecord to the email log.
Parameters: - mailRecord – the record to add to the email log
EmailRecordService¶
- public interface EmailRecordService extends MotechDataService<EmailRecord>¶
This service provides data access for org.motechproject.email.domain.EmailRecord. The implementation is generated by Motech Data Services and published as an OSGi service.
Methods¶
countFind¶
- long countFind(String fromAddress, String toAddress, String subject, String message, Range<DateTime> deliveryTimeRange, Set<DeliveryStatus> deliveryStatuses)¶
Returns the count of all EmailRecord entries matching the specified search parameters.
Parameters: - fromAddress – the sender address on which to search
- toAddress – the recipient address on which to search
- subject – the subject on which to search
- message – the message body on which to search
- deliveryTimeRange – the delivery time range on which to search
- deliveryStatuses – the delivery statuses on which to search
Returns: the count of EmailRecord entries that match the specified criteria
find¶
- List<EmailRecord> find(String fromAddress, String toAddress, String subject, String message, Range<DateTime> deliveryTimeRange, Set<DeliveryStatus> deliveryStatuses, QueryParams queryParams)¶
Finds and returns all EmailRecord entries matching the specified search parameters. This method is exposed as a org.motechproject.mds.annotations.Lookup through Motech Data Services.
Parameters: - fromAddress – the sender address on which to search
- toAddress – the recipient address on which to search
- subject – the subject on which to search
- message – the message body on which to search
- deliveryTimeRange – the delivery time range on which to search
- deliveryStatuses – the delivery statuses on which to search
- queryParams – the query parameters to include with the search criteria
Returns: the list of EmailRecord entries that match the specified criteria
See also: org.motechproject.mds.annotations
findByRecipientAddress¶
- List<EmailRecord> findByRecipientAddress(String recipientAddress)¶
Finds and returns all EmailRecord entries for the specified recipient address. This method is exposed as a org.motechproject.mds.annotations.Lookup through Motech Data Services.
Parameters: - recipientAddress – the recipient address on which to search
Returns: the list of EmailRecord entries that match the specified address
See also: org.motechproject.mds.annotations
EmailSenderService¶
- public interface EmailSenderService¶
The EmailSenderService interface provides a method for sending email.
Methods¶
send¶
- void send(Mail message)¶
Attempts to send the supplied email message. Adds an org.motechproject.email.domain.EmailRecord entry to the log with the details of the activity.
Parameters: - message – the message to send
Throws: - MailException – if an error occurs when attempting to send the message
org.motechproject.event¶
MotechEvent¶
- public class MotechEvent implements Serializable¶
Motech Scheduled Event data carrier class, Instance of this class with event specific data will be send by Motech Scheduler when a scheduled event is fired
This class is immutable
Fields¶
Methods¶
setEndTime¶
- public MotechEvent setEndTime(Date endDate)¶
setLastEvent¶
- public MotechEvent setLastEvent(boolean lastEvent)¶
org.motechproject.event.listener¶
EventListener¶
- public interface EventListener¶
Methods¶
getIdentifier¶
handle¶
- void handle(MotechEvent event)¶
Handle an particular event that has been received
Parameters: - event –
EventListenerRegistryService¶
- public interface EventListenerRegistryService¶
This interface is necessary for OSGi service publication. The implementing class acts as a registry for all scheduled event listeners. One can register themselves to listen for a specific set of event types.
Methods¶
clearListenersForBean¶
- void clearListenersForBean(String beanName)¶
This method is responsible for removing listeners for a particular bean. This is necessary when bundles are stopped in some fashion so that the listener does not persist.
Parameters: - beanName – The bean name from the Spring context of the candidate class for listener clearing
getListenerCount¶
getListeners¶
- Set<EventListener> getListeners(String subject)¶
Retrieve a list of event listeners for a given event type. If there are no listeners, an empty list is returned.
Parameters: - subject – The event type that you are seeking listeners for
Returns: A list of scheduled event listeners that are interested in that event
hasListener¶
registerListener¶
- void registerListener(EventListener listener, List<String> subjects)¶
Register an event listener to be notified when events of a given type are received via the Server JMS Event Queue.
Parameters: - listener – the listener instance
- subjects – the event types that a listener is interested in
registerListener¶
- void registerListener(EventListener listener, String subject)¶
org.motechproject.event.listener.annotations¶
MotechListenerAbstractProxy¶
- public abstract class MotechListenerAbstractProxy implements EventListener¶
Event Listener Proxy base abstract class
Author: yyonkov
Constructors¶
Methods¶
callHandler¶
- public abstract void callHandler(MotechEvent event)¶
Needs to be implemented by concrete Proxies
Parameters: - event –
handle¶
- public void handle(MotechEvent event)¶
MotechListenerEventProxy¶
- public class MotechListenerEventProxy extends MotechListenerAbstractProxy¶
Responsible for dispatching to void doSomething(MotechEvent event) {} type of handlers
Author: yyonkov
Constructors¶
Methods¶
callHandler¶
- public void callHandler(MotechEvent event)¶
MotechListenerNamedParametersProxy¶
- public class MotechListenerNamedParametersProxy extends MotechListenerAbstractProxy¶
Author: yyonkov
Constructors¶
Methods¶
callHandler¶
- public void callHandler(MotechEvent event)¶
MotechListenerType¶
- public enum MotechListenerType¶
ENUM defining the annotation types
Author: yyonkov
Enum Constants¶
MOTECH_EVENT¶
- public static final MotechListenerType MOTECH_EVENT¶
NAMED_PARAMETERS¶
- public static final MotechListenerType NAMED_PARAMETERS¶
org.motechproject.event.queue¶
MotechCachingConnectionFactory¶
- public class MotechCachingConnectionFactory extends CachingConnectionFactory¶
The MotechCachingConnectionFactory is used to created connection to ActiveMQ.
MotechEventHeaderMapper¶
- public class MotechEventHeaderMapper extends DefaultJmsHeaderMapper¶
For the delay to work, set attribute schedulerSupport=”true” in the broker element of the activemq.xml Ref: http://activemq.apache.org/delay-and-schedule-message-delivery.html
Methods¶
fromHeaders¶
- public void fromHeaders(MessageHeaders messageHeaders, Message message)¶
MotechEventTransformer¶
- public class MotechEventTransformer¶
Methods¶
transform¶
- public MotechEvent transform(MotechEvent motechEvent)¶
org.motechproject.mds.annotations¶
Cascade¶
- public @interface Cascade¶
The Cascade annotation is used by developers to set correct cascade properties for the given field that is a relationship.
See also: org.motechproject.mds.annotations.internal.FieldProcessor
Entity¶
- public @interface Entity¶
The Entity annotation is used by developers to point classes, that should be mapped as Motech Dataservices Entities. The discovery logic for this annotation is done in org.motechproject.mds.annotations.internal.EntityProcessor
See also: org.motechproject.mds.annotations.internal.EntityProcessor
Field¶
- public @interface Field¶
The Field annotation is used by developers to point fields, that should be mapped as entity fields. The discovery logic for this annotation is done in org.motechproject.mds.annotations.internal.FieldProcessor.
Only fields, ‘getter’ or ‘setter’ methods can have this annotation for other methods this annotation is omitted.
See also: org.motechproject.mds.annotations.internal.FieldProcessor
Ignore¶
- public @interface Ignore¶
Thanks to this annotation, developers can point public fields and getter/setter method of a private field that should not be added to the schema definition of an entity. By default, all public fields of an object are added. The discovery logic for this annotation is done in the FieldProcessor
See also: org.motechproject.mds.annotations.internal.FieldProcessor
InSet¶
- public @interface InSet¶
The annotated element must have value that will be in defined set.
Supported types are:
- Integer
- Double
- int, double
Lookup¶
- public @interface Lookup¶
The Lookup annotation is used by developers to point methods, in classes that implements org.motechproject.mds.service.MotechDataService, that should be mapped as Motech Dataservices Lookups. The discovery logic for this annotation is done in org.motechproject.mds.annotations.internal.LookupProcessor
See also: org.motechproject.mds.annotations.internal.LookupProcessor
LookupField¶
- public @interface LookupField¶
The LookupField annotation allows developers to point fields in Lookup method, that should be mapped as Lookup fields for Developer Defined Lookup. The discovery logic for this annotation is done in org.motechproject.mds.annotations.internal.LookupProcessor
See also: org.motechproject.mds.annotations.internal.LookupProcessor
NotInSet¶
- public @interface NotInSet¶
The annotated element must not have value that will be in defined set.
Supported types are:
- Integer
- Double
- int, double
UIDisplayable¶
- public @interface UIDisplayable¶
The UIDisplayable annotation is used by developers to mark a field as being in the default display for a listing of objects. The discovery logic for this annotation is done in org.motechproject.mds.annotations.internal.UIDisplayableProcessor.
Only fields, ‘getter’ or ‘setter’ methods can have this annotation for other methods this annotation is omitted.
See also: org.motechproject.mds.annotations.internal.UIDisplayableProcessor
UIFilterable¶
- public @interface UIFilterable¶
The UIFilterable annotation is used by developers to mark a field that allow users to filter a list of objects by the values in the field. The discovery logic for this annotation is done in org.motechproject.mds.annotations.internal.UIFilterableProcessor.
Only fields, ‘getter’ or ‘setter’ methods can have this annotation for other methods this annotation is omitted. Also this annotation is permitted on fields of type Date, Boolean or List.
See also: org.motechproject.mds.annotations.internal.UIFilterableProcessor
org.motechproject.mds.builder¶
EntityBuilder¶
- public interface EntityBuilder¶
An entity builder is responsible for building the entity class from an Entity schema.
Methods¶
build¶
buildDDE¶
- ClassData buildDDE(Entity entity, Bundle bundle)¶
Builds Developer Defined Entity. The main difference between regular build method and this one, is that this method fetches the class definition from the given bundle, and injects members to the constructed class from there, if possible, rather than building everything from scratch.
Parameters: - entity – the entity schema
- bundle – the bundle to fetch class definition from
Returns: bytes of the constructed class
buildHistory¶
- ClassData buildHistory(Entity entity)¶
Builds History class definition for the given entity. The history class definition contains the same members as the entity class, plus some fields history-exclusive, like schema version.
Parameters: - entity – the entity schema
Returns: bytes of the constructed class
buildTrash¶
prepareHistoryClass¶
EntityInfrastructureBuilder¶
- public interface EntityInfrastructureBuilder¶
The EntityInfrastructureBuilder is responsible for building infrastructure for a given entity: repository, interface and service classes.
Methods¶
buildHistoryInfrastructure¶
- List<ClassData> buildHistoryInfrastructure(String className)¶
Builds the repository, interface and implementation of this interface classes for the given history class. The names for classes are generated by org.motechproject.mds.util.ClassName.getRepositoryName(String), org.motechproject.mds.util.ClassName.getInterfaceName(String), org.motechproject.mds.util.ClassName.getServiceName(String), respectively.
Parameters: - className – a name of history class.
Returns: a list of classes that represents infrastructure for the history class.
buildInfrastructure¶
- List<ClassData> buildInfrastructure(Entity entity)¶
Builds the repository, interface and implementation of this interface classes for the given entity. The names for classes are generated by org.motechproject.mds.util.ClassName.getRepositoryName(String), org.motechproject.mds.util.ClassName.getInterfaceName(String), org.motechproject.mds.util.ClassName.getServiceName(String), respectively.
Parameters: - entity – an instance of org.motechproject.mds.domain.Entity
Returns: a list of classes that represents infrastructure for the given entity.
EntityMetadataBuilder¶
- public interface EntityMetadataBuilder¶
The EntityMetadataBuilderImpl class is responsible for building jdo metadata for an entity class.
Methods¶
addBaseMetadata¶
- void addBaseMetadata(JDOMetadata jdoMetadata, ClassData classData)¶
Adds base information about package and class name to a javax.jdo.metadata.JDOMetadata instance.
Parameters: - jdoMetadata – an empty instance of javax.jdo.metadata.JDOMetadata.
- classData – an instance of org.motechproject.mds.domain.ClassData
addEntityMetadata¶
- void addEntityMetadata(JDOMetadata jdoMetadata, Entity entity)¶
Adds information about package and class name to a javax.jdo.metadata.JDOMetadata instance.
Parameters: - jdoMetadata – a empty instance of javax.jdo.metadata.JDOMetadata.
- entity – a instance of org.motechproject.mds.domain.Entity
addHelperClassMetadata¶
- void addHelperClassMetadata(JDOMetadata jdoMetadata, ClassData classData, Entity entity)¶
Creates metadata with basic information about package and class name to the javax.jdo.metadata.JDOMetadata instance. Additionally, fetches fields from passed entites and adds metadata for fields, if it’s necessary. If entity is null, it will work just like addBaseMetadata(JDOMetadata, ClassData) and won’t add any metadata for fields.
Parameters: - jdoMetadata – an empty instance of javax.jdo.metadata.JDOMetadata.
- classData – an instance of org.motechproject.mds.domain.ClassData
- entity – an entity to fetch fields from
fixEnhancerIssuesInMetadata¶
- void fixEnhancerIssuesInMetadata(JDOMetadata jdoMetadata)¶
This updates the metadata after enhancement. Nucleus makes some “corrections” which do not work with the runtime enhancer.
EnumBuilder¶
- public interface EnumBuilder¶
An enum builder is responsible for building the enum class with the same values as those are defined in the field.
Methods¶
build¶
- ClassData build(ComboboxHolder holder)¶
MDSConstructor¶
- public interface MDSConstructor¶
This interface provide method to create a class for the given entity. The implementation of this interface should also construct other classes like repository, service interface and implementation for this service interface.
Methods¶
constructEntities¶
- boolean constructEntities(boolean buildDDE)¶
Creates a class definition and insert it into the MDS class loader based on data from database. The implementation of this method should also create a repository, interface (when it’s necessary) and implementation of this interface.
After executing this method, there should be possible to create an instance of the given class definition and save it to database by javax.jdo.PersistenceManager provided by DataNucleus.
An interface related with class definition should be created only for entities from outside bundles and if the bundle does not define its interface.
Parameters: - buildDDE – true if class definitions for entities from outside bundles should also be created; otherwise false.
Returns: true if there were entities for which class definitions should be created; otherwise false.
updateFields¶
- void updateFields(Long entityId, Map<String, String> fieldNameChanges)¶
Updates the field names of an entity. This method changes the database schema by changing column names to the new value. This is done for the entity instances, history instances and trash instances.
Parameters: - entityId – The ID of an entity to update
- fieldNameChanges – A map, indexed by current field names and values being updated field names.
org.motechproject.mds.config¶
DeleteMode¶
- public enum DeleteMode¶
The DeleteMode presents what should happen with objects when they are deleted. They can be deleted permanently DELETE or moved to the trash TRASH. This enum is related with the property org.motechproject.mds.util.Constants.Config.MDS_DELETE_MODE.
The UNKNOWN value should not be used in code as appropriate value. It was added to ensure that the fromString(String) method will not return {@value null} value.
Enum Constants¶
DELETE¶
- public static final DeleteMode DELETE¶
TRASH¶
- public static final DeleteMode TRASH¶
UNKNOWN¶
- public static final DeleteMode UNKNOWN¶
MdsConfig¶
- public class MdsConfig¶
Class responsible for handling MDS configuration. Since MDS don’t use Server Config everything connected to the MDS configuration needs to be handled by the module itself.
Methods¶
asProperties¶
- public Properties asProperties()¶
getDataNucleusProperties¶
- public Properties getDataNucleusProperties()¶
getProperties¶
- public Properties getProperties(String filename)¶
ModuleSettings¶
- public class ModuleSettings extends Properties¶
The ModuleSettings contains the base module settings which are inside the org.motechproject.mds.util.Constants.Config.MODULE_FILE. The getters and setters inside this class always checks the given property and if it is incorrect then the default value of the given property will be returned.
Fields¶
DEFAULT_DELETE_MODE¶
- public static final DeleteMode DEFAULT_DELETE_MODE¶
Methods¶
getDeleteMode¶
- public DeleteMode getDeleteMode()¶
setDeleteMode¶
- public void setDeleteMode(DeleteMode deleteMode)¶
ModuleSettings.Deserializer¶
- public static final class Deserializer extends JsonDeserializer<ModuleSettings>¶
Methods¶
deserialize¶
- public ModuleSettings deserialize(JsonParser jp, DeserializationContext ctxt)¶
ModuleSettings.Serializer¶
- public static final class Serializer extends JsonSerializer<ModuleSettings>¶
Methods¶
serialize¶
- public void serialize(ModuleSettings value, JsonGenerator jgen, SerializerProvider provider)¶
SettingsService¶
- public interface SettingsService¶
The SettingsService is a service class for org.motechproject.server.config.SettingsFacade. Its main purpose is to create better access to module settings for developers.
Methods¶
getDeleteMode¶
- DeleteMode getDeleteMode()¶
getModuleSettings¶
- ModuleSettings getModuleSettings()¶
getProperties¶
- Properties getProperties()¶
saveModuleSettings¶
- void saveModuleSettings(ModuleSettings settings)¶
TimeUnit¶
- public enum TimeUnit¶
The TimeUnit specifies what time unit should be used to specify time when the module trash should be cleaned. This enum is related with the property org.motechproject.mds.util.Constants.Config.MDS_TIME_UNIT.
Each value from this enum can be converted to long value that presents time interval in milliseconds. For example the HOURS value is equal to {@value 3.6E6}.
The UNKNOWN value should not be used in code as appropriate value. It was added to ensure that the fromString(String) method will not return {@value null} value.
org.motechproject.mds.domain¶
BrowsingSettings¶
- public class BrowsingSettings¶
The BrowsingSettings contains information about fields that will be visible on UI and could be used as filter on UI.
This class is read only (the data are not saved to database) and its main purpose is to provide methods that help developer to get displayed and filterable fields.
ClassData¶
- public class ClassData¶
Represents a class name and its byte code.
Constructors¶
ClassData¶
- public ClassData(String className, String module, String namespace, byte[] bytecode, EntityType type)¶
ClassData¶
Methods¶
getType¶
- public EntityType getType()¶
ComboboxHolder¶
- public class ComboboxHolder extends FieldHolder¶
The main purpose of this class is to find out what kind of type should be used when the field will be added to the class definition.
Constructors¶
Methods¶
ConfigSettings¶
- public class ConfigSettings¶
Constructors¶
ConfigSettings¶
- public ConfigSettings(DeleteMode deleteMode, boolean emptyTrash, int afterTimeValue, TimeUnit afterTimeUnit)¶
Methods¶
getDeleteMode¶
- public DeleteMode getDeleteMode()¶
setDeleteMode¶
- public void setDeleteMode(DeleteMode deleteMode)¶
Entity¶
- public class Entity¶
The Entity class contains information about an entity. Also it contains information about advanced settings related with the entity.
Constructors¶
Methods¶
advancedSettingsDto¶
- public AdvancedSettingsDto advancedSettingsDto()¶
getBrowsingSettings¶
- public BrowsingSettings getBrowsingSettings()¶
getDrafts¶
- public List<EntityDraft> getDrafts()¶
getRestOptions¶
- public RestOptions getRestOptions()¶
getSecurityMode¶
- public SecurityMode getSecurityMode()¶
setDrafts¶
- public void setDrafts(List<EntityDraft> drafts)¶
setRestOptions¶
- public void setRestOptions(RestOptions restOptions)¶
setSecurity¶
- public void setSecurity(SecurityMode securityMode, List<String> securityMembersList)¶
setSecurityMode¶
- public void setSecurityMode(SecurityMode securityMode)¶
updateAdvancedSetting¶
- public void updateAdvancedSetting(AdvancedSettingsDto advancedSettings)¶
updateFromDraft¶
- public void updateFromDraft(EntityDraft draft)¶
EntityAudit¶
- public class EntityAudit extends Entity¶
This class represents a single historical commit of an Entity.
Methods¶
EntityDraft¶
- public class EntityDraft extends Entity¶
This class represents a users draft of an Entity. A draft is a users work in progress from the UI. This shares the table with its superclass, Entity.
Methods¶
EntityInfo¶
- public class EntityInfo¶
The EntityInfo class contains base information about the given entity like class name or infrastructure classes name.
Methods¶
EntityType¶
- public enum EntityType¶
Enum Constants¶
HISTORY¶
- public static final EntityType HISTORY¶
STANDARD¶
- public static final EntityType STANDARD¶
TRASH¶
- public static final EntityType TRASH¶
Field¶
- public class Field¶
The Field class contains information about a single field.
Methods¶
addMetadata¶
- public void addMetadata(FieldMetadata metadata)¶
addSetting¶
- public void addSetting(FieldSetting setting)¶
addValidation¶
- public void addValidation(FieldValidation validation)¶
getMetadata¶
- public List<FieldMetadata> getMetadata()¶
getMetadata¶
- public FieldMetadata getMetadata(String key)¶
getMetadataById¶
- public FieldMetadata getMetadataById(Long id)¶
getSettingByName¶
- public FieldSetting getSettingByName(String name)¶
getSettings¶
- public List<FieldSetting> getSettings()¶
getValidationByName¶
- public FieldValidation getValidationByName(String name)¶
getValidations¶
- public List<FieldValidation> getValidations()¶
setMetadata¶
- public void setMetadata(List<FieldMetadata> metadata)¶
setSettings¶
- public void setSettings(List<FieldSetting> settings)¶
setValidations¶
- public void setValidations(List<FieldValidation> validations)¶
FieldHolder¶
- public class FieldHolder¶
The main purpose of this class is to give a easy way to access values inside metadata and settings related with the given field.
Constructors¶
Methods¶
FieldMetadata¶
- public class FieldMetadata implements Pair<String, String>¶
The FieldMetadata class contains information about a single metadata added into a field.
Constructors¶
FieldMetadata¶
- public FieldMetadata(MetadataDto metadata)¶
Methods¶
copy¶
- public FieldMetadata copy()¶
toDto¶
- public MetadataDto toDto()¶
update¶
- public final void update(MetadataDto metadata)¶
FieldSetting¶
Constructors¶
FieldSetting¶
- public FieldSetting(Field field, TypeSetting details)¶
FieldSetting¶
- public FieldSetting(Field field, TypeSetting details, String value)¶
Methods¶
copy¶
- public FieldSetting copy()¶
getDetails¶
- public TypeSetting getDetails()¶
setDetails¶
- public void setDetails(TypeSetting details)¶
toDto¶
- public SettingDto toDto()¶
FieldValidation¶
- public class FieldValidation¶
The FieldValidation class contains the value that is related with the correct type validation and information about that whether the given validation is enabled or not.
Constructors¶
FieldValidation¶
- public FieldValidation(Field field, TypeValidation details)¶
FieldValidation¶
- public FieldValidation(Field field, TypeValidation details, String value, boolean enabled)¶
Methods¶
copy¶
- public FieldValidation copy()¶
getDetails¶
- public TypeValidation getDetails()¶
setDetails¶
- public void setDetails(TypeValidation details)¶
toDto¶
- public ValidationCriterionDto toDto()¶
Lookup¶
- public class Lookup¶
The Lookup class contains information about single lookup
Methods¶
OneToManyRelationship¶
- public class OneToManyRelationship extends Relationship¶
A specialization of the Relationship class. Represents a one-to-many relationship.
OneToOneRelationship¶
- public class OneToOneRelationship extends Relationship¶
A specialization of the Relationship class. Represents a one-to-one relationship.
Relationship¶
- public class Relationship¶
A class representing a relationship type. This class is inherited by different types of relationships. This class only represents the field type and provides some utility methods. It is not used in entities themselves.
RelationshipHolder¶
- public class RelationshipHolder extends FieldHolder¶
The main purpose of this class is to find out how cascade should be used for the given field with relationship type.
Constructors¶
RestOptions¶
- public class RestOptions¶
The RestOptions class representing rest options of given entity. This class is related with table in database with the same name.
Methods¶
copy¶
- public RestOptions copy()¶
toDto¶
- public RestOptionsDto toDto()¶
update¶
- public final void update(RestOptionsDto restOptionsDto)¶
Tracking¶
- public class Tracking¶
The Tracking contains information about which fields and what kind of actions should be logged. This class is related with table in database with the same name.
Methods¶
toDto¶
- public TrackingDto toDto()¶
Type¶
- public class Type¶
The Type class contains information about a single type in mds system. The mds type can have a settings and validations that can be assigned to field with the same type.
Constructors¶
Methods¶
getSettings¶
- public List<TypeSetting> getSettings()¶
getValidations¶
- public List<TypeValidation> getValidations()¶
setSettings¶
- public void setSettings(List<TypeSetting> settings)¶
setValidations¶
- public void setValidations(List<TypeValidation> validations)¶
TypeSetting¶
- public class TypeSetting¶
The TypeSetting contains settings for the given mds type. This class is related with table in database with the same name.
Methods¶
getTypeSettingOptions¶
- public List<TypeSettingOption> getTypeSettingOptions()¶
setTypeSettingOptions¶
- public void setTypeSettingOptions(List<TypeSettingOption> typeSettingOptions)¶
TypeSettingOption¶
- public class TypeSettingOption¶
The TypeSettingOption contains a single setting option for the given type setting. This class is related with table in database with the same name.
TypeValidation¶
- public class TypeValidation¶
The TypeValidation contains a single validation option for the given type. This class is related with table in database with the same name.
Constructors¶
org.motechproject.mds.dto¶
AdvancedSettingsDto¶
- public class AdvancedSettingsDto¶
The AdvancedSettingsDto contains information about advanced settings of an entity.
Methods¶
getBrowsing¶
- public BrowsingSettingsDto getBrowsing()¶
getRestOptions¶
- public RestOptionsDto getRestOptions()¶
getTracking¶
- public TrackingDto getTracking()¶
setBrowsing¶
- public void setBrowsing(BrowsingSettingsDto browsing)¶
setRestOptions¶
- public void setRestOptions(RestOptionsDto restOptions)¶
setTracking¶
- public void setTracking(TrackingDto tracking)¶
BrowsingSettingsDto¶
- public class BrowsingSettingsDto¶
The BrowsingSettingsDto contains informations about filed browsing settings
DraftData¶
- public class DraftData¶
The DraftData contains information that are used later for creating temporary changes in field.
Fields¶
Methods¶
DraftResult¶
- public class DraftResult implements Serializable¶
After users do draft changes an instance of this class is returned. It contains information about the draft state.
EntityDto¶
- public class EntityDto¶
The EntityDto class contains only basic information about an entity like id, name, module and namespace.
Constructors¶
EntityDto¶
- public EntityDto(String className, SecurityMode securityMode, Set<String> securityMembers)¶
EntityDto¶
EntityDto¶
EntityDto¶
EntityDto¶
EntityDto¶
EntityDto¶
FieldBasicDto¶
- public class FieldBasicDto¶
The FieldBasicDto contains basic information about a field.
Constructors¶
FieldDto¶
- public class FieldDto¶
The FieldDto class contains information about an existing field in an entity.
Constructors¶
FieldDto¶
- public FieldDto(Long id, Long entityId, TypeDto type, FieldBasicDto basic, boolean readOnly, List<MetadataDto> metadata, FieldValidationDto validation, List<SettingDto> settings, List<LookupDto> lookups)¶
FieldDto¶
- public FieldDto(Long id, Long entityId, TypeDto type, FieldBasicDto basic, boolean readOnly, FieldValidationDto validation)¶
Methods¶
addMetadata¶
- public void addMetadata(MetadataDto metadata)¶
getBasic¶
- public FieldBasicDto getBasic()¶
getMetadata¶
- public List<MetadataDto> getMetadata()¶
getMetadata¶
- public MetadataDto getMetadata(String key)¶
getSetting¶
- public SettingDto getSetting(String name)¶
getSettings¶
- public List<SettingDto> getSettings()¶
getValidation¶
- public FieldValidationDto getValidation()¶
setBasic¶
- public void setBasic(FieldBasicDto basic)¶
setMetadata¶
- public void setMetadata(List<MetadataDto> metadata)¶
setSettings¶
- public void setSettings(List<SettingDto> settings)¶
setValidation¶
- public void setValidation(FieldValidationDto validation)¶
FieldInstanceDto¶
- public class FieldInstanceDto¶
The FieldInstanceDto class contains information about an existing field in an instance.
Constructors¶
FieldInstanceDto¶
- public FieldInstanceDto(Long id, Long instanceId, FieldBasicDto basic)¶
FieldValidationDto¶
- public class FieldValidationDto¶
The FieldValidationDto class contains information about validation criteria for field.
Fields¶
DOUBLE¶
- public static final FieldValidationDto DOUBLE¶
Constant DOUBLE contains validation criteria for double type.
INTEGER¶
- public static final FieldValidationDto INTEGER¶
Constant INTEGER contains validation criteria for integer type.
STRING¶
- public static final FieldValidationDto STRING¶
Constant STRING contains validation criteria for string type.
Constructors¶
FieldValidationDto¶
- public FieldValidationDto(ValidationCriterionDto... criteria)¶
Methods¶
addCriterion¶
- public void addCriterion(ValidationCriterionDto criterion)¶
getCriteria¶
- public List<ValidationCriterionDto> getCriteria()¶
getCriterion¶
- public ValidationCriterionDto getCriterion(String displayName)¶
setCriteria¶
- public void setCriteria(List<ValidationCriterionDto> criteria)¶
LookupDto¶
- public class LookupDto¶
The LookupDto class contains information about single lookup defined by user
Constructors¶
LookupDto¶
- public LookupDto(String lookupName, boolean singleObjectReturn, boolean exposedViaRest, List<LookupFieldDto> lookupFields, boolean readOnly)¶
LookupFieldDto¶
- public class LookupFieldDto¶
Represents a field added to a lookup. The lookup using a given field can be done using multiple lookup types.
Constructors¶
Methods¶
LookupFieldDto.Type¶
- public static enum Type¶
The lookup type represents whether the lookup will be done by comparing to a single field, matching values to a range, or matching to a set of values.
Enum Constants¶
RANGE¶
- public static final LookupFieldDto.Type RANGE¶
SET¶
- public static final LookupFieldDto.Type SET¶
VALUE¶
- public static final LookupFieldDto.Type VALUE¶
MetadataDto¶
- public class MetadataDto implements Pair<String, String>¶
The MetadataDto contains key and value of a single field metadata.
Constructors¶
RestOptionsDto¶
- public class RestOptionsDto¶
Class representing rest options of given entity.
Constructors¶
SettingDto¶
- public class SettingDto implements Pair<String, Object>¶
The SettingDto contains information about a single setting inside a field.
Constructors¶
SettingOptions¶
- public enum SettingOptions¶
The SettingOptions contains available options that can be added to field setting.
Enum Constants¶
POSITIVE¶
- public static final SettingOptions POSITIVE¶
Ensure that a value in a given setting is a number and it has a positive value.
REQUIRE¶
- public static final SettingOptions REQUIRE¶
Force setting a value for a given setting.
TrackingDto¶
- public class TrackingDto¶
The TrackingDto contains information about which fields and what kind of actions should be logged.
TypeDto¶
- public class TypeDto¶
The TypeDto class contains information about an available field in an entity.
Fields¶
BOOLEAN¶
DATETIME¶
DOUBLE¶
INTEGER¶
LOCAL_DATE¶
- public static final TypeDto LOCAL_DATE¶
Constant LOCAL_DATE is a representation of the org.joda.time.LocalDate type.
PERIOD¶
STRING¶
org.motechproject.mds.enhancer¶
MdsJDOEnhancer¶
- public class MdsJDOEnhancer extends JDOEnhancer¶
The MdsJDOEnhancer class is a wrapper for org.datanucleus.api.jdo.JDOEnhancer class. Its task is to add the missing information into created entity class.
Constructors¶
MdsJDOEnhancer¶
- public MdsJDOEnhancer(Properties config, ClassLoader classLoader)¶
org.motechproject.mds.ex¶
EmptyTrashException¶
- public class EmptyTrashException extends MdsException¶
The EmptyTrashException exception signals a situation that there were some problems with cleaning the module trash.
EntityAlreadyExistException¶
- public class EntityAlreadyExistException extends MdsException¶
The EntityAlreadyExistException exception signals a situation in which a user wants to create a new entity with a name that already exist in database.
EntityChangedException¶
- public class EntityChangedException extends MdsException¶
This exception signals that an Entity was changed(presumably by another user).
EntityCreationException¶
- public class EntityCreationException extends MdsException¶
The EntityCreationException exception signals a situation when there were problems with creating new entity class.
EntityDeletedException¶
- public class EntityDeletedException extends MdsException¶
This exception signals that the Entity was deleted(presumably by an another user).
EntityInfrastructureException¶
- public class EntityInfrastructureException extends MdsException¶
The EntityInfrastructureException exception signals a situation when there were problems with creating repository/service interface/service class for entity.
EntityNotFoundException¶
- public class EntityNotFoundException extends MdsException¶
The EntityNotFoundException exception signals a situation in which an entity with a given id does not exist in database.
EntityReadOnlyException¶
- public class EntityReadOnlyException extends MdsException¶
The EntityReadOnlyException exception signals a situation in which a user wants to make changes on an entity which is read only (it was created by a module).
EntitySchemaMismatchException¶
- public class EntitySchemaMismatchException extends MdsException¶
The EntitySchemaMismatch exception signals a situation in which a user wants to revert their instance to a version on a different schema version.
FieldNotFoundException¶
- public class FieldNotFoundException extends MdsException¶
This exception signals that a given field was not found for the Entity.
FieldUsedInLookupException¶
- public class FieldUsedInLookupException extends MdsException¶
Exception indicating that a field cannot be removed, since it is used in a lookup.
IllegalLookupException¶
- public class IllegalLookupException extends RuntimeException¶
Signales that the user defined an illegal lookup.
LoaderException¶
- public class LoaderException extends RuntimeException¶
The LoaderException exception signals situations in which there were problems with correct loading the given class or its dependencies.
LookupExecutionException¶
- public class LookupExecutionException extends MdsException¶
Signals that we were not able to execute a lookup for a given entity.
LookupNameIsRepeatedException¶
- public class LookupNameIsRepeatedException extends MdsException¶
The LookupNameIsRepeatedException exception signals a situation when are more than one lookups in the entity with the same name.
LookupNotFoundException¶
- public class LookupNotFoundException extends MdsException¶
The LookupNotFoundException exception signals a situation in which a lookup with given id does not exist in database.
MdsException¶
- public class MdsException extends RuntimeException¶
The MdsException exception is a basic class for all other exceptions defined in the mds module. It contains information about a message key which will be used on UI to present a message in appropriate language.
Constructors¶
MdsException¶
MdsException¶
MdsException¶
- public MdsException(String messageKey, String... params)
Constructs a new mds exception with the specified message key and params.
Parameters: - messageKey – the message key used later to display message in appropriate language on UI.
- params – the params used later to change placeholders in the message
MdsException¶
MdsException¶
- public MdsException(String messageKey, String params, Throwable cause)¶
Constructs a new mds exception with the specified message key and the specified cause.
Parameters: - messageKey – the message key used later to display message in appropriate language on UI.
- params – the params used later to change placeholders in the message
- cause – the cause of exception.
MdsSchedulerException¶
- public class MdsSchedulerException extends RuntimeException¶
The MdsSchedulerException exception signals problems with scheduling MDS jobs
NoSuchTypeException¶
- public class NoSuchTypeException extends MdsException¶
An exception which signals that a given type does not exist in the database.
ObjectNotFoundException¶
- public class ObjectNotFoundException extends MdsException¶
Signals that the expected object was not found in the database.
ObjectReadException¶
- public class ObjectReadException extends MdsException¶
Signals that we were unable to we are unable to parse the object coming from the database.
ObjectUpdateException¶
- public class ObjectUpdateException extends MdsException¶
Signals that we were unable to update object instance from the provided data.
ReservedKeywordException¶
- public class ReservedKeywordException extends MdsException¶
Signals that field/lookup name is invalid because it is a java keyword.
SecurityException¶
- public class SecurityException extends MdsException¶
The SecurityException exception signals a situation in which user wants to perform an operation on objects, they don’t have access to.
ServiceNotFoundException¶
- public class ServiceNotFoundException extends MdsException¶
Signals that service for a corresponding entity was not found. This most likely signals an issue with entities bundle.
TrashClassNotFoundException¶
- public class TrashClassNotFoundException extends MdsException¶
An Exception thrown when MDS fails to load trash class for an entity
TypeAlreadyExistsException¶
- public class TypeAlreadyExistsException extends MdsException¶
The TypeAlreadyExistsException is thrown, if the user attempts to add a field type, with a display name that already exists in the database
TypeNotFoundException¶
- public class TypeNotFoundException extends RuntimeException¶
The TypeNotFoundException exception signals a situation in which a type with given name does not exist in database.
TypeValidationAlreadyExistsException¶
- public class TypeValidationAlreadyExistsException extends MdsException¶
The TypeValidationAlreadyExistsException is thrown, if the user attempts to add a type validation when there is already validation for given type
org.motechproject.mds.filter¶
Filter¶
- public class Filter implements Serializable¶
Represents a filter on a field.
FilterType¶
- public enum FilterType¶
Represents a method of filtering.
Enum Constants¶
ALL¶
- public static final FilterType ALL¶
NO¶
- public static final FilterType NO¶
PAST_7_DAYS¶
- public static final FilterType PAST_7_DAYS¶
THIS_MONTH¶
- public static final FilterType THIS_MONTH¶
THIS_YEAR¶
- public static final FilterType THIS_YEAR¶
TODAY¶
- public static final FilterType TODAY¶
YES¶
- public static final FilterType YES¶
org.motechproject.mds.javassist¶
JavassistBuilder¶
- public final class JavassistBuilder¶
Builder class for javassist related tasks. Helps with building appropriate elements of class e.g. fields, getters, field initializer
JavassistHelper¶
- public final class JavassistHelper¶
Helper class for javassist related tasks. Helps with generic signature generation, plus methods related with analyzing and loading javassist class representations.
JavassistLoader¶
- public class JavassistLoader extends Loader<ClassData>¶
The JavassistLoader is a implementation of the org.motechproject.mds.util.Loader interface. It takes class information from instance of org.motechproject.mds.domain.ClassData and the missing classes are taken from org.motechproject.mds.javassist.MotechClassPool
See also: org.motechproject.mds.util.Loader, org.motechproject.mds.domain.ClassData, org.motechproject.mds.javassist.MotechClassPool
Constructors¶
JavassistLoader¶
- public JavassistLoader(MDSClassLoader classLoader)¶
MotechClassPool¶
- public final class MotechClassPool¶
This class holds the javasisst classpool, enriched by motech classes. All predefined additions to the ClassPool should take place here. The classpool should also be retrieved using this class, in order to be sure that the a initialization took place.
Methods¶
getEnhancedClasses¶
- public static Collection<ClassData> getEnhancedClasses(boolean includeInerfaces)¶
registerEnhancedClassData¶
registerServiceInterface¶
registeredEnums¶
- public static Collection<String> registeredEnums()¶
registeredInterfaces¶
- public static Collection<String> registeredInterfaces()¶
org.motechproject.mds.jdo¶
AbstractObjectValueGenerator¶
- public abstract class AbstractObjectValueGenerator<T> implements ObjectValueGenerator¶
Base class for other generator classes. It takes value of property (see getPropertName() method) from object and modify it depending on the implementation. If the modified value is null then the java.lang.IllegalStateException is thrown.
Parameters: - <T> – type of property
Methods¶
CreationDateValueGenerator¶
- public class CreationDateValueGenerator extends DateTimeValueGenerator¶
The CreationDateValueGenerator class is responsible for generating value for org.motechproject.mds.util.Constants.Util.CREATION_DATE_FIELD_NAME field.
CreatorValueGenerator¶
- public class CreatorValueGenerator extends UsernameValueGenerator¶
The CreatorValueGenerator class is responsible for generating value for org.motechproject.mds.util.Constants.Util.CREATOR_FIELD_NAME field.
DateTimeValueGenerator¶
- public abstract class DateTimeValueGenerator extends AbstractObjectValueGenerator<DateTime>¶
The DateTimeValueGenerator class modifies properties with org.joda.time.DateTime type. If the given value is null then the current time is returned; otherwise the given value is returned.
MDSClassLoaderResolver¶
- public class MDSClassLoaderResolver implements ClassLoaderResolver¶
This is a wrapper for org.motechproject.mds.jdo.MDSClassLoaderResolverImpl. All calls for the org.datanucleus.ClassLoaderResolver interface are passed to the current instance of the ClassLoaderResolver implementation. When we hit a NullPointerException originating in Felix, we can determine it is due to a synchronization bug after bundle updates - as a result of this DataNucleus has passed us ClassLoaders from the former Bundle version. In that case we reload the instance passing it the ClassLoaders from the new bundle.
Constructors¶
MDSClassLoaderResolver¶
- public MDSClassLoaderResolver(ClassLoader pmLoader)¶
Methods¶
classForName¶
- public Class classForName(String name, ClassLoader primary)¶
classForName¶
- public Class classForName(String name, ClassLoader primary, boolean initialize)¶
getResource¶
- public URL getResource(String resourceName, ClassLoader primary)¶
getResources¶
- public Enumeration<URL> getResources(String resourceName, ClassLoader primary)¶
registerUserClassLoader¶
- public void registerUserClassLoader(ClassLoader loader)¶
setPrimary¶
- public void setPrimary(ClassLoader primary)¶
setRuntimeClassLoader¶
- public void setRuntimeClassLoader(ClassLoader loader)¶
MDSClassLoaderResolverImpl¶
- class MDSClassLoaderResolverImpl extends ClassLoaderResolverImpl¶
The main purpose of the MDSClassLoaderResolverImpl class is to avoid situation in which standard datanucleus class loader resolver does not see classes that are saved in database. This is the main implementation that extends the standard ClassLoaderResolverImpl from datanucleus. Due to a synchronization bug in Felix, there are cases when we will instantiate this more then once (after we hit the bug).
Constructors¶
MDSClassLoaderResolverImpl¶
- public MDSClassLoaderResolverImpl(ClassLoader pmLoader)¶
MdsJdoAnnotationReader¶
- public class MdsJdoAnnotationReader extends JDOAnnotationReader¶
MDS JDO annotation reader, extends the regular org.datanucleus.api.jdo.metadata.JDOAnnotationReader This class was introduced because org.datanucleus.api.jdo.metadata.JDOAnnotationReader would not read field annotations for metadata if there was no class level JDO annotations. This extension will recognize the org.motechproject.mds.annotations.Entity annotation as an annotation indicating that the class is persistence capable.
MdsTransactionManager¶
- public class MdsTransactionManager extends JdoTransactionManager¶
We override springs transaction for classloader control. We store context classloaders as thread local variables, and switch them with the MDS classloader for the transaction. Since we only allow operations in transactions, this entry point for classloader switching is enough.
ModificationDateValueGenerator¶
- public class ModificationDateValueGenerator extends DateTimeValueGenerator¶
The ModificationDateValueGenerator class is responsible for generating value for org.motechproject.mds.util.Constants.Util.MODIFICATION_DATE_FIELD_NAME field.
ModifiedByValueGenerator¶
- public class ModifiedByValueGenerator extends UsernameValueGenerator¶
The ModifiedByValueGenerator class is responsible for generating value for org.motechproject.mds.util.Constants.Util.MODIFIED_BY_FIELD_NAME field.
OwnerValueGenerator¶
- public class OwnerValueGenerator extends UsernameValueGenerator¶
The OwnerValueGenerator class is responsible for generating value for org.motechproject.mds.util.Constants.Util.OWNER_FIELD_NAME field.
SchemaGenerator¶
- public class SchemaGenerator implements InitializingBean¶
The schema generator class is responsible for generating the table schema for entities upon start. Schema for all entity classes has to be generated, otherwise issues might arise in foreign key generation for example. This code runs in the generated entities bundle.
Constructors¶
TimeTypeConverter¶
- public class TimeTypeConverter implements TypeConverter<Time, String>¶
This is datanucleus type converter we plug in. It is responsible for converting org.motechproject.commons.date.model.Time instances to Strings which are persisted.
UsernameValueGenerator¶
- public abstract class UsernameValueGenerator extends AbstractObjectValueGenerator<String>¶
The UsernameValueGenerator class modifies properties with java.lang.String type. The given value is returned without any change if it is not blank. Otherise the class tries to get current logged user name. If the user exists and name is not blank then this name is returned otherwise the empty string is returned.
org.motechproject.mds.query¶
CollectionProperty¶
- public class CollectionProperty extends Property<Collection>¶
The CollectionProperty class represent a property that will be used in JDO query and it has to have the given value(s).
Methods¶
generateDeclareParameter¶
- public CharSequence generateDeclareParameter(int idx)¶
generateFilter¶
- public CharSequence generateFilter(int idx)¶
unwrap¶
- public Collection unwrap()¶
CustomOperatorProperty¶
- public class CustomOperatorProperty<T> extends Property<T>¶
The CustomOperatorProperty class represents a property that will be used in JDO query. This class allows inserting a custom operator, such as >, <=, matches(), etc.
Parameters: - <T> – type of the passed value
Constructors¶
EqualProperty¶
- public class EqualProperty<T> extends Property<T>¶
The EqualProperty class represents a property that will be used in JDO query and it has to be equal to the given value.
Parameters: - <T> – type of the passed value
Methods¶
generateFilter¶
- public CharSequence generateFilter(int idx)¶
MatchesProperty¶
- public class MatchesProperty extends CustomOperatorProperty<String>¶
A convenience extension of the org.motechproject.mds.query.CustomOperatorProperty. The custom operator is “matches()” and the underlying type is String. The value passed will be wrapped inside .*.* for matching purposes.
Property¶
- public abstract class Property<T>¶
The Property class represents a property that will be used in JDO query. Classes that extend this class should define how that property should be used in WHERE section in JDO query.
Parameters: - <T> – type of the passed value
Methods¶
asDeclareParameter¶
- public CharSequence asDeclareParameter(int idx)¶
asFilter¶
- public CharSequence asFilter(int idx)¶
containsOnlyNullValues¶
- protected boolean containsOnlyNullValues(Collection collection)¶
generateDeclareParameter¶
- protected CharSequence generateDeclareParameter(int idx)¶
generateFilter¶
- protected abstract CharSequence generateFilter(int idx)¶
unwrap¶
- public Collection unwrap()¶
PropertyBuilder¶
- public final class PropertyBuilder¶
The PropertyBuilder class is a util class that helps create appropriate property class based on passed name and value.
QueryExecution¶
- public interface QueryExecution<T>¶
Allows users to execute custom queries through Motech Data Services. Implementations need only to implement the execute method, which can operate directly on the javax.jdo.Query object. The return value type is left to the implementation.
Parameters: - <T> – the type that will be returned from this query
Methods¶
execute¶
- T execute(Query query, InstanceSecurityRestriction restriction)¶
QueryExecutor¶
- public final class QueryExecutor¶
The QueryExecutor util class provides methods that help execute a JDO query.
Methods¶
execute¶
- public static Object execute(Query query, InstanceSecurityRestriction restriction)¶
execute¶
- public static Object execute(Query query, Object value, InstanceSecurityRestriction restriction)¶
QueryParams¶
- public class QueryParams implements Serializable¶
Utility class containing parameters which control order and size of query results. Used mainly for paging/ordering queries from the UI.
Constructors¶
Methods¶
ascOrder¶
- public static QueryParams ascOrder(String field)¶
descOrder¶
- public static QueryParams descOrder(String field)¶
QueryUtil¶
- public final class QueryUtil¶
The QueryUtil util class provides methods that help developer to create a JDO query.
See also: javax.jdo.Query
Methods¶
asMatchesPattern¶
setQueryParams¶
- public static void setQueryParams(Query query, QueryParams queryParams)¶
useFilter¶
- public static void useFilter(Query query, String[] properties, Object[] values, InstanceSecurityRestriction restriction)¶
RangeProperty¶
- public class RangeProperty<T> extends Property<Range<T>>¶
The RangeProperty class represents a property that will be used in JDO query and it has to be inside the given range.
Parameters: - <T> – type used in range.
Methods¶
generateDeclareParameter¶
- public CharSequence generateDeclareParameter(int idx)¶
generateFilter¶
- public CharSequence generateFilter(int idx)¶
unwrap¶
- public Collection unwrap()¶
RestrictionProperty¶
- public class RestrictionProperty extends EqualProperty<String>¶
The RestrictionProperty class represents a property that will be used in JDO query and depends on restriction criteria the creator or owner field in an instance has to have the appropriate user name.
Constructors¶
RestrictionProperty¶
- public RestrictionProperty(InstanceSecurityRestriction restriction, String value)¶
SetProperty¶
- public class SetProperty<T> extends Property<Set<T>>¶
The SetProperty class represents a property that will be used in JDO query and it has to have one of the value from the given set.
Parameters: - <T> – type used in set.
Methods¶
generateDeclareParameter¶
- public CharSequence generateDeclareParameter(int idx)¶
generateFilter¶
- public CharSequence generateFilter(int idx)¶
unwrap¶
- public Collection unwrap()¶
org.motechproject.mds.repository¶
AllConfigSettings¶
- public class AllConfigSettings extends MotechDataRepository<ConfigSettings>¶
AllConfigSettings is responsible for communication with database for MDS configuration.
Methods¶
addOrUpdate¶
- public void addOrUpdate(ConfigSettings record)¶
AllEntities¶
- public class AllEntities extends MotechDataRepository<Entity>¶
The AllEntities class is a repository class that operates on instances of org.motechproject.mds.domain.Entity.
AllEntityAudits¶
- public class AllEntityAudits extends MotechDataRepository<EntityAudit>¶
This a repository for persisting entity audits. It provides methods which created audits, by cloning the giving entity.
AllEntityDrafts¶
- public class AllEntityDrafts extends MotechDataRepository<EntityDraft>¶
This a repository for persisting entity drafts. It provides methods which created drafts, by cloning the giving entity.
Methods¶
create¶
- public EntityDraft create(Entity entity, String username)¶
retrieve¶
- public EntityDraft retrieve(Entity entity, String username)¶
retrieveAll¶
- public List<EntityDraft> retrieveAll(String username)¶
retrieveAll¶
- public List<EntityDraft> retrieveAll(Entity entity)¶
setProperties¶
- public void setProperties(EntityDraft draft, Entity entity)¶
setProperties¶
- public void setProperties(EntityDraft draft, Entity entity, String username)¶
update¶
- public EntityDraft update(EntityDraft draft)¶
AllTypeSettings¶
- public class AllTypeSettings extends MotechDataRepository<TypeSetting>¶
The AllTypeSettings class is a repository class that operates on instances of org.motechproject.mds.domain.TypeSetting.
AllTypeValidations¶
- public class AllTypeValidations extends MotechDataRepository<TypeValidation>¶
The AllTypeValidations class is a repository class that operates on instances of org.motechproject.mds.domain.TypeValidation.
AllTypes¶
- public class AllTypes extends MotechDataRepository<Type>¶
The AllTypes repository class allows persistence and retrieving of Field Types in Data Services database.
MetadataHolder¶
- public class MetadataHolder¶
Holds the current JDO metadata for Seuss. Allows reloading the metadata and retrieval for modifications.
Methods¶
getJdoMetadata¶
- public JDOMetadata getJdoMetadata()¶
reloadMetadata¶
- public JDOMetadata reloadMetadata()¶
setPersistenceManagerFactory¶
- public void setPersistenceManagerFactory(PersistenceManagerFactory persistenceManagerFactory)¶
MotechDataRepository¶
- public abstract class MotechDataRepository<T>¶
This is a basic repository class with standard CRUD operations. It should be used by other repositories inside this package.
This class is also used as super class to create a repository related with the given entity schema in org.motechproject.mds.builder.EntityInfrastructureBuilder.
Parameters: - <T> – the type of class
Methods¶
count¶
- public long count(InstanceSecurityRestriction restriction)¶
count¶
- public long count(String[] properties, Object[] values, InstanceSecurityRestriction restriction)¶
count¶
- public long count(List<Property> properties, InstanceSecurityRestriction restriction)¶
countForFilter¶
- public long countForFilter(Filter filter, InstanceSecurityRestriction restriction)¶
delete¶
- public void delete(String property, Object value, InstanceSecurityRestriction restriction)¶
delete¶
- public void delete(String[] properties, Object[] values, InstanceSecurityRestriction restriction)¶
deleteAll¶
- public void deleteAll(String property, Object value, InstanceSecurityRestriction restriction)¶
deleteAll¶
- public void deleteAll(String[] properties, Object[] values, InstanceSecurityRestriction restriction)¶
filter¶
- public List<T> filter(Filter filter, QueryParams queryParams)¶
filter¶
- public List<T> filter(Filter filter, QueryParams queryParams, InstanceSecurityRestriction restriction)¶
getPersistenceManager¶
- public PersistenceManager getPersistenceManager()¶
retrieve¶
- public T retrieve(String property, Object value, InstanceSecurityRestriction restriction)¶
retrieve¶
- public T retrieve(String[] properties, Object[] values, InstanceSecurityRestriction restriction)¶
retrieveAll¶
- public List<T> retrieveAll(InstanceSecurityRestriction restriction)¶
retrieveAll¶
- public List<T> retrieveAll(String property, Object value, InstanceSecurityRestriction restriction)¶
retrieveAll¶
- public List<T> retrieveAll(String[] properties, Object[] values, InstanceSecurityRestriction restriction)¶
retrieveAll¶
- public List<T> retrieveAll(String[] properties, Object[] values, QueryParams queryParams, InstanceSecurityRestriction restriction)¶
retrieveAll¶
- public List<T> retrieveAll(QueryParams queryParams, InstanceSecurityRestriction restriction)¶
retrieveAll¶
- public List<T> retrieveAll(List<Property> properties, InstanceSecurityRestriction restriction)¶
retrieveAll¶
- public List<T> retrieveAll(List<Property> properties, QueryParams queryParams, InstanceSecurityRestriction restriction)¶
setPersistenceManagerFactory¶
- public void setPersistenceManagerFactory(PersistenceManagerFactory persistenceManagerFactory)¶
org.motechproject.mds.service¶
DefaultMotechDataService¶
- public abstract class DefaultMotechDataService<T> implements MotechDataService<T>¶
This is a basic implementation of org.motechproject.mds.service.MotechDataService. Mainly it is used as super class to create a service related with the given entity schema in org.motechproject.mds.builder.EntityInfrastructureBuilder but it can be also used by other services inside this package.
Parameters: - <T> – the type of entity schema.
Methods¶
doInTransaction¶
- public <R> R doInTransaction(TransactionCallback<R> transactionCallback)¶
executeQuery¶
- public <R> R executeQuery(QueryExecution<R> queryExecution)¶
filter¶
- public List<T> filter(Filter filter, QueryParams queryParams)¶
getRepository¶
- protected MotechDataRepository<T> getRepository()¶
retrieveAll¶
- public List<T> retrieveAll(QueryParams queryParams)¶
setAllEntities¶
- public void setAllEntities(AllEntities allEntities)¶
setEntityService¶
- public void setEntityService(EntityService entityService)¶
setHistoryService¶
- public void setHistoryService(HistoryService historyService)¶
setRepository¶
- public void setRepository(MotechDataRepository<T> repository)¶
setTransactionManager¶
- public void setTransactionManager(JdoTransactionManager transactionManager)¶
setTrashService¶
- public void setTrashService(TrashService trashService)¶
validateCredentials¶
- protected InstanceSecurityRestriction validateCredentials()¶
validateCredentials¶
- protected InstanceSecurityRestriction validateCredentials(T instance)¶
EntityService¶
- public interface EntityService¶
This interface provides methods related with executing actions on an entity.
Methods¶
addFields¶
- void addFields(EntityDto entity, Collection<FieldDto> fields)¶
addFilterableFields¶
- void addFilterableFields(EntityDto entityDto, Collection<String> fieldNames)¶
addLookups¶
- void addLookups(Long entityId, Collection<LookupDto> lookups)¶
getAdvancedSettings¶
- AdvancedSettingsDto getAdvancedSettings(Long entityId)¶
getAdvancedSettings¶
- AdvancedSettingsDto getAdvancedSettings(Long entityId, boolean committed)¶
getEntityDraft¶
- EntityDraft getEntityDraft(Long entityId)¶
getEntityDraft¶
- EntityDraft getEntityDraft(Long entityId, String username)¶
saveDraftEntityChanges¶
- DraftResult saveDraftEntityChanges(Long entityId, DraftData draftData, String username)¶
saveDraftEntityChanges¶
- DraftResult saveDraftEntityChanges(Long entityId, DraftData draftData)¶
HistoryService¶
- public interface HistoryService¶
The HistoryService provides methods related with processing historical changes on the given instance of entity.
Methods¶
getHistoryForInstance¶
- List getHistoryForInstance(Object instance, QueryParams queryParams)¶
Returns the historical data for the given instance. This method return historical data only for objects that are not in the MDS trash. For trash instances the return value will be incorrect.
Parameters: - instance – an instance created from the given entity definition.
- queryParams – Query parameters such as page number, size of page and sort direction. If null method will return all history records.
Returns: a list of historical data related with the given instance.
record¶
- void record(Object instance)¶
Records changes made on the given instance of entity. The first historical data should be equal to data inside the given instance. Two instance of historical data should be connected using appropriate fields (defined in history class definition). This method should be used only for instances that are not in the MDS trash.
Parameters: - instance – an instance created from the given entity definition.
remove¶
JarGeneratorService¶
- public interface JarGeneratorService¶
This interface provides methods to create a bundle jar with all entities defined in MDS module.
Fields¶
Methods¶
generate¶
- File generate()¶
Generates a jar file that contains entity class definitions, repositories, interfaces, implementations of these interfaces. The jar should also contains class related with historical data and trash.
Throws: - IOException – if an I/O error occurs while the jar is creating.
Returns: file that point to an entitites bundle jar.
regenerateMdsDataBundle¶
- void regenerateMdsDataBundle(boolean buildDDE)¶
Constructs entities, builds and starts the entities bundle jar
Parameters: - buildDDE – true if class definitions for entities from outside bundles should also be created; otherwise false.
See also: .generate()
regenerateMdsDataBundle¶
- void regenerateMdsDataBundle(boolean buildDDE, boolean startBundle)¶
Constructs entities, builds the entities bundle jar. The generated bundle will start only if the startBundle will be set to true.
Parameters: - buildDDE – true if class definitions for entities from outside bundles should also be created; otherwise false.
- startBundle – true if the generated bundle should start; otherwise false.
See also: .generate()
regenerateMdsDataBundleAfterDdeEnhancement¶
- void regenerateMdsDataBundleAfterDdeEnhancement(String moduleName)¶
Constructs entities, builds and starts the entities bundle jar. This method should be used after DDE enhancement. It will build all DDE classes and refresh the module from which the DDE being enhanced comes from.
Parameters: - moduleName – module name of the entity from which the enhanced DDE comes from
See also: .generate()
MotechDataService¶
- public interface MotechDataService<T>¶
This is a basic service interface with CRUD operations. Mainly it is used as super interface to create service interface related with the given entity schema in org.motechproject.mds.builder.EntityInfrastructureBuilder but it can be also used by other service interfaces inside this package.
Parameters: - <T> – the type of entity schema.
Methods¶
doInTransaction¶
- <R> R doInTransaction(TransactionCallback<R> transactionCallback)¶
executeQuery¶
- <R> R executeQuery(QueryExecution<R> queryExecution)¶
filter¶
- List<T> filter(Filter filter, QueryParams queryParams)¶
retrieveAll¶
- List<T> retrieveAll(QueryParams queryParams)¶
TransactionalMotechDataService¶
- public abstract class TransactionalMotechDataService<T> extends DefaultMotechDataService<T>¶
The main goal of the TransactionalMotechDataService class is to resolve problems with transaction annotations not working for generated lookups. We use the traditional transaction callback instead.
Parameters: - <T> – the type of entity schema.
TrashService¶
- public interface TrashService¶
The TrashService provides methods related with the module trash mode (by default the mode is active and it can be turned off by the user).
Methods¶
emptyTrash¶
- void emptyTrash()¶
Cleans the module trash. All instances in trash should be removed permanently and if they contain any historical data they should also be removed permanently.
This method should only be executed by the job created in the scheduleEmptyTrashJob() method.
findTrashById¶
getInstancesFromTrash¶
- Collection getInstancesFromTrash(String entityName, QueryParams queryParams)¶
Returns the collection of instances from trash of a certain entity. Returned collection contains only instances that are on the current schema version.
Parameters: - entityName – Instances of what entity should be looked for
- queryParams – Query parameters such as page number, size of page and sort direction. If null method will return all records in trash.
Returns: Collection of instances on the current schema version in trash
isTrashMode¶
- boolean isTrashMode()¶
Checks if trash mode is active. This method should be used before executing the moveToTrash(Object,Long) method to resolve whether the given instance should be moved to trash or removed permanently.
Returns: true if delete mode is equal to org.motechproject.mds.config.DeleteMode.TRASH; false otherwise.
moveFromTrash¶
moveToTrash¶
scheduleEmptyTrashJob¶
- void scheduleEmptyTrashJob()¶
Sets the repeating schedule job that will be executed from time to time. Execution time depends on the value of time value and time unit (defined in org.motechproject.mds.util.Constants.Config.MODULE_FILE).
Before scheduling new job, the old one should be unscheduled to prevent the errors.
org.motechproject.mds.service.impl¶
BasePersistenceService¶
- public abstract class BasePersistenceService¶
The BasePersistenceService class provides utility methods for communication with the database for HistoryServiceImpl and TrashServiceImpl. It allows to create and retrieve instances, load proper classes and parse values.
Methods¶
create¶
- protected <T> Object create(Class<T> clazz, Object src, EntityType type, ObjectReference objectReference)¶
findService¶
- protected MotechDataService findService(Class<?> clazz)¶
getClass¶
- protected Class<?> getClass(Object src, EntityType type)¶
getClass¶
- protected Class<?> getClass(String srcClassName, EntityType type)¶
getPersistenceManagerFactory¶
- protected PersistenceManagerFactory getPersistenceManagerFactory()¶
getValue¶
- protected Object getValue(Field field, Object src, Object target, EntityType type, ObjectReference objectReference)¶
setAllEntities¶
- public void setAllEntities(AllEntities allEntities)¶
setBundleContext¶
- public void setBundleContext(BundleContext bundleContext)¶
setPersistenceManagerFactory¶
- public void setPersistenceManagerFactory(PersistenceManagerFactory persistenceManagerFactory)¶
EntityServiceImpl¶
- public class EntityServiceImpl implements EntityService¶
Default implementation of org.motechproject.mds.service.EntityService interface.
Methods¶
addDisplayedFields¶
addFields¶
- public void addFields(EntityDto entityDto, Collection<FieldDto> fields)¶
addFilterableFields¶
- public void addFilterableFields(EntityDto entityDto, Collection<String> fieldNames)¶
addLookups¶
- public void addLookups(Long entityId, Collection<LookupDto> lookups)¶
getAdvancedSettings¶
- public AdvancedSettingsDto getAdvancedSettings(Long entityId)¶
getAdvancedSettings¶
- public AdvancedSettingsDto getAdvancedSettings(Long entityId, boolean committed)¶
getEntityDraft¶
- public EntityDraft getEntityDraft(Long entityId)¶
getEntityDraft¶
- public EntityDraft getEntityDraft(Long entityId, String username)¶
saveDraftEntityChanges¶
- public DraftResult saveDraftEntityChanges(Long entityId, DraftData draftData, String username)¶
saveDraftEntityChanges¶
- public DraftResult saveDraftEntityChanges(Long entityId, DraftData draftData)¶
setAllEntities¶
- public void setAllEntities(AllEntities allEntities)¶
setAllEntityAudits¶
- public void setAllEntityAudits(AllEntityAudits allEntityAudits)¶
setAllEntityDrafts¶
- public void setAllEntityDrafts(AllEntityDrafts allEntityDrafts)¶
setMDSConstructor¶
- public void setMDSConstructor(MDSConstructor mdsConstructor)¶
HistoryServiceImpl¶
- public class HistoryServiceImpl extends BasePersistenceService implements HistoryService¶
Default implementation of org.motechproject.mds.service.HistoryService interface.
JarGeneratorServiceImpl¶
- public class JarGeneratorServiceImpl implements JarGeneratorService¶
Default implementation of org.motechproject.mds.service.JarGeneratorService interface.
Methods¶
regenerateMdsDataBundle¶
- public void regenerateMdsDataBundle(boolean buildDDE, boolean startBundle)¶
regenerateMdsDataBundleAfterDdeEnhancement¶
setBundleContext¶
- public void setBundleContext(BundleContext bundleContext)¶
setMdsConstructor¶
- public void setMdsConstructor(MDSConstructor mdsConstructor)¶
setMetadataHolder¶
- public void setMetadataHolder(MetadataHolder metadataHolder)¶
MdsScheduledJob¶
- public class MdsScheduledJob implements Job¶
Job responsible for emptying MDS trash.
MdsSchedulerServiceImpl¶
- public class MdsSchedulerServiceImpl implements MdsSchedulerService¶
Fields¶
Constructors¶
MdsSchedulerServiceImpl¶
- public MdsSchedulerServiceImpl(BundleContext bundleContext)¶
TrashServiceImpl¶
- public class TrashServiceImpl extends BasePersistenceService implements TrashService¶
Default implementation of org.motechproject.mds.service.TrashService interface.
Methods¶
getInstancesFromTrash¶
- public Collection getInstancesFromTrash(String className, QueryParams queryParams)¶
setHistoryService¶
- public void setHistoryService(HistoryService historyService)¶
setMdsSchedulerService¶
- public void setMdsSchedulerService(MdsSchedulerService mdsSchedulerService)¶
setSettingsService¶
- public void setSettingsService(SettingsService settingsService)¶
TypeServiceImpl¶
- public class TypeServiceImpl implements TypeService¶
Default implementation of org.motechproject.mds.service.TypeService interface
Methods¶
findValidations¶
- public List<TypeValidation> findValidations(TypeDto type, Class<? extends Annotation> aClass)¶
getType¶
- public Type getType(TypeValidation validation)¶
setAllTypeValidations¶
- public void setAllTypeValidations(AllTypeValidations allTypeValidations)¶
org.motechproject.mds.util¶
ClassName¶
- public final class ClassName¶
The ClassName util provides several methods which should help for example with getting class name or package from string representation of class. There is also methods related with creating names for repository, service interface and implementation of this service interface.
Methods¶
Constants¶
- public final class Constants¶
The Constants contains constant values used in MDS module. They are grouped by their role.
Constants.AnnotationFields¶
- public static final class AnnotationFields¶
The AnnotationFields contains constant values related with attributes names in mds annotations.
See also: org.motechproject.mds.annotations.Entity, org.motechproject.mds.annotations.Field, org.motechproject.mds.annotations.Ignore, org.motechproject.mds.annotations.Lookup, org.motechproject.mds.annotations.LookupField
Constants.Config¶
- public static final class Config¶
The Config contains constant values related with properties inside files:
- datanucleus.properties
- motech-mds.properties
Constants.Manifest¶
- public static final class Manifest¶
The Manifest contains constant values related with attributes inside the motech-platform-dataservices-entities bundle manifest.
See also: org.motechproject.mds.service.JarGeneratorService, org.motechproject.mds.service.impl.JarGeneratorServiceImpl
Fields¶
BUNDLE_MANIFESTVERSION¶
BUNDLE_NAME_SUFFIX¶
- public static final String BUNDLE_NAME_SUFFIX¶
Constant BUNDLE_NAME_SUFFIX presents suffix of the name of bundle that will be created by implementation of org.motechproject.mds.service.JarGeneratorService interface.
MANIFEST_VERSION¶
SYMBOLIC_NAME_SUFFIX¶
- public static final String SYMBOLIC_NAME_SUFFIX¶
Constant SYMBOLIC_NAME_SUFFIX presents suffix of the bundle symbolic name of bundle that will be created by implementation of org.motechproject.mds.service.JarGeneratorService interface.
Constants.Operators¶
- public static final class Operators¶
Operators that users can use in lookups.
Fields¶
Constants.Packages¶
- public static final class Packages¶
The Packages contains constant values related with packages inside MDS module.
Constants.PackagesGenerated¶
- public static final class PackagesGenerated¶
Constants.Roles¶
- public static final class Roles¶
The Roles contains constant values related with security roles.
Constants.Util¶
HistoryFieldUtil¶
- public final class HistoryFieldUtil¶
The HistoryFieldUtil class provides helper methods to determine field names in the given history class.
InstanceSecurityRestriction¶
- public class InstanceSecurityRestriction¶
Represents a restriction on entity instances
Loader¶
- public abstract class Loader<T>¶
The Loader is an abstract class that checks if all class dependencies to the given class definition are resolved. If not then the missing class name is taken from exception and the doWhenClassNotFound(String) method is executed.
Parameters: - <T> – the type of argument data
MDSClassLoader¶
- public class MDSClassLoader extends ClassLoader¶
The MDSClassLoader class is a mds wrapper for ClassLoader.
Constructors¶
MDSClassLoader¶
- protected MDSClassLoader(ClassLoader parent)¶
Methods¶
getInstance¶
- public static MDSClassLoader getInstance()¶
getStandaloneInstance¶
- public static MDSClassLoader getStandaloneInstance()¶
getStandaloneInstance¶
- public static MDSClassLoader getStandaloneInstance(ClassLoader parent)¶
MemberUtil¶
- public final class MemberUtil¶
Fields¶
Methods¶
getCorrectType¶
- public static Class<?> getCorrectType(AnnotatedElement object)¶
getFieldName¶
- public static String getFieldName(AnnotatedElement object)¶
getGenericType¶
- public static Class<?> getGenericType(AnnotatedElement object)¶
getGenericType¶
- public static Class<?> getGenericType(AnnotatedElement object, int typeNumber)¶
NumberPredicate¶
ObjectReference¶
- public class ObjectReference¶
Represents an object reference. It holds an information about related field name, as well as the object that the field should reference to.
Pair¶
- public interface Pair<N, V>¶
The Pair util interface should use everywhere where developer needs a pair of key-value
Parameters: - <N> – type of key
- <V> – type of value
See also: org.motechproject.mds.domain.FieldMetadata, org.motechproject.mds.domain.FieldSetting, org.motechproject.mds.dto.MetadataDto, org.motechproject.mds.dto.SettingDto
PropertyUtil¶
- public final class PropertyUtil extends PropertyUtils¶
The PropertyUtil util class provides the same method like org.apache.commons.beanutils.PropertyUtils and two additional methods for safe writing and reading property in the given bean.
SecurityMode¶
- public enum SecurityMode¶
This enum describes security mode for an entity
Enum Constants¶
CREATOR¶
- public static final SecurityMode CREATOR¶
EVERYONE¶
- public static final SecurityMode EVERYONE¶
OWNER¶
- public static final SecurityMode OWNER¶
ROLES¶
- public static final SecurityMode ROLES¶
USERS¶
- public static final SecurityMode USERS¶
SecurityUtil¶
- public final class SecurityUtil¶
The SecurityUtil class provides helper methods to retrieve logged user details, such as username or roles
org.motechproject.osgi.web¶
Activator¶
- public class Activator implements BundleActivator¶
ApplicationContextTracker¶
- public abstract class ApplicationContextTracker extends ServiceTracker¶
Base class for every class that wishes to track Spring application context. Contains a methods that help with synchronous processing.
Constructors¶
ApplicationContextTracker¶
- public ApplicationContextTracker(BundleContext context)¶
Methods¶
contextInvalidOrProcessed¶
- protected boolean contextInvalidOrProcessed(ServiceReference serviceReference, ApplicationContext applicationContext)¶
markAsProcessed¶
- protected void markAsProcessed(ApplicationContext applicationContext)¶
removeFromProcessed¶
- protected void removeFromProcessed(ApplicationContext applicationContext)¶
BlueprintActivator¶
- public class BlueprintActivator implements BundleActivator¶
Methods¶
start¶
- public void start(BundleContext context)¶
stop¶
- public void stop(BundleContext context)¶
BlueprintApplicationContextTracker¶
- public class BlueprintApplicationContextTracker extends ApplicationContextTracker¶
The BlueprintApplicationContextTracker class tracks application contexts, which are registered as services.
Constructors¶
BlueprintApplicationContextTracker¶
- public BlueprintApplicationContextTracker(BundleContext context)¶
Methods¶
addingService¶
- public Object addingService(ServiceReference serviceReference)¶
removedService¶
- public void removedService(ServiceReference reference, Object service)¶
BundleContextWrapper¶
- public class BundleContextWrapper implements BundleContextAware¶
Constructors¶
BundleContextWrapper¶
- public BundleContextWrapper(BundleContext context)¶
Methods¶
getBundleApplicationContext¶
- public ApplicationContext getBundleApplicationContext()¶
getBundleContext¶
- public BundleContext getBundleContext()¶
setBundleContext¶
- public void setBundleContext(BundleContext bundleContext)¶
BundleRegister¶
- public final class BundleRegister¶
The BundleRegister Singleton class is used for recording bundles. This class will help to reconfigure logger’s levels.
BundledJspView¶
Methods¶
render¶
- public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response)¶
setBundleContext¶
- public void setBundleContext(BundleContext bundleContext)¶
Log4JBundleLoader¶
- public class Log4JBundleLoader¶
This Log4JBundleLoader class is responsible for loading configuration of the loggers from the saved properties or file in bundle (log4j.xml).
Methods¶
checkListContainLogger¶
- public boolean checkListContainLogger(List<LogMapping> loggers, String log)¶
createLoggerProperties¶
- public Properties createLoggerProperties(List<LogMapping> log)¶
ModuleRegistrationData¶
- public class ModuleRegistrationData¶
Object used to registered a module withing the Motech UI system. Represents a module and is used for building the common user interface. All modules that wish to register within the UI system must either expose this class as a spring bean in their application context or manually register it through the UIFrameworkService OSGi service.
See also: UIFrameworkService
Constructors¶
Methods¶
MotechOsgiWebApplicationContext¶
- public class MotechOsgiWebApplicationContext extends OsgiBundleXmlApplicationContext implements ConfigurableWebApplicationContext¶
Methods¶
getServletConfig¶
- public ServletConfig getServletConfig()¶
getServletContext¶
- public ServletContext getServletContext()¶
setServletConfig¶
- public void setServletConfig(ServletConfig servletConfig)¶
setServletContext¶
- public void setServletContext(ServletContext servletContext)¶
OsgiDispatcherServlet¶
- public class OsgiDispatcherServlet extends DispatcherServlet¶
Constructors¶
OsgiDispatcherServlet¶
- public OsgiDispatcherServlet(BundleContext bundleContext)¶
OsgiDispatcherServlet¶
- public OsgiDispatcherServlet(BundleContext bundleContext, ConfigurableWebApplicationContext configurableWebApplicationContext)¶
OsgiWebApplicationContext¶
- public class OsgiWebApplicationContext implements WebApplicationContext¶
Constructors¶
OsgiWebApplicationContext¶
- public OsgiWebApplicationContext(ApplicationContext applicationContext, ConfigurableWebApplicationContext configurableWebApplicationContext)¶
Methods¶
findAnnotationOnBean¶
getAutowireCapableBeanFactory¶
- public AutowireCapableBeanFactory getAutowireCapableBeanFactory()¶
getBeanNamesForType¶
getBeansOfType¶
getBeansWithAnnotation¶
getClassLoader¶
- public ClassLoader getClassLoader()¶
getEnvironment¶
- public ConfigurableEnvironment getEnvironment()¶
getMessage¶
getMessage¶
- public String getMessage(MessageSourceResolvable resolvable, Locale locale)¶
getParent¶
- public ApplicationContext getParent()¶
getParentBeanFactory¶
- public BeanFactory getParentBeanFactory()¶
getServletContext¶
- public ServletContext getServletContext()¶
publishEvent¶
- public void publishEvent(ApplicationEvent event)¶
UIFrameworkService¶
- public interface UIFrameworkService¶
Service responsible for managing the interface. Provides methods for registering/un-registering modules. All modules are represented by ModuleRegistrationData objects, either registered directly through this service or automatically by exposing it in their spring context. This service also allows manipulation of module state, by marking given modules as requiring attention on the UI.
Methods¶
getModuleData¶
- ModuleRegistrationData getModuleData(String moduleName)¶
getModuleDataByAngular¶
- ModuleRegistrationData getModuleDataByAngular(String angularModule)¶
getModuleDataByBundle¶
- ModuleRegistrationData getModuleDataByBundle(Bundle bundle)¶
getRegisteredModules¶
- Map<String, Collection<ModuleRegistrationData>> getRegisteredModules()¶
registerModule¶
- void registerModule(ModuleRegistrationData module)¶
UIServiceTracker¶
- public class UIServiceTracker extends ServiceTracker¶
Constructors¶
UIServiceTracker¶
- public UIServiceTracker(BundleContext context, ModuleRegistrationData moduleRegistrationData)¶
UIServiceTracker¶
- public UIServiceTracker(BundleContextWrapper wrapper, ModuleRegistrationData moduleRegistrationData)¶
UIServiceTrackers¶
- public class UIServiceTrackers¶
Methods¶
addTrackerFor¶
- public UIServiceTracker addTrackerFor(Bundle bundle, ApplicationContext applicationContext)¶
removeTrackerFor¶
- public UIServiceTracker removeTrackerFor(Bundle bundle)¶
WebUIBundleActivator¶
org.motechproject.osgi.web.exception¶
RenderException¶
ServletRegistrationException¶
- public class ServletRegistrationException extends RuntimeException¶
org.motechproject.osgi.web.ext¶
FileSystemAwareUIHttpContext¶
- public class FileSystemAwareUIHttpContext extends UiHttpContext¶
Constructors¶
FileSystemAwareUIHttpContext¶
- public FileSystemAwareUIHttpContext(HttpContext context, String resourceRootDirectoryPath)¶
HttpContextFactory¶
- public final class HttpContextFactory¶
Methods¶
getHttpContext¶
- public static HttpContext getHttpContext(HttpContext httpContext, Bundle bundle)¶
UiHttpContext¶
- public class UiHttpContext implements HttpContext¶
Constructors¶
UiHttpContext¶
- public UiHttpContext(HttpContext context)¶
org.motechproject.osgi.web.service¶
ServerLogService¶
- public interface ServerLogService¶
Interface for accessing Logger’s configuration from the saved properties
Methods¶
getAllLogMappings¶
- List<LogMapping> getAllLogMappings()¶
getLogLevels¶
- List<LogMapping> getLogLevels()¶
getRootLogLevel¶
- LogMapping getRootLogLevel()¶
org.motechproject.osgi.web.settings¶
Loggers¶
- public class Loggers¶
Loggers class that holds information about all loggers in our system.
Constructors¶
Loggers¶
- public Loggers(List<LogMapping> loggers, LogMapping root)¶
Methods¶
getLoggers¶
- public List<LogMapping> getLoggers()¶
getRoot¶
- public LogMapping getRoot()¶
getTrash¶
- public List<LogMapping> getTrash()¶
setLoggers¶
- public void setLoggers(List<LogMapping> loggers)¶
setRoot¶
- public void setRoot(LogMapping root)¶
setTrash¶
- public void setTrash(List<LogMapping> trash)¶
org.motechproject.osgi.web.util¶
BundleHeaders¶
- public class BundleHeaders¶
Constructors¶
BundleHeaders¶
- public BundleHeaders(BundleContext bundleContext)¶
Methods¶
WebBundleUtil¶
- public final class WebBundleUtil¶
Utility class that’s purpose is easing bundle related operations/searches.
org.motechproject.scheduler.builder¶
org.motechproject.scheduler.contract¶
CronJobId¶
CronSchedulableJob¶
- public class CronSchedulableJob implements Serializable¶
Schedulable Job - a data carrier class for a scheduled job that can be fired unlimited number of times as specified with the cron expression
Author: Igor (iopushnyev@2paths.com) Date: 16/02/11 Time: 1:43 PM
Constructors¶
CronSchedulableJob¶
- public CronSchedulableJob(MotechEvent motechEvent, String cronExpression, Date startTime, Date endTime)¶
CronSchedulableJob¶
- public CronSchedulableJob(MotechEvent motechEvent, String cronExpression)¶
Methods¶
getMotechEvent¶
- public MotechEvent getMotechEvent()¶
DayOfWeekSchedulableJob¶
- public final class DayOfWeekSchedulableJob implements Serializable¶
Job that is scheduled on particular days of week
Methods¶
getMotechEvent¶
- public MotechEvent getMotechEvent()¶
EventInfo¶
- public class EventInfo¶
EventInfo is the class which contains information about event associated with scheduled job.
JobBasicInfo¶
- public class JobBasicInfo¶
JobBasicInfo is the class which contains information about scheduled job and its current state.
Fields¶
Constructors¶
Methods¶
JobDetailedInfo¶
- public class JobDetailedInfo¶
JobDetailedInfo is the class which wraps the EventInfo list.
See also: EventInfo
Constructors¶
JobId¶
- public abstract class JobId implements Serializable¶
Constructors¶
JobId¶
- public JobId(MotechEvent motechEvent, String suffix)¶
RepeatingJobId¶
RepeatingSchedulableJob¶
- public class RepeatingSchedulableJob implements Serializable¶
Schedulable Job - a data carrier class for a scheduled job that can be fired set number of times
Methods¶
getMotechEvent¶
- public MotechEvent getMotechEvent()¶
setEndTime¶
- public RepeatingSchedulableJob setEndTime(Date endTime)¶
setIgnorePastFiresAtStart¶
- public RepeatingSchedulableJob setIgnorePastFiresAtStart(boolean ignorePastFiresAtStart)¶
Ignore past fires when start time of job is in past.
ex : repeating job with interval of 5 unit, and current time in between fire 2 and 3 will start triggering from 3rd firetime. 1 2 3 4 |-----|-----|-----| start ^current time
Parameters: - ignorePastFiresAtStart –
setMotechEvent¶
- public RepeatingSchedulableJob setMotechEvent(MotechEvent motechEvent)¶
setRepeatCount¶
- public RepeatingSchedulableJob setRepeatCount(Integer repeatCount)¶
setRepeatIntervalInMilliSeconds¶
- public RepeatingSchedulableJob setRepeatIntervalInMilliSeconds(Long repeatIntervalInMilliSeconds)¶
setStartTime¶
- public RepeatingSchedulableJob setStartTime(Date startTime)¶
setUseOriginalFireTimeAfterMisfire¶
- public RepeatingSchedulableJob setUseOriginalFireTimeAfterMisfire(boolean useOriginalFireTimeAfterMisfire)¶
RunOnceJobId¶
RunOnceSchedulableJob¶
- public final class RunOnceSchedulableJob implements Serializable¶
Run Once Schedulable Job - a data carrier class for a job scheduled in the future that can be fired only once
This class is immutable
User: Igor (iopushnyev@2paths.com) Date: 16/02/11 Time: 1:43 PM
Constructors¶
RunOnceSchedulableJob¶
- public RunOnceSchedulableJob(MotechEvent motechEvent, Date startDate)¶
Constructor
Parameters: - motechEvent –
- event data message that will be send by Motech Scheduler when this job is fired
- startDate –
- date and time when the job fill be fired
Throws: - IllegalArgumentException – if motechEvent or startDate is null or startDate is in past
- motechEvent –
org.motechproject.scheduler.exception¶
MotechSchedulerException¶
- public class MotechSchedulerException extends RuntimeException¶
User: Igor (iopushnyev@2paths.com) Date: 17/02/11 Time: 4:20 PM
Constructors¶
SchedulerInstantiationException¶
- public class SchedulerInstantiationException extends RuntimeException¶
org.motechproject.scheduler.factory¶
MotechSchedulerFactoryBean¶
- public class MotechSchedulerFactoryBean¶
The MotechSchedulerFactoryBean is used to created scheduler and start it.
Constructors¶
MotechSchedulerFactoryBean¶
- public MotechSchedulerFactoryBean(ApplicationContext applicationContext, Properties schedulerProperties)¶
org.motechproject.scheduler.service¶
MotechSchedulerActionProxyService¶
- public interface MotechSchedulerActionProxyService¶
MotechSchedulerService¶
- public interface MotechSchedulerService¶
ingroup scheduler Motech Scheduler Service Interface provides methods to schedule reschedule and unschedule a job Set a global policy that determines trigger fire behaviour for misfired triggers. For details see quartz documentations for misfire policy do_nothing -> @see CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING fire_once_now -> @see CronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW ignore -> @see CronTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY fire_now -> @see SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW ignore -> @see SimpleTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY reschedule_next_with_existing_count -> @see SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT reschedule_next_with_remaining_count -> @see SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT reschedule_now_with_existing_count -> @see SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT reschedule_now_with_remaining_count -> @see SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT Scheduler can use couchdb for its job store. To enable set the following properties org.quartz.jobStore.class = org.motechproject.quartz.CouchDbStore org.quartz.jobStore.dbNameGenerator = org.motechproject.scheduler.service.impl.MultiTenantQuartzDatabaseName # provides database names for the jobstore, used in a multi-tenant environment to have separate databases for each tenant; leave blank to use a single database org.quartz.jobStore.properties = # a couchdb.properties file understood by ektorp to specify the database environment
Author: Igor (iopushnyev@2paths.com) Date: 16/02/11
Methods¶
getScheduledJobDetailedInfo¶
- JobDetailedInfo getScheduledJobDetailedInfo(JobBasicInfo jobBasicInfo)¶
getScheduledJobTimings¶
getScheduledJobTimingsWithPrefix¶
getScheduledJobsBasicInfo¶
- List<JobBasicInfo> getScheduledJobsBasicInfo()¶
rescheduleJob¶
- void rescheduleJob(String subject, String externalId, String cronExpression)¶
Reschedules a job with the given job ID to be fired according to the given Cron Expression Previous version of the configured Motech Scheduled Even that will be created when the job is fired remains us it was
Parameters: - subject –
- externalId –
- cronExpression –
safeScheduleJob¶
- void safeScheduleJob(CronSchedulableJob cronSchedulableJob)¶
Same as scheduleJob, except that it would update existing job if one exists instead of creating a new one
Parameters: - cronSchedulableJob –
safeScheduleRepeatingJob¶
- void safeScheduleRepeatingJob(RepeatingSchedulableJob repeatingSchedulableJob)¶
Same as safeScheduleRepeatingJob with intervening = true
Parameters: - repeatingSchedulableJob –
safeScheduleRunOnceJob¶
- void safeScheduleRunOnceJob(RunOnceSchedulableJob schedulableJob)¶
Same as scheduleRunOnceJob, except that it would update existing job if one exists instead of creating a new one
Parameters: - schedulableJob –
safeUnscheduleJob¶
safeUnscheduleRepeatingJob¶
safeUnscheduleRunOnceJob¶
scheduleDayOfWeekJob¶
- void scheduleDayOfWeekJob(DayOfWeekSchedulableJob dayOfWeekSchedulableJob)¶
Same as safeScheduleDayOfWeekJob with intervening = true
Parameters: - dayOfWeekSchedulableJob –
scheduleJob¶
- void scheduleJob(CronSchedulableJob cronSchedulableJob)¶
Schedules the given schedulable job. The Job ID by which the job will be referencing in the future should be provided in an Instance of MotechEvent in SchedulableJob (see MotechEvent.jobId) If a job with the same job ID as the given exists, this job will be unscheduled and the given schedulable job will be scheduled
Parameters: - cronSchedulableJob –
scheduleRepeatingJob¶
- void scheduleRepeatingJob(RepeatingSchedulableJob repeatingSchedulableJob)¶
Schedules the given schedulable job. The Job ID by which the job will be referencing in the future should be provided in an Instance of MotechEvent in SchedulableJob (see MotechEvent.jobId) If a job with the same job ID as the given exists, this job will be unscheduled and the given schedulable job will be scheduled
Parameters: - repeatingSchedulableJob –
scheduleRunOnceJob¶
- void scheduleRunOnceJob(RunOnceSchedulableJob schedulableJob)¶
unscheduleJob¶
unscheduleRunOnceJob¶
updateScheduledJob¶
- void updateScheduledJob(MotechEvent motechEvent)¶
Updates MotechEvent data of the job defined by jobIb in the given instance of that class
Parameters: - motechEvent –
org.motechproject.scheduler.service.impl¶
MotechScheduler¶
- public final class MotechScheduler¶
ingroup scheduler
Main class that can bootstrap a Motech Scheduler
Author: Igor (iopushnyev@2paths.com)
MotechSchedulerActionProxyServiceImpl¶
- public class MotechSchedulerActionProxyServiceImpl implements MotechSchedulerActionProxyService¶
Constructors¶
MotechSchedulerActionProxyServiceImpl¶
- public MotechSchedulerActionProxyServiceImpl(MotechSchedulerService schedulerService)¶
MotechSchedulerServiceImpl¶
- public class MotechSchedulerServiceImpl implements MotechSchedulerService¶
Motech Scheduler Service implementation
See also: MotechSchedulerService
Constructors¶
MotechSchedulerServiceImpl¶
- public MotechSchedulerServiceImpl(MotechSchedulerFactoryBean motechSchedulerFactoryBean, SettingsFacade schedulerSettings)¶
Methods¶
getScheduledJobDetailedInfo¶
- public JobDetailedInfo getScheduledJobDetailedInfo(JobBasicInfo jobBasicInfo)¶
getScheduledJobTimings¶
getScheduledJobTimingsWithPrefix¶
getScheduledJobsBasicInfo¶
- public List<JobBasicInfo> getScheduledJobsBasicInfo()¶
safeScheduleJob¶
- public void safeScheduleJob(CronSchedulableJob cronSchedulableJob)¶
safeScheduleRepeatingJob¶
- public void safeScheduleRepeatingJob(RepeatingSchedulableJob repeatingSchedulableJob)¶
safeScheduleRunOnceJob¶
- public void safeScheduleRunOnceJob(RunOnceSchedulableJob schedulableJob)¶
safeUnscheduleRepeatingJob¶
scheduleDayOfWeekJob¶
- public void scheduleDayOfWeekJob(DayOfWeekSchedulableJob dayOfWeekSchedulableJob)¶
scheduleJob¶
- public void scheduleJob(CronSchedulableJob cronSchedulableJob)¶
scheduleRepeatingJob¶
- public void scheduleRepeatingJob(RepeatingSchedulableJob repeatingSchedulableJob)¶
scheduleRunOnceJob¶
- public void scheduleRunOnceJob(RunOnceSchedulableJob schedulableJob)¶
updateScheduledJob¶
- public void updateScheduledJob(MotechEvent motechEvent)¶
org.motechproject.security.annotations¶
SecurityAnnotationBeanPostProcessor¶
- public class SecurityAnnotationBeanPostProcessor implements BeanPostProcessor¶
A BeanPostProcessor used by Motech to load permissions from modules. Given a module context, it looks for PreAuthorize and PostAuthorize annotations. These annotations are then parsed using an ExpressionParser. The permission names are deduced from hasRole and hasAnyRole in the annotation value. The names of permissions are then saved using the MotechPermissionService. The bundle name used to construct the permission is retrieved from the application context.
Constructors¶
SecurityAnnotationBeanPostProcessor¶
- public SecurityAnnotationBeanPostProcessor(MotechPermissionService permissionService)¶
org.motechproject.security.authentication¶
MotechAccessVoter¶
- public class MotechAccessVoter implements AccessDecisionVoter<Object>¶
A custom AccessDecisionVoter for voting on whether a specific user has access to a particular URL. For example, a security rule can specify that the users motech and admin have access to a particular URL. This loads the metadata source with attributes for ACCESS_motech and ACCESS_admin. When a user invokes that URL, an affirmative based voting system will check whether or not the user is motech or admin. If not, they are denied permission, otherwise they are granted access.
Methods¶
supports¶
- public boolean supports(ConfigAttribute attribute)¶
vote¶
- public int vote(Authentication authentication, Object object, Collection<ConfigAttribute> attributes)¶
MotechBasicAuthenticationEntryPoint¶
- public class MotechBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoint¶
An entry point for BASIC authentications, sets the correct server realm key.
Constructors¶
MotechBasicAuthenticationEntryPoint¶
- public MotechBasicAuthenticationEntryPoint(SettingsFacade settingsFacade)¶
MotechLoginUrlAuthenticationEntryPoint¶
- public class MotechLoginUrlAuthenticationEntryPoint extends LoginUrlAuthenticationEntryPoint¶
Methods¶
commence¶
- public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException)¶
MotechLogoutSuccessHandler¶
- public class MotechLogoutSuccessHandler implements LogoutHandler¶
A logout handler for removing Motech user sessions from Motech’s internally kept session handler. This is invoked when a user logs out.
Methods¶
logout¶
- public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication)¶
MotechPasswordEncoder¶
- public class MotechPasswordEncoder extends BCryptPasswordEncoder¶
MotechRestBasicAuthenticationEntryPoint¶
- public class MotechRestBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoint¶
A custom entry point that is invoked when there is an authentication exception within the filter. This ensures that when a user does not have login privileges and are unable to authenticate, a 401 unauthorized response is returned.
Constructors¶
MotechRestBasicAuthenticationEntryPoint¶
- public MotechRestBasicAuthenticationEntryPoint(SettingsFacade settingsFacade)¶
Methods¶
commence¶
- public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException)¶
MotechSuccessHandler¶
- public class MotechSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler¶
Methods¶
onAuthenticationSuccess¶
- public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)¶
org.motechproject.security.builder¶
SecurityRuleBuilder¶
- public class SecurityRuleBuilder¶
The security rule builder is responsible for building a SecurityFilterChain, which consists of a matcher pattern and a list of Spring security filters. The filters are created and configured base upon the security rule’s settings.
Methods¶
buildSecurityChain¶
- public synchronized SecurityFilterChain buildSecurityChain(MotechURLSecurityRule securityRule, HTTPMethod method)¶
setAuthenticationManager¶
- public void setAuthenticationManager(AuthenticationManager authenticationManager)¶
setBasicAuthenticationEntryPoint¶
- public void setBasicAuthenticationEntryPoint(AuthenticationEntryPoint basicAuthenticationEntryPoint)¶
setChannelDecisionManager¶
- public void setChannelDecisionManager(ChannelDecisionManager channelDecisionManager)¶
setLoginAuthenticationEntryPoint¶
- public void setLoginAuthenticationEntryPoint(AuthenticationEntryPoint loginAuthenticationEntryPoint)¶
setMotechLogoutHandler¶
- public void setMotechLogoutHandler(MotechLogoutSuccessHandler motechLogoutHandler)¶
setOpenIDAuthenticationFilter¶
- public void setOpenIDAuthenticationFilter(OpenIDAuthenticationFilter openIDAuthenticationFilter)¶
setSettingsFacade¶
- public void setSettingsFacade(SettingsFacade settingsFacade)¶
setUsernamePasswordAuthenticationFilter¶
- public void setUsernamePasswordAuthenticationFilter(UsernamePasswordAuthenticationFilter usernamePasswordAuthenticationFilter)¶
org.motechproject.security.constants¶
HTTPMethod¶
- public enum HTTPMethod¶
Enumeration of HTTP request method.
Enum Constants¶
ANY¶
- public static final HTTPMethod ANY¶
DELETE¶
- public static final HTTPMethod DELETE¶
GET¶
- public static final HTTPMethod GET¶
HEAD¶
- public static final HTTPMethod HEAD¶
OPTIONS¶
- public static final HTTPMethod OPTIONS¶
POST¶
- public static final HTTPMethod POST¶
PUT¶
- public static final HTTPMethod PUT¶
TRACE¶
- public static final HTTPMethod TRACE¶
org.motechproject.security.domain¶
MotechSecurityConfiguration¶
- public class MotechSecurityConfiguration¶
The MotechSecurityConfiguration is a single document that contains all of the URL security rule configuration. The configuration was designed as one document because the entire filter chain must be reconstructed each time it is updated, therefore managing many references is unnecessary.
Constructors¶
MotechSecurityConfiguration¶
- public MotechSecurityConfiguration(List<MotechURLSecurityRule> securityRules)¶
Methods¶
getSecurityRules¶
- public List<MotechURLSecurityRule> getSecurityRules()¶
setSecurityRules¶
- public void setSecurityRules(List<MotechURLSecurityRule> securityRules)¶
MotechURLSecurityRule¶
- public class MotechURLSecurityRule¶
The MotechURLSecurityRule specifies the configuration for setting up a Spring SecurityFilterChain.
Details regarding configuration:
- pattern - URL pattern the security rule applies to
- supportedSchemes - Security rules that should apply to the URL, such as BASIC or OPEN_ID
- protocol - Protocol the security rule applies to, such as HTTP or HTTPS
- permissionAccess - Requires user has at least one of the listed permission to access the URL
- userAccess - User specific access for a URL, such as motech or admin, when combined with permission access they act as an either or (one must be true)
- priority - For future use in determining the ordering of filter chains, may be deprecated depending on UI implementation
- rest - Whether the endpoint is meant for a form login process or as an REST end-point that does not create a session for the
- origin - The module or user the rule originated from
- version - The version of the module or platform the rule was created
- methodsRequired - HTTP methods the rule applies to, if ANY is used then any method is matched, if a set is used, such as GET, POST, etc, then each will have its own corresponding filter chain with the same security found in that rule
Methods¶
getMethodsRequired¶
- public List<HTTPMethod> getMethodsRequired()¶
setMethodsRequired¶
- public void setMethodsRequired(List<HTTPMethod> methodsRequired)¶
MotechUserProfile¶
- public class MotechUserProfile implements Serializable¶
Constructors¶
MotechUserProfile¶
- public MotechUserProfile(MotechUser user)¶
org.motechproject.security.ex¶
EmailExistsException¶
- public class EmailExistsException extends RuntimeException¶
InvalidTokenException¶
NonAdminUserException¶
RoleHasUserException¶
- public class RoleHasUserException extends RuntimeException¶
Represents a failed attempt to delete a role currently assigned to a user.
SecurityConfigException¶
- public class SecurityConfigException extends RuntimeException¶
A runtime exception thrown when the security config does not pass validation constraints required in order to construct a new security chain. Ideally should not be thrown as the UI should not allow invalid data to be submitted.
org.motechproject.security.model¶
PermissionDto¶
- public class PermissionDto implements Serializable¶
The PermissionDto contains information about permission.
Constructors¶
PermissionDto¶
- public PermissionDto(MotechPermission motechPermission)¶
Methods¶
RoleDto¶
- public class RoleDto¶
Transfer Motech role data between representations.
Role data transfer object facilitates exchange of role data among services, repository, and client user interface.
Constructors¶
RoleDto¶
- public RoleDto(MotechRole motechRole)¶
Methods¶
SecurityConfigDto¶
- public class SecurityConfigDto¶
Used to transfer security configuration to and from a web request and UI
Methods¶
getSecurityRules¶
- public List<SecurityRuleDto> getSecurityRules()¶
setSecurityRules¶
- public void setSecurityRules(List<SecurityRuleDto> securityRules)¶
SecurityRuleDto¶
- public class SecurityRuleDto¶
Transfer Motech security rule data between representations.
Methods¶
org.motechproject.security.repository¶
AllMotechPermissions¶
- public class AllMotechPermissions¶
Methods¶
add¶
- public void add(MotechPermission permission)¶
delete¶
- public void delete(MotechPermission permission)¶
findByPermissionName¶
- public MotechPermission findByPermissionName(String permissionName)¶
getPermissions¶
- public List<MotechPermission> getPermissions()¶
setDataService¶
- public void setDataService(MotechPermissionsDataService dataService)¶
AllMotechRoles¶
- public class AllMotechRoles¶
Methods¶
add¶
- public void add(MotechRole role)¶
findByRoleName¶
- public MotechRole findByRoleName(String roleName)¶
getRoles¶
- public List<MotechRole> getRoles()¶
remove¶
- public void remove(MotechRole motechRole)¶
setDataService¶
- public void setDataService(MotechRolesDataService dataService)¶
update¶
- public void update(MotechRole motechRole)¶
AllMotechSecurityRules¶
- public class AllMotechSecurityRules¶
Implementation of DAO interface that utilizes a MDS back-end for storage. Only one MotechSecurityConfiguration file should be saved at a time, so adding the document looks for the old document in order to update it if it already exists. Rather than updating the object reference, the old configuration’s ID and revision are used for the new document.
Methods¶
addOrUpdate¶
- public void addOrUpdate(MotechSecurityConfiguration config)¶
getMotechSecurityConfiguration¶
- public MotechSecurityConfiguration getMotechSecurityConfiguration()¶
getRuleById¶
- public MotechURLSecurityRule getRuleById(Long id)¶
getRules¶
- public List<MotechURLSecurityRule> getRules()¶
getRulesByOrigin¶
- public List<MotechURLSecurityRule> getRulesByOrigin(String origin)¶
remove¶
- public void remove(MotechSecurityConfiguration config)¶
setDataService¶
- public void setDataService(MotechURLSecurityRuleDataService dataService)¶
AllMotechUsers¶
- public class AllMotechUsers¶
Methods¶
add¶
- public void add(MotechUser user)¶
addOpenIdUser¶
- public void addOpenIdUser(MotechUser user)¶
findByRole¶
- public List<MotechUser> findByRole(String role)¶
findByUserName¶
- public MotechUser findByUserName(String userName)¶
findUserByEmail¶
- public MotechUser findUserByEmail(String email)¶
findUserByOpenId¶
- public MotechUser findUserByOpenId(String openId)¶
getOpenIdUsers¶
- public List<MotechUser> getOpenIdUsers()¶
getUsers¶
- public List<MotechUser> getUsers()¶
remove¶
- public void remove(MotechUser motechUser)¶
setDataService¶
- public void setDataService(MotechUsersDataService dataService)¶
update¶
- public void update(MotechUser motechUser)¶
AllPasswordRecoveries¶
- public class AllPasswordRecoveries¶
Methods¶
add¶
- public void add(PasswordRecovery passwordRecovery)¶
allRecoveries¶
- public List<PasswordRecovery> allRecoveries()¶
createRecovery¶
findForToken¶
- public PasswordRecovery findForToken(String token)¶
findForUser¶
- public PasswordRecovery findForUser(String username)¶
getExpired¶
- public List<PasswordRecovery> getExpired()¶
remove¶
- public void remove(PasswordRecovery passwordRecovery)¶
setDataService¶
- public void setDataService(PasswordRecoveriesDataService dataService)¶
update¶
- public void update(PasswordRecovery passwordRecovery)¶
MotechPermissionsDataService¶
- public interface MotechPermissionsDataService extends MotechDataService<MotechPermission>¶
Methods¶
findByPermissionName¶
- MotechPermission findByPermissionName(String permissionName)¶
MotechRolesDataService¶
- public interface MotechRolesDataService extends MotechDataService<MotechRole>¶
Methods¶
findByRoleName¶
- MotechRole findByRoleName(String roleName)¶
MotechURLSecurityRuleDataService¶
- public interface MotechURLSecurityRuleDataService extends MotechDataService<MotechURLSecurityRule>¶
MotechUsersDataService¶
- public interface MotechUsersDataService extends MotechDataService<MotechUser>¶
Methods¶
findByEmail¶
- MotechUser findByEmail(String email)¶
findByOpenId¶
- MotechUser findByOpenId(String openId)¶
findByRole¶
- List<MotechUser> findByRole(String role)¶
findByUserName¶
- MotechUser findByUserName(String userName)¶
PasswordRecoveriesDataService¶
- public interface PasswordRecoveriesDataService extends MotechDataService<PasswordRecovery>¶
Methods¶
findForToken¶
- PasswordRecovery findForToken(String token)¶
findForUser¶
- PasswordRecovery findForUser(String username)¶
org.motechproject.security.service¶
AuthoritiesService¶
- public interface AuthoritiesService¶
Service interface to retrieve authorities(permissions) for a given MotechUser
MotechPermissionService¶
- public interface MotechPermissionService¶
Service for managing Motech permissions.
MotechProxyManager¶
- public class MotechProxyManager¶
The MotechProxyManager acts as a wrapper around Spring’s FilterChainProxy. The FilterChainProxy contains a list of immutable SecurityFilterChain objects which Spring’s security consults for filters when handling requests. In order to dynamically define new secure, a new FilterChainProxy is constructed and the reference is updated. The MotechProxyManager acts as a customized delegate in MotechDelegatingFilterProxy.
Methods¶
getDefaultSecurityConfiguration¶
- public MotechSecurityConfiguration getDefaultSecurityConfiguration()¶
This method reads default security configuration from the file containing security rules and returns it.
Returns: MotechSecurityConfiguration default security rules
getFilterChainProxy¶
- public FilterChainProxy getFilterChainProxy()¶
initializeProxyChain¶
- public void initializeProxyChain()¶
This method serves the same purpose of rebuildProxyChain, but does not require any kind of security authentication so it should only ever be used by the activator, which does not have an authentication object.
rebuildProxyChain¶
- public synchronized void rebuildProxyChain()¶
Method to invoke to dynamically re-define the Spring security. All rules converted into security filter chains in order to create a new FilterChainProxy. The order of the rules in the list matters for filtering purposes.
setProxy¶
- public void setProxy(FilterChainProxy proxy)¶
setSecurityRuleBuilder¶
- public void setSecurityRuleBuilder(SecurityRuleBuilder securityRuleBuilder)¶
setSecurityRulesDAO¶
- public void setSecurityRulesDAO(AllMotechSecurityRules securityRulesDAO)¶
MotechURLSecurityService¶
- public interface MotechURLSecurityService¶
Service to access and update security configuration details from the platform. Permission based, method level security is defined to prevent unauthorized users from updating security.
Methods¶
findAllSecurityRules¶
- List<SecurityRuleDto> findAllSecurityRules()¶
A protected method for viewing security rule information for the platform.
Returns: All URL security rules found in the database
updateSecurityConfiguration¶
- void updateSecurityConfiguration(SecurityConfigDto configuration)¶
A protected method for updating security configuration for the platform.
Parameters: - configuration – The updated security information, which will cause an updating of the motech proxy manager
MotechUserService¶
- public interface MotechUserService¶
Service interface that defines APIs to retrieve and manage user details
Methods¶
changePassword¶
- MotechUserProfile changePassword(String username, String oldPassword, String newPassword)¶
getOpenIdUsers¶
- List<MotechUserProfile> getOpenIdUsers()¶
getUsers¶
- List<MotechUserProfile> getUsers()¶
register¶
register¶
retrieveUserByCredentials¶
- MotechUserProfile retrieveUserByCredentials(String username, String password)¶
PasswordRecoveryService¶
- public interface PasswordRecoveryService¶
Methods¶
validateTokenAndLoginUser¶
- void validateTokenAndLoginUser(String token, HttpServletRequest request, HttpServletResponse response)¶
SecurityRoleLoader¶
- public class SecurityRoleLoader¶
Constructors¶
SecurityRoleLoader¶
- public SecurityRoleLoader(MotechRoleService roleService)¶
Methods¶
loadRoles¶
- public void loadRoles(ApplicationContext applicationContext)¶
SecurityRuleLoader¶
- public class SecurityRuleLoader¶
Helper class that scans an application context for security rules and re-initializes the MotechProxyManager security chain.
Methods¶
loadRules¶
- public synchronized void loadRules(ApplicationContext applicationContext)¶
Attempts to load rules from the application context, if rules are found, the security configuration is updated. Synchronized so there are not race conditions on the data.
setAllSecurityRules¶
- public void setAllSecurityRules(AllMotechSecurityRules allSecurityRules)¶
setProxyManager¶
- public void setProxyManager(MotechProxyManager proxyManager)¶
org.motechproject.server.api¶
BundleInformation.State¶
- public enum State¶
Represents the bundle state.
Enum Constants¶
ACTIVE¶
- public static final BundleInformation.State ACTIVE¶
INSTALLED¶
- public static final BundleInformation.State INSTALLED¶
RESOLVED¶
- public static final BundleInformation.State RESOLVED¶
STARTING¶
- public static final BundleInformation.State STARTING¶
STOPPING¶
- public static final BundleInformation.State STOPPING¶
UNINSTALLED¶
- public static final BundleInformation.State UNINSTALLED¶
UNKNOWN¶
- public static final BundleInformation.State UNKNOWN¶
BundleLoader¶
- public interface BundleLoader¶
Interface for custom bundle loading processes
Author: Ricky Wang
BundleLoadingException¶
org.motechproject.server.config¶
SettingsFacade¶
- public class SettingsFacade¶
SettingsFacade provides an interface to access application configuration present in files or database
Methods¶
asProperties¶
- public Properties asProperties()¶
getActivemqConfig¶
- public Properties getActivemqConfig()¶
getPlatformSettings¶
- public MotechSettings getPlatformSettings()¶
getProperties¶
- public Properties getProperties(String filename)¶
getRawConfig¶
- public InputStream getRawConfig(String filename)¶
registerProperties¶
- protected void registerProperties(String filename, Properties properties)¶
saveConfigProperties¶
- public void saveConfigProperties(String filename, Properties properties)¶
savePlatformSettings¶
- public void savePlatformSettings(MotechSettings settings)¶
setConfigurationService¶
- public void setConfigurationService(ConfigurationService configurationService)¶
org.motechproject.server.config.domain¶
MotechSettings¶
- public interface MotechSettings¶
Interface for main motech settings managment
Methods¶
asProperties¶
- Properties asProperties()¶
getActivemqProperties¶
- Properties getActivemqProperties()¶
load¶
- void load(DigestInputStream dis)¶
updateFromProperties¶
- void updateFromProperties(Properties props)¶
updateSettings¶
- void updateSettings(String configFileChecksum, String filePath, Properties platformSettings)¶
SettingsRecord¶
- public class SettingsRecord implements MotechSettings¶
Class for storing settings values
Methods¶
asProperties¶
- public Properties asProperties()¶
getActivemqProperties¶
- public Properties getActivemqProperties()¶
load¶
- public synchronized void load(DigestInputStream dis)¶
mergeWithDefaults¶
- public void mergeWithDefaults(Properties defaultConfig)¶
removeDefaults¶
- public void removeDefaults(Properties defaultConfig)¶
updateFromProperties¶
- public void updateFromProperties(Properties props)¶
updateSettings¶
- public void updateSettings(String configFileChecksum, String filePath, Properties platformSettings)¶
org.motechproject.server.config.service¶
ConfigLoader¶
- public class ConfigLoader¶
Config loader used to load the platform core settings.
Methods¶
findExistingConfigs¶
loadDefaultConfig¶
- public SettingsRecord loadDefaultConfig()¶
loadMotechSettings¶
- public SettingsRecord loadMotechSettings()¶
setCoreConfigurationService¶
- public void setCoreConfigurationService(CoreConfigurationService coreConfigurationService)¶
setEventAdmin¶
- public void setEventAdmin(EventAdmin eventAdmin)¶
setResourceLoader¶
- public void setResourceLoader(ResourceLoader resourceLoader)¶
PlatformSettingsService¶
- public interface PlatformSettingsService¶
Platform Settings service used to handle platform settings.
Methods¶
exportPlatformSettings¶
- Properties exportPlatformSettings()¶
SettingService¶
- public interface SettingService extends MotechDataService<SettingsRecord>¶
org.motechproject.server.startup¶
MotechPlatformState¶
- public enum MotechPlatformState¶
Defines the different states of the MOTECH system.
Enum Constants¶
DB_ERROR¶
- public static final MotechPlatformState DB_ERROR¶
FIRST_RUN¶
- public static final MotechPlatformState FIRST_RUN¶
NEED_BOOTSTRAP_CONFIG¶
- public static final MotechPlatformState NEED_BOOTSTRAP_CONFIG¶
NEED_CONFIG¶
- public static final MotechPlatformState NEED_CONFIG¶
NORMAL_RUN¶
- public static final MotechPlatformState NORMAL_RUN¶
NO_DB¶
- public static final MotechPlatformState NO_DB¶
STARTUP¶
- public static final MotechPlatformState STARTUP¶
StartupManager¶
- public class StartupManager¶
StartupManager controlling and managing the application loading
Methods¶
getDefaultSettings¶
- public SettingsRecord getDefaultSettings()¶
This function is only called when the default configuration is loaded and is no config in the database or external files
org.motechproject.server.ui¶
LocaleService¶
- public interface LocaleService¶
A service responsible for localization. Allows retrieval/settings of user language as well as retrieving localized messages for a user request. Can also be used to retrieve a list of usable languages.
Methods¶
getSupportedLanguages¶
- NavigableMap<String, String> getSupportedLanguages()¶
getUserLocale¶
- Locale getUserLocale(HttpServletRequest request)¶
setUserLocale¶
- void setUserLocale(HttpServletRequest request, HttpServletResponse response, Locale locale)¶
org.motechproject.server.ui.ex¶
org.motechproject.server.web.controller¶
DashboardController¶
- public class DashboardController¶
Main application controller. Responsible for retrieving information shared across the UI of different modules. The view returned by this controller will embed the UI of the currently requested module.
Methods¶
accessdenied¶
- public ModelAndView accessdenied(HttpServletRequest request)¶
getTime¶
- public String getTime(HttpServletRequest request)¶
getUser¶
- public UserInfo getUser(HttpServletRequest request)¶
index¶
- public ModelAndView index(HttpServletRequest request)¶
setBundleContext¶
- public void setBundleContext(BundleContext bundleContext)¶
setLocaleService¶
- public void setLocaleService(LocaleService localeService)¶
setStartupManager¶
- public void setStartupManager(StartupManager startupManager)¶
ForgotController¶
- public class ForgotController¶
Forgot Controller for reset password.
Methods¶
getForgotViewData¶
- public ForgotViewData getForgotViewData(HttpServletRequest request)¶
login¶
- public ModelAndView login(HttpServletRequest request)¶
LocaleController¶
- public class LocaleController¶
The LocaleController class is responsible for handling requests connected with internationalization
Methods¶
getSupportedLanguages¶
- public NavigableMap<String, String> getSupportedLanguages()¶
getUserLang¶
- public String getUserLang(HttpServletRequest request)¶
setUserLang¶
- public void setUserLang(HttpServletRequest request, HttpServletResponse response, String language, String country, String variant)¶
LoginController¶
- public class LoginController¶
Login Controller for user authentication.
Methods¶
getLoginViewData¶
- public LoginViewData getLoginViewData(HttpServletRequest request)¶
login¶
- public ModelAndView login(HttpServletRequest request)¶
ModuleController¶
- public class ModuleController¶
Methods¶
getUser¶
- public UserInfo getUser(HttpServletRequest request)¶
setBundleContext¶
- public void setBundleContext(BundleContext bundleContext)¶
setLocaleService¶
- public void setLocaleService(LocaleService localeService)¶
setUiFrameworkService¶
- public void setUiFrameworkService(UIFrameworkService uiFrameworkService)¶
ResetController¶
- public class ResetController¶
Methods¶
getResetViewData¶
- public ResetViewData getResetViewData(HttpServletRequest request)¶
reset¶
- public ResetViewData reset(ResetForm form, HttpServletRequest request)¶
resetView¶
- public ModelAndView resetView(HttpServletRequest request)¶
StartupController¶
- public class StartupController¶
StartupController that manages the platform system start up and captures the platform core settings and user information.
Methods¶
getStartupViewData¶
- public StartupViewData getStartupViewData(HttpServletRequest request)¶
setStartupFormValidatorFactory¶
- public void setStartupFormValidatorFactory(StartupFormValidatorFactory validatorFactory)¶
startup¶
- public ModelAndView startup()¶
submitForm¶
- public List<String> submitForm(StartupForm startupSettings)¶
org.motechproject.server.web.form¶
org.motechproject.server.web.helper¶
Header.HeaderOrder¶
- public static class HeaderOrder¶
Methods¶
getCss¶
- public List<ElementOrder> getCss()¶
getJs¶
- public List<ElementOrder> getJs()¶
getLib¶
- public List<ElementOrder> getLib()¶
setCss¶
- public void setCss(List<ElementOrder> css)¶
setJs¶
- public void setJs(List<ElementOrder> js)¶
setLib¶
- public void setLib(List<ElementOrder> lib)¶
org.motechproject.server.web.validator¶
AbstractValidator¶
- public interface AbstractValidator¶
Basic interface which startup settings validators implement
Methods¶
validate¶
- void validate(StartupForm target, List<String> errors, ConfigSource configSource)¶
OpenIdUserValidator¶
- public class OpenIdUserValidator implements AbstractValidator¶
Validates presence of OpenId related field values Also validates provider URL
Constructors¶
OpenIdUserValidator¶
- public OpenIdUserValidator(UrlValidator urlValidator)¶
Methods¶
validate¶
- public void validate(StartupForm target, List<String> errors, ConfigSource configSource)¶
PersistedUserValidator¶
- public class PersistedUserValidator implements AbstractValidator¶
Validates presence of admin user registration fields. Checks existence of user with identical name Checks existence of user with identical email Checks that password and confirmed password field are same.
Constructors¶
PersistedUserValidator¶
- public PersistedUserValidator(MotechUserService userService)¶
Methods¶
validate¶
- public void validate(StartupForm target, List<String> errors, ConfigSource configSource)¶
QueueURLValidator¶
- public class QueueURLValidator implements AbstractValidator¶
Validates presence of Queue URL and if present whether it is in expected format or not
Constructors¶
QueueURLValidator¶
- public QueueURLValidator(UrlValidator urlValidator)¶
Methods¶
validate¶
- public void validate(StartupForm target, List<String> errors, ConfigSource configSource)¶
RequiredFieldValidator¶
- public class RequiredFieldValidator implements AbstractValidator¶
Generic validator class that validates presence of a given field
Constructors¶
StartupFormValidator¶
- public class StartupFormValidator¶
StartupFormValidator validates user information during registration process
Methods¶
add¶
- public void add(AbstractValidator validator)¶
getValidators¶
- public List<AbstractValidator> getValidators()¶
validate¶
- public List<String> validate(StartupForm target, ConfigSource configSource)¶
StartupFormValidatorFactory¶
- public class StartupFormValidatorFactory¶
Factory to create startUpFormValidator with requisite validators. If Admin User exists,the admin user is not created so the relevant validators are not added.
Methods¶
getStartupFormValidator¶
- public StartupFormValidator getStartupFormValidator(StartupForm startupSettings, MotechUserService userService)¶
UserRegistrationValidator¶
- public class UserRegistrationValidator implements AbstractValidator¶
Validator to validate user registration details. Delegates to either @OpenIdUserValidator or @UserRegistrationValidator depending on login mode preference.
Constructors¶
UserRegistrationValidator¶
- public UserRegistrationValidator(PersistedUserValidator persistedUserValidator, OpenIdUserValidator openIdUserValidator)¶
Methods¶
validate¶
- public void validate(StartupForm target, List<String> errors, ConfigSource configSource)¶
org.motechproject.tasks.annotations¶
TaskActionParam¶
- public @interface TaskActionParam¶
Marks method parameter to be treated as action parameter.
Each parameter in the given method has to have this annotation otherwise it will be a problem with the proper execution of the channel action.
See also: TaskAction, TaskChannel, TaskAnnotationBeanPostProcessor
TaskAnnotationBeanPostProcessor¶
- public class TaskAnnotationBeanPostProcessor implements BeanPostProcessor¶
Factory class which is looking for classes with TaskChannel annotation to add them to the channel definition as channel action.
See also: TaskAction, TaskActionParam, TaskChannel
Constructors¶
TaskAnnotationBeanPostProcessor¶
- public TaskAnnotationBeanPostProcessor(BundleContext bundleContext, ChannelService channelService)¶
org.motechproject.tasks.contract¶
ActionEventRequest¶
- public class ActionEventRequest¶
Methods¶
addParameter¶
- public void addParameter(ActionParameterRequest parameter, boolean changeOrder)¶
getActionParameters¶
- public SortedSet<ActionParameterRequest> getActionParameters()¶
ActionParameterRequest¶
- public class ActionParameterRequest implements Comparable<ActionParameterRequest>¶
Object representation of a parameter in the channel action request definition.
See also: ActionEventRequest
Methods¶
compareTo¶
- public int compareTo(ActionParameterRequest o)¶
ChannelRequest¶
- public class ChannelRequest¶
Service layer object denoting a org.motechproject.tasks.domain.Channel. Used by ChannelService
Constructors¶
ChannelRequest¶
- public ChannelRequest(String displayName, String moduleName, String moduleVersion, String description, List<TriggerEventRequest> triggerTaskEvents, List<ActionEventRequest> actionTaskEvents)¶
Methods¶
getActionTaskEvents¶
- public List<ActionEventRequest> getActionTaskEvents()¶
getTriggerTaskEvents¶
- public List<TriggerEventRequest> getTriggerTaskEvents()¶
org.motechproject.tasks.domain¶
ActionEvent¶
Constructors¶
ActionEvent¶
ActionEvent¶
ActionEvent¶
ActionEvent¶
- public ActionEvent(ActionEventRequest actionEventRequest)¶
Methods¶
accept¶
- public boolean accept(TaskActionInformation info)¶
addParameter¶
- public void addParameter(ActionParameter parameter, boolean changeOrder)¶
getActionParameters¶
- public SortedSet<ActionParameter> getActionParameters()¶
setActionParameters¶
- public void setActionParameters(SortedSet<ActionParameter> actionParameters)¶
ActionParameter¶
- public class ActionParameter extends Parameter implements Comparable<ActionParameter>¶
Object representation of a parameter in the channel action definition.
See also: ActionEvent
Constructors¶
ActionParameter¶
- public ActionParameter(String displayName, String key, ParameterType type)¶
ActionParameter¶
- public ActionParameter(String displayName, String key, ParameterType type, boolean required)¶
ActionParameter¶
- public ActionParameter(String displayName, String key, ParameterType type, Integer order)¶
ActionParameter¶
- public ActionParameter(ActionParameterRequest actionParameterRequest)¶
Methods¶
compareTo¶
- public int compareTo(ActionParameter o)¶
Channel¶
- public class Channel¶
Constructors¶
Channel¶
- public Channel(String displayName, String moduleName, String moduleVersion, String description, List<TriggerEvent> triggerTaskEvents, List<ActionEvent> actionTaskEvents)¶
Channel¶
- public Channel(ChannelRequest channelRequest)¶
Methods¶
addActionTaskEvent¶
- public void addActionTaskEvent(ActionEvent actionEvent)¶
containsAction¶
- public boolean containsAction(TaskActionInformation actionInformation)¶
containsTrigger¶
- public boolean containsTrigger(TaskTriggerInformation triggerInformation)¶
getAction¶
- public ActionEvent getAction(TaskActionInformation actionInformation)¶
getActionTaskEvents¶
- public List<ActionEvent> getActionTaskEvents()¶
getTrigger¶
- public TriggerEvent getTrigger(TaskTriggerInformation triggerInformation)¶
getTriggerTaskEvents¶
- public List<TriggerEvent> getTriggerTaskEvents()¶
setActionTaskEvents¶
- public void setActionTaskEvents(List<ActionEvent> actionTaskEvents)¶
setTriggerTaskEvents¶
- public void setTriggerTaskEvents(List<TriggerEvent> triggerTaskEvents)¶
ChannelRegisterEvent¶
- public class ChannelRegisterEvent¶
A wrapper over a MotechEvent with subject {@value EventSubjects#CHANNEL_REGISTER_SUBJECT}. Raised when a channel is registered with the tasks module
Constructors¶
ChannelRegisterEvent¶
- public ChannelRegisterEvent(MotechEvent motechEvent)¶
EventParameter¶
Constructors¶
EventParameter¶
- public EventParameter(String displayName, String eventKey, ParameterType type)¶
EventParameter¶
- public EventParameter(EventParameterRequest eventParameterRequest)¶
FieldParameter¶
Filter¶
- public class Filter implements Serializable¶
Constructors¶
Filter¶
- public Filter(EventParameter eventParameter, boolean negationOperator, String operator, String expression)¶
FilterSet¶
- public class FilterSet extends TaskConfigStep¶
KeyInformation¶
- public final class KeyInformation¶
Object representation of dragged field from trigger or data source.
This class represents a single dragged field from trigger or data source. This class does not expose a public constructor. You have to use parse(String) method if you want to parse single field or parseAll(String) if you want ot get all fields from a given string.
Methods¶
fromAdditionalData¶
- public boolean fromAdditionalData()¶
Check if the field is from the data source.
Returns: true if the field is from the data source otherwise false
fromTrigger¶
- public boolean fromTrigger()¶
Check if the field is from the trigger.
Returns: true if the field is from the trigger otherwise false
getManipulations¶
getOriginalKey¶
hasManipulations¶
- public boolean hasManipulations()¶
Check if the field has any manipulations.
Returns: true if the field has manipulations otherwise false
parse¶
- public static KeyInformation parse(String input)¶
Parse given string to instance of KeyInformation.
This method should be used to convert string representation of dragged field to instance of KeyInformation.
Argument has adhere to one of the following format:
- trigger field format: trigger.eventKey
- data source format: ad.dataProviderId.objectType#objectId.fieldKey
Argument can also contain list of manipulation which should be executed on field before it will be used by org.motechproject.tasks.service.TaskTriggerHandler class. Manipulations should be connected together by the ? character.
Example of input argument:
- ad.279f5fdf60700d9717270b1ae3011eb1.CaseInfo#0.fieldValues.phu_id
- trigger.message?format(Ala,cat)?capitalize
Parameters: - input – string representation of a dragged field from trigger or data source
Throws: - IllegalArgumentException – exception is thrown if format for data source field is incorrect or if the dragged field is not from trigger or data source.
Returns: Object representation of a dragged field
parseAll¶
- public static List<KeyInformation> parseAll(String input)¶
Find all fields from given input and convert them to the instance of KeyInformation.
This method should be used to find and convert all of string representation of the field from trigger and/or data sources. Fields in input have to adhere to one of the following formats:
- trigger field format: {{trigger.eventKey}}
- data source format: {{ad.dataProviderId.objectType#objectId.fieldKey}}
To find fields in the input argument this method uses regular expression. When field is found it is converted to an instance of KeyInformation by using the parse(String) method.
Fields are found by the following regular expression: {{((.*?))(}})(?![^(]*)). The expression searches for strings that start with {{ and end with }} and are not within ( and ). Because of manipulations which contain additional data in (...) needed to execute manipulation on the field (e.g.: join needs to have the join character) and the text in (...) can be another string representation of the dragged field, the expression has to check if the field has this kind of manipulation.
Example of input argument:
- {{trigger.message?format(Ala,cat)?capitalize}}
- You get the following message: {{trigger.message}}
Parameters: - input – string with one or more string representation of dragged fields from trigger and/or data sources
Throws: - IllegalArgumentException – in the same situations as the parse(String) method.
Returns: list of object representation of dragged fields.
Lookup¶
- public class Lookup implements Serializable¶
ManipulationTarget¶
- public enum ManipulationTarget¶
Defines the target of various manipulations used in a task for both triggers and data sources.
Enum Constants¶
ALL¶
- public static final ManipulationTarget ALL¶
DATE¶
- public static final ManipulationTarget DATE¶
STRING¶
- public static final ManipulationTarget STRING¶
ManipulationType¶
- public enum ManipulationType¶
Defines the type of various manipulations used in a task for both triggers and data sources.
Enum Constants¶
CAPITALIZE¶
- public static final ManipulationType CAPITALIZE¶
DATETIME¶
- public static final ManipulationType DATETIME¶
FORMAT¶
- public static final ManipulationType FORMAT¶
JOIN¶
- public static final ManipulationType JOIN¶
PLUSDAYS¶
- public static final ManipulationType PLUSDAYS¶
SPLIT¶
- public static final ManipulationType SPLIT¶
SUBSTRING¶
- public static final ManipulationType SUBSTRING¶
TOLOWER¶
- public static final ManipulationType TOLOWER¶
TOUPPER¶
- public static final ManipulationType TOUPPER¶
UNKNOWN¶
- public static final ManipulationType UNKNOWN¶
OperatorType¶
- public enum OperatorType¶
Object representation of available operators in filter definition.
Enum Constants¶
AFTER¶
- public static final OperatorType AFTER¶
AFTER_NOW¶
- public static final OperatorType AFTER_NOW¶
BEFORE¶
- public static final OperatorType BEFORE¶
BEFORE_NOW¶
- public static final OperatorType BEFORE_NOW¶
CONTAINS¶
- public static final OperatorType CONTAINS¶
ENDSWITH¶
- public static final OperatorType ENDSWITH¶
EQUALS¶
- public static final OperatorType EQUALS¶
EQ_NUMBER¶
- public static final OperatorType EQ_NUMBER¶
EXIST¶
- public static final OperatorType EXIST¶
GT¶
- public static final OperatorType GT¶
LESS_DAYS_FROM_NOW¶
- public static final OperatorType LESS_DAYS_FROM_NOW¶
LESS_MONTHS_FROM_NOW¶
- public static final OperatorType LESS_MONTHS_FROM_NOW¶
LT¶
- public static final OperatorType LT¶
MORE_DAYS_FROM_NOW¶
- public static final OperatorType MORE_DAYS_FROM_NOW¶
MORE_MONTHS_FROM_NOW¶
- public static final OperatorType MORE_MONTHS_FROM_NOW¶
STARTSWITH¶
- public static final OperatorType STARTSWITH¶
Parameter¶
- public abstract class Parameter implements Serializable¶
Constructors¶
Parameter¶
- protected Parameter(String displayName, ParameterType type)¶
ParameterType¶
- public enum ParameterType¶
Defines the type of various values used in a task including trigger parameters, action parameters and data source object fields.
Enum Constants¶
BOOLEAN¶
- public static final ParameterType BOOLEAN¶
DATE¶
- public static final ParameterType DATE¶
DOUBLE¶
- public static final ParameterType DOUBLE¶
INTEGER¶
- public static final ParameterType INTEGER¶
LIST¶
- public static final ParameterType LIST¶
LONG¶
- public static final ParameterType LONG¶
MAP¶
- public static final ParameterType MAP¶
TEXTAREA¶
- public static final ParameterType TEXTAREA¶
TIME¶
- public static final ParameterType TIME¶
UNICODE¶
- public static final ParameterType UNICODE¶
UNKNOWN¶
- public static final ParameterType UNKNOWN¶
Task¶
- public class Task¶
A task is set of actions that are executed in response to a trigger. The actions and the trigger are defined by their respective Channels.
Constructors¶
Task¶
- public Task(String name, TaskTriggerInformation trigger, List<TaskActionInformation> actions)¶
Task¶
- public Task(String name, TaskTriggerInformation trigger, List<TaskActionInformation> actions, TaskConfig taskConfig, boolean enabled, boolean hasRegisteredChannel)¶
Methods¶
addAction¶
- public void addAction(TaskActionInformation action)¶
getActions¶
- public List<TaskActionInformation> getActions()¶
getTaskConfig¶
- public TaskConfig getTaskConfig()¶
getTrigger¶
- public TaskTriggerInformation getTrigger()¶
setActions¶
- public void setActions(List<TaskActionInformation> actions)¶
setTaskConfig¶
- public void setTaskConfig(TaskConfig taskConfig)¶
setTrigger¶
- public void setTrigger(TaskTriggerInformation trigger)¶
TaskActionInformation¶
- public class TaskActionInformation extends TaskEventInformation¶
Represents an action event configured with a Task
Methods¶
TaskActivity¶
- public class TaskActivity implements Comparable<TaskActivity>¶
Constructors¶
TaskActivity¶
- public TaskActivity(String message, Long task, TaskActivityType activityType)¶
TaskActivity¶
- public TaskActivity(String message, String field, Long task, TaskActivityType activityType)¶
TaskActivity¶
Methods¶
compareTo¶
- public int compareTo(TaskActivity o)¶
getActivityType¶
- public TaskActivityType getActivityType()¶
setActivityType¶
- public void setActivityType(TaskActivityType activityType)¶
TaskActivityType¶
- public enum TaskActivityType¶
Enum Constants¶
ERROR¶
- public static final TaskActivityType ERROR¶
SUCCESS¶
- public static final TaskActivityType SUCCESS¶
WARNING¶
- public static final TaskActivityType WARNING¶
TaskBuilder¶
- public class TaskBuilder¶
Methods¶
addAction¶
- public TaskBuilder addAction(TaskActionInformation action)¶
addDataSource¶
- public TaskBuilder addDataSource(DataSource dataSource)¶
addFilterSet¶
- public TaskBuilder addFilterSet(FilterSet filterSet)¶
clear¶
- public TaskBuilder clear()¶
isEnabled¶
- public TaskBuilder isEnabled(boolean enabled)¶
withDescription¶
- public TaskBuilder withDescription(String description)¶
withId¶
- public TaskBuilder withId(Long id)¶
withName¶
- public TaskBuilder withName(String name)¶
withTaskConfig¶
- public TaskBuilder withTaskConfig(TaskConfig taskConfig)¶
withTrigger¶
- public TaskBuilder withTrigger(TaskTriggerInformation trigger)¶
TaskConfig¶
- public class TaskConfig implements Serializable¶
Methods¶
add¶
- public TaskConfig add(TaskConfigStep... configSteps)¶
addAll¶
- public TaskConfig addAll(SortedSet<TaskConfigStep> set)¶
getDataSources¶
- public List<DataSource> getDataSources()¶
getDataSources¶
- public SortedSet<DataSource> getDataSources(Long providerId)¶
getSteps¶
- public SortedSet<TaskConfigStep> getSteps()¶
removeAll¶
- public TaskConfig removeAll()¶
removeDataSources¶
- public TaskConfig removeDataSources()¶
removeFilterSets¶
- public TaskConfig removeFilterSets()¶
setDataSources¶
- public void setDataSources(List<DataSource> dataSources)¶
TaskConfigStep¶
- public abstract class TaskConfigStep implements Comparable<TaskConfigStep>, Serializable¶
TaskDataProvider¶
- public class TaskDataProvider¶
The TaskDataProvider class cointains all informations about data providers used in tasks
Constructors¶
TaskDataProvider¶
- public TaskDataProvider(String name, List<TaskDataProviderObject> objects)¶
Methods¶
containsProviderObjectField¶
containsProviderObjectLookup¶
getObjects¶
- public List<TaskDataProviderObject> getObjects()¶
getProviderObject¶
- public TaskDataProviderObject getProviderObject(String type)¶
setObjects¶
- public void setObjects(List<TaskDataProviderObject> objects)¶
TaskDataProviderObject¶
- public class TaskDataProviderObject implements Serializable¶
Constructors¶
TaskDataProviderObject¶
- public TaskDataProviderObject(String displayName, String type, List<LookupFieldsParameter> lookupFields, List<FieldParameter> fields)¶
Methods¶
getFields¶
- public List<FieldParameter> getFields()¶
getLookupFields¶
- public List<LookupFieldsParameter> getLookupFields()¶
setFields¶
- public void setFields(List<FieldParameter> fields)¶
TaskError¶
- public class TaskError implements Serializable¶
Constructors¶
TaskError¶
- public TaskError(TaskErrorType type, String... args)¶
Methods¶
TaskErrorType¶
- public enum TaskErrorType¶
Enum Constants¶
BLANK¶
- public static final TaskErrorType BLANK¶
EMPTY_COLLECTION¶
- public static final TaskErrorType EMPTY_COLLECTION¶
NULL¶
- public static final TaskErrorType NULL¶
VERSION¶
- public static final TaskErrorType VERSION¶
TaskEventInformation¶
- public abstract class TaskEventInformation implements Serializable¶
Constructors¶
Methods¶
TaskTriggerInformation¶
- public class TaskTriggerInformation extends TaskEventInformation¶
Constructors¶
TaskTriggerInformation¶
TaskTriggerInformation¶
- public TaskTriggerInformation(TaskTriggerInformation other)¶
TriggerEvent¶
- public class TriggerEvent extends TaskEvent¶
The TriggerEvent class is responsible for storing data about event
Constructors¶
TriggerEvent¶
TriggerEvent¶
- public TriggerEvent(TriggerEventRequest triggerEventRequest)¶
Methods¶
getEventParameters¶
- public List<EventParameter> getEventParameters()¶
setEventParameters¶
- public void setEventParameters(List<EventParameter> eventParameters)¶
org.motechproject.tasks.ex¶
org.motechproject.tasks.json¶
ActionEventRequestDeserializer¶
- public class ActionEventRequestDeserializer implements JsonDeserializer<ActionEventRequest>¶
Fields¶
Methods¶
deserialize¶
- public ActionEventRequest deserialize(JsonElement element, Type type, JsonDeserializationContext context)¶
TaskConfigDeserializer¶
- public class TaskConfigDeserializer extends JsonDeserializer<TaskConfig>¶
Methods¶
deserialize¶
- public TaskConfig deserialize(JsonParser parser, DeserializationContext context)¶
org.motechproject.tasks.repository¶
ChannelsDataService¶
- public interface ChannelsDataService extends MotechDataService<Channel>¶
TaskActivitiesDataService¶
- public interface TaskActivitiesDataService extends MotechDataService<TaskActivity>¶
TasksDataService¶
- public interface TasksDataService extends MotechDataService<Task>¶
org.motechproject.tasks.service¶
ChannelService¶
Methods¶
getChannelIcon¶
- BundleIcon getChannelIcon(String moduleName)¶
registerChannel¶
- void registerChannel(ChannelRequest channelRequest)¶
registerChannel¶
- void registerChannel(InputStream stream, String moduleName, String moduleVersion)¶
DataProviderDataService¶
- public interface DataProviderDataService extends MotechDataService<TaskDataProvider>¶
Methods¶
findByName¶
- TaskDataProvider findByName(String name)¶
DataSourceObject¶
- public class DataSourceObject¶
DataSourceObject is the result of a org.motechproject.commons.api.DataProvider lookup.
Constructors¶
HandlerPredicates¶
- final class HandlerPredicates¶
Utility class defining filters over some collections.
KeyEvaluator¶
- public class KeyEvaluator¶
KeyEvaluator evaluates the value of a key in the context of a task which is used to execute filters and actions.
Constructors¶
KeyEvaluator¶
- public KeyEvaluator(TaskContext taskContext)¶
MethodHandler¶
- class MethodHandler¶
Utility class used by TaskTriggerHandler to construct a list of parameter types of the method in the correct order.
See also: TaskTriggerHandler
Constructors¶
TaskActionExecutor¶
- class TaskActionExecutor¶
Builds action parameters from TaskContext and executes the action by invoking its service or raising its event.
Constructors¶
TaskActionExecutor¶
- TaskActionExecutor(TaskService taskService, TaskActivityService activityService, EventRelay eventRelay)¶
Methods¶
createParameters¶
- Map<String, Object> createParameters(TaskActionInformation info, ActionEvent action)¶
execute¶
- void execute(Task task, TaskActionInformation actionInformation, TaskContext taskContext)¶
setBundleContext¶
- void setBundleContext(BundleContext bundleContext)¶
TaskActivityService¶
- public interface TaskActivityService¶
Methods¶
addError¶
- void addError(Task task, TaskHandlerException e)¶
errorsFromLastRun¶
- List<TaskActivity> errorsFromLastRun(Task task)¶
getAllActivities¶
- List<TaskActivity> getAllActivities()¶
getTaskActivities¶
- List<TaskActivity> getTaskActivities(Long taskId)¶
TaskContext¶
- public class TaskContext¶
TaskContext holds task trigger event and data provider lookup objects that are used while executing filters/actions.
Constructors¶
TaskContext¶
- public TaskContext(Task task, MotechEvent event, TaskActivityService activityService)¶
TaskDataProviderService¶
- public interface TaskDataProviderService¶
Methods¶
getProvider¶
- TaskDataProvider getProvider(String name)¶
getProviderById¶
- TaskDataProvider getProviderById(Long providerId)¶
getProviders¶
- List<TaskDataProvider> getProviders()¶
registerProvider¶
- void registerProvider(InputStream stream)¶
TaskFilterExecutor¶
- public class TaskFilterExecutor¶
The TaskFilterExecutor applies a list of filters in a #TaskContext.
- convertTo - convert a given value to a correct type,
- getFieldValue - get value of a field defined in the key from the given object,
- getTriggerKey - get value of a trigger event parameter,
- checkFilters - executed defined filters for a task,
- manipulate - executed the given manipulation on the given string value.
TaskInitializer¶
- class TaskInitializer¶
The TaskInitializer class prepares an action in the task definition to execution.
- evalConfigSteps - executes all config steps (load data sources, check filters) defined in the task,
See also: TaskTriggerHandler, TaskActionExecutor
Constructors¶
TaskInitializer¶
- TaskInitializer(TaskContext taskContext)¶
TaskService¶
- public interface TaskService¶
Methods¶
findTasksForTrigger¶
- List<Task> findTasksForTrigger(TriggerEvent trigger)¶
findTrigger¶
- TriggerEvent findTrigger(String subject)¶
getActionEventFor¶
- ActionEvent getActionEventFor(TaskActionInformation taskActionInformation)¶
TaskTriggerHandler¶
- public class TaskTriggerHandler implements TriggerHandler¶
The TaskTriggerHandler receives events and executes tasks for which the trigger event subject is the same as the received event subject.
Constructors¶
TaskTriggerHandler¶
- public TaskTriggerHandler(TaskService taskService, TaskActivityService activityService, EventListenerRegistryService registryService, EventRelay eventRelay, SettingsFacade settings)¶
Methods¶
addDataProvider¶
- public void addDataProvider(DataProvider provider)¶
handle¶
- public void handle(MotechEvent event)¶
setBundleContext¶
- public void setBundleContext(BundleContext bundleContext)¶
setDataProviders¶
- void setDataProviders(Map<String, DataProvider> dataProviders)¶
org.motechproject.tasks.util¶
ManagementDataProvider¶
- public class ManagementDataProvider implements OsgiServiceLifecycleListener¶
Constructors¶
ManagementDataProvider¶
- public ManagementDataProvider(TaskDataProviderService taskDataProviderService)¶
ManagementDataProvider¶
- public ManagementDataProvider(TaskTriggerHandler handler, TaskDataProviderService taskDataProviderService)¶
Contribute¶
Thank you for your interest in contributing to MOTECH. There are many different ways to get involved - regardless of your area of expertise and time commitment, there is likely a useful way for you to contribute. Please peruse the sections below for some instructions on how to get started contributing in specific areas. If there is another way you’d like to help that isn’t listed, just let us know what your interests are and we can help find a project for you.
Development¶
Want to help us develop MOTECH? The step by step guide below will help you get started. The instructions may be incomplete, or may contain some errors, so please just let us know if something is missing or incorrect. Our mailing list is populated with helpful people who will help you get going - and will get this documentation up to date with any issues you encounter.
Here is how to get started:
Mailing Lists and Accounts¶
- Sign up for the MOTECH Developer mailing list - this is the best place to get help with any questions about MOTECH development.
- Create an account on Gerrit, our code review system.
- Get a Jira account if you’ll need to report/track issues - there is no self-serve way to request a Jira account yet, so please just email the MOTECH Developer list and we’ll get you set up.
Dev Environment & Tools¶
- Configure your dev machine.
- Configure your Git client to submit changes via Gerrit.
- Familiarize yourself with our CI.
Finding Something to Work On¶
- Some MOTECH devs have found that reviewing code written by others before they jump in and develop their own is a good way to get their feet wet. If that sounds like your style, feel free to jump into any code review on Gerrit and add your comments.
- If you’d rather dive right in, we’d recommend that you find a “community” issue from our issue tracker - these are bugs and user stories that we think are good introductory items for MOTECH newbies. See a list of all current “community” issues here.
- If you’re already building your own system on top of MOTECH and you’d like us to incorporate your changes for an issue you’ve found and fixed, please first check whether the issue already exists in our issue tracker. If you are not sure, please email the mailing list and we’ll help you determine whether the issue is already known. Please track your work with a new issue so that we can evaluate it for inclusion in the Platform.
Developing and Submitting Your Code¶
- If your fix will be nontrivial, please leverage the mailing list for feedback on your design before you get too far - we are a friendly bunch and can help ensure you are headed in the right direction.
- When you’re ready to push your changes, please squash your commits to keep the change history concise, and write a commit message that conforms to our guidelines.
- Submit your code using git push origin - if you configured your environment correctly, this sends your changes to Gerrit, our code review system.
- Please incorporate code review feedback and update your patch as needed - once your change has passed code review, one of the project maintainers will merge your change to the repo.
- Resolve the relevant issue(s) in Jira.
Documentation¶
There will be text here.
Translation¶
Bonjour!
We are using Transifex to manage MOTECH translations, which makes it easy for non-geeks to help. If you speak multiple languages and would like to help us make MOTECH multilingual, please start by checking out our translation page to determine whether your language(s) are on our list. Do we have a translation in progress for your language? Great! We’d love your help translating additional strings. Do we not have a translation started for your language? Also great! We’d love your help getting one started.
Either way, please sign up for Transifex (free), and then contact us. Let us know your Transifex user ID and which language(s) you’d like to work on, and we’ll help you get started.
Indices and tables¶
- genindex
- modindex
- search