Skip to content

Commit

Permalink
APPNG-2000
Browse files Browse the repository at this point in the history
  • Loading branch information
madness-inc committed Jun 29, 2017
1 parent 8ed3d3e commit e5e931d
Show file tree
Hide file tree
Showing 1,280 changed files with 123,107 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
.classpath
.project
.settings
target
6 changes: 6 additions & 0 deletions appng-api/.gitignore
@@ -0,0 +1,6 @@
/bin
/.classpath
/.project
/.settings
/target
/target/
138 changes: 138 additions & 0 deletions appng-api/pom.xml
@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<artifactId>appng-api</artifactId>
<packaging>jar</packaging>
<name>appNG public API</name>
<description>the public API of appNG</description>

<parent>
<groupId>org.appng</groupId>
<artifactId>appng-parent</artifactId>
<version>1.14.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<!-- BEGIN DEPENDENCY MANAGEMENT -->
<dependencies>
<!-- BEGIN PROJECT DEPENDENCIES -->
<dependency>
<groupId>org.appng</groupId>
<artifactId>appng-forms</artifactId>
</dependency>
<dependency>
<groupId>org.appng</groupId>
<artifactId>appng-xmlapi</artifactId>
</dependency>
<dependency>
<groupId>org.appng</groupId>
<artifactId>appng-tools</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.appng</groupId>
<artifactId>appng-formtags</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jasper</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
115 changes: 115 additions & 0 deletions appng-api/src/main/java/org/appng/api/ActionProvider.java
@@ -0,0 +1,115 @@
/*
* Copyright 2011-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.appng.api;

import org.appng.api.model.Application;
import org.appng.api.model.Site;
import org.appng.xml.platform.Action;
import org.appng.xml.platform.Bean;
import org.appng.xml.platform.BeanOption;
import org.appng.xml.platform.Datasource;
import org.appng.xml.platform.FieldDef;
import org.appng.xml.platform.MetaData;

/**
* An {@link ActionProvider} usually performs a CRUD-action on a domain object. The implementing class needs to be
* defined in the application's {@code beans.xml}. This bean is then being referenced in a concrete {@link Action}:
*
* <pre>
* &lt;action id="update">
* &lt;config>
* &lt;title id="issue.update" />
* &lt;params>
* &lt;param name="form_action" />
* &lt;param name="issueName" />
* &lt;param name="edit" />
* &lt;/params>
* &lt;/config>
* &lt;condition expression="${form_action eq 'update' and not empty issueName}" />
* &lt;datasource id="issue">
* &lt;params>
* &lt;param name="issueName">${issueName}&lt;/param>
* &lt;param name="edit">${edit}&lt;/param>
* &lt;/params>
* &lt;/datasource>
* &lt;bean id="issues">
* &lt;option name="action" id="update" issue="${issueName}" />
* &lt;/bean>
* &lt;/action>
* </pre>
*
* There is no need to implement one {@link ActionProvider} per {@link Action}, since the {@link Bean} can be
* parameterized using different {@link BeanOption}s. So for example, the above defined bean could also be used for
* creating a new domain object, using another {@link BeanOption}:
*
* <pre>
* &lt;action id="create">
* &lt;config>
* &lt;title id="issue.create" />
* &lt;/config>
* &lt;condition expression="${form_action eq 'create'}" />
* &lt;datasource id="new_issue">
* &lt;params>
* &lt;param name="form_action" />
* &lt;/params>
* &lt;/datasource>
* &lt;bean id="issues">
* &lt;option name="action" id="create" />
* &lt;/bean>
* &lt;/action>
* </pre>
*
* The distinction between create and update then can be done like this:
*
* <pre>
* <code>
* if ("create".equals(options.getOptionValue("action", "id"))) {
* // create new domain object
* } else if ("update".equals(options.getOptionValue("action", "id"))){
* // update existing domain object
* }</code>
* </pre>
*
* @author Matthias Müller
*
* @param <T>
* the bean type for this {@link ActionProvider}s {@code perform(...)}-method. Must match
* {@link MetaData#getBindClass()} of the {@link Datasource} used by the {@link Action}
*/
public interface ActionProvider<T> {

/**
* Performs an action on the given {@code formBean}
*
* @param site
* the current {@link Site}
* @param application
* the current {@link Application}
* @param environment
* the current {@link Environment}
* @param options
* the {@link Options} for this {@link ActionProvider}
* @param request
* the current {@link Request}
* @param formBean
* the bean which has been created
* @param fieldProcessor
* the {@link FieldProcessor} containing all writable {@link FieldDef}initions for this action
*/
void perform(Site site, Application application, Environment environment, Options options, Request request, T formBean,
FieldProcessor fieldProcessor);

}

0 comments on commit e5e931d

Please sign in to comment.