adding the code form moose into the repo

This commit is contained in:
Jeff Thomas 2021-08-11 08:27:46 +02:00
commit 5118436ee6
147 changed files with 13773 additions and 0 deletions

19
.gitignore vendored Normal file
View File

@ -0,0 +1,19 @@
*.sw?
.#*
*#
*~
.classpath
.project
.settings
bin
build
target
dependency-reduced-pom.xml
*.sublime-*
/scratch
.gradle
README.html
*.iml
.idea
out
/configuration/tmp/tomcat-orbeon.zip

1
README.md Normal file
View File

@ -0,0 +1 @@
Source code from Moose for the integration module between Orbeon and Bluedb

View File

@ -0,0 +1,42 @@
<Context>
<Resource
name="jdbc/postgresql"
driverClassName="org.postgresql.Driver"
auth="Container"
type="javax.sql.DataSource"
initialSize="3"
maxActive="10"
maxIdle="10"
maxWait="30000"
poolPreparedStatements="true"
testOnBorrow="true"
validationQuery="select 1"
username="postgres"
password="postgres"
url="jdbc:postgresql://localhost:5432/orbeon?useUnicode=true&amp;characterEncoding=UTF8&amp;socketTimeout=30&amp;tcpKeepAlive=true"/>
<Resource
name="jdbc/postgresql"
driverClassName="org.postgresql.Driver"
auth="Container"
type="javax.sql.DataSource"
initialSize="3"
maxActive="10"
maxIdle="10"
maxWait="30000"
poolPreparedStatements="true"
testOnBorrow="true"
validationQuery="select 1"
username="postgres"
password="postgres"
url="jdbc:postgresql://localhost:5432/orbeon_mapper?useUnicode=true&amp;characterEncoding=UTF8&amp;socketTimeout=30&amp;tcpKeepAlive=true"/>
</Context>

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -0,0 +1,65 @@
if (ORBEON.jQuery(".fr-mode-edit").length != 0 || ORBEON.jQuery(".fr-mode-view").length != 0)
{
var xhttp = new XMLHttpRequest();
var url = document.URL;
var documentId = url.substring(url.lastIndexOf("/"));
xhttp.withCredentials = true;
xhttp.open("GET", "http://192.168.0.167:18080/integration/rest/form/issubmitted/" + documentId, true);
xhttp.setRequestHeader("Content-type", "application/json");
xhttp.onload = function (e)
{
var disableSubmit = (xhttp.responseText == 'true')
if (disableSubmit)
{
//Below is for submision button
ORBEON.jQuery("#fr-view").find('.fr-submit-button').find('.btn').each(function (i)
{
ORBEON.jQuery(this).attr("disabled", "true");
});
}
}
xhttp.send();
var xhttp2 = new XMLHttpRequest();
var url = document.URL;
var documentId = url.substring(url.lastIndexOf("/"));
xhttp2.withCredentials = true;
xhttp2.open("GET", "http://192.168.0.167:18080/integration/rest/form/hasremovedattachments/" + documentId, true);
xhttp2.setRequestHeader("Content-type", "application/json");
xhttp2.onload = function (e)
{
var hideDownloads = (xhttp2.responseText == 'true')
if (hideDownloads)
{
//Below is for download attachment icon
ORBEON.jQuery("#fr-view").find('.xforms-output-output').each(function (i)
{
if (ORBEON.jQuery(this).text().trim() == "Download")
{
ORBEON.jQuery(this).attr("style", "visibility: hidden");
}
});
//Below is for remove attachment icon
ORBEON.jQuery("#fr-view").find('.xforms-upload-remove').each(function (i)
{
ORBEON.jQuery(this).attr("style", "visibility: hidden");
});
// Below is for upload file control
/*
ORBEON.jQuery("#fr-view").find('.xforms-upload-select').each(function(i) {
ORBEON.jQuery(this).attr("style", "visibility: hidden");
});
*/
}
}
xhttp2.send();
}
function hideSubmit() {
ORBEON.jQuery("#fr-view").find('.fr-submit-button').find('.btn').each(function (i)
{
ORBEON.jQuery(this).attr("disabled", "true");
});
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,18 @@
<signed-data>
<data>
<license>
<licensor>Orbeon, Inc.</licensor>
<licensee>Kamil Łukowski</licensee>
<organization>Hycom</organization>
<email>kamil.lukowski@it.hycom.pl</email>
<issued>2017-06-05</issued>
<version/>
<expiration>2017-09-03</expiration>
<subscription-start/>
<subscription-end/>
<license-id/>
<license-description/>
</license>
</data>
<signature>MCwCFElcM8HWGXwfyB3JuOb24WybtQXLAhRwL7Kuuebb6HzAU7RLphXbNFR+gw==</signature>
</signed-data>

View File

@ -0,0 +1,99 @@
<properties xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:oxf="http://www.orbeon.com/oxf/processors">
<!-- Default provider is postgresql -->
<property as="xs:string" name="oxf.fr.persistence.provider.*.*.*" value="postgresql" />
<property as="xs:anyURI" name="oxf.fr.persistence.postgresql.uri" value="/fr/service/postgresql"/>
<property as="xs:string" name="oxf.fr.persistence.postgresql.datasource" value="postgresql"/>
<property as="xs:boolean" name="oxf.fr.persistence.postgresql.create-flat-view" value="true"/>
<!-- Auhtentication and permissions -->
<property as="xs:string" name="oxf.fr.authentication.method" value="container"/>
<property as="xs:string" name="oxf.fr.authentication.container.roles" value="form-admin form-user"/>
<!-- Autosave enabled -->
<property as="xs:boolean" name="oxf.fr.persistence.postgresql.autosave" value="true"/>
<!-- Service Methods -->
<property as="xs:string" processor-name="oxf:page-flow" name="service-public-methods" value="GET HEAD POST PUT DELETE" />
<property as="xs:string" processor-name="oxf:page-flow" name="page-public-methods" value="GET HEAD POST PUT DELETE" />
<!-- Logo -->
<property as="xs:anyURI" name="oxf.fr.default-logo.uri.*.*">
/apps/fr/icons/icoca.png
</property>
<!-- Summary buttons -->
<property as="xs:string" name="oxf.fr.detail.buttons.*.*">
refresh summary clear pdf save-draft submit review
</property>
<!-- Save-final button actions -->
<property as="xs:string" name="oxf.fr.detail.process.submit.*.*">
require-uploads
then validate-all
then save
then send(
uri = "http://192.168.0.141:8090/integration/rest/form/submit/{xxf:instance('fr-parameters-instance')/document}",
method = "PUT",
content = "metadata"
)
then email
then success-message("submit-dialog-message")
then send(uri="http://localhost:8080/rest/mapper/submit/{xxf:instance('fr-parameters-instance')/app}/{xxf:instance('fr-parameters-instance')/form}/{xxf:get-remote-user()}", method = "POST", content-type = "application/xml", content = "xml")
then navigate(uri = "javascript:hideSubmit()")
</property>
<!-- Publish button actions -->
<property as="xs:string" name="oxf.fr.detail.process.publish.orbeon.builder">
validate-all
then xf:show(
dialog = "fb-publish-dialog",
app = "{xxf:instance('fb-form-instance')/xh:head/xf:model[@id = 'fr-form-model']/xf:instance[@id = 'fr-form-metadata']/*/application-name}",
form = "{xxf:instance('fb-form-instance')/xh:head/xf:model[@id = 'fr-form-model']/xf:instance[@id = 'fr-form-metadata']/*/form-name}")
then send(uri="http://localhost:8080/rest/mapper/publish/{xxf:instance('fb-form-instance')/xh:head/xf:model[@id = 'fr-form-model']/xf:instance[@id = 'fr-form-metadata']/*/application-name}/{xxf:instance('fb-form-instance')/xh:head/xf:model[@id = 'fr-form-model']/xf:instance[@id = 'fr-form-metadata']/*/form-name}", method = "PUT", prune="false", content = "metadata")
</property>
<!-- Proxy -->
<!--<property as="xs:anyURI" name="oxf.url-rewriting.service.base-uri" value="http://192.168.0.167:8080/orbeon"/>-->
<!-- Style CSS -->
<property as="xs:string" name="oxf.fr.css.custom.uri.*.*" value="/apps/fr/style/style.css"/>
<!-- Custom JS -->
<property as="xs:string" name="oxf.fr.js.custom.uri.*.*" value="/apps/fr/js/attachments.js"/>
<!-- Builder configuration -->
<property as="xs:integer" name="oxf.fb.grid.max-columns" value="6"/>
<property as="xs:string" name="oxf.xforms.xbl.fr.number.digits-after-decimal" value="0"/>
<property as="xs:string" name="oxf.xforms.xbl.fr.number.grouping-separator" value=""/>
<!-- Email configuration -->
<property as="xs:string" name="oxf.fr.email.smtp.host.*.*" value="smtp.gmail.com" />
<property as="xs:string" name="oxf.fr.email.smtp.port.*.*" value="587" />
<property as="xs:string" name="oxf.fr.email.smtp.encryption.*.*" value="tls" />
<property as="xs:string" name="oxf.fr.email.smtp.username.*.*" value="icoorbeon@gmail.com" />
<property as="xs:string" name="oxf.fr.email.smtp.credentials.*.*" value="Passw0rd_a" />
<property as="xs:string" name="oxf.fr.email.from.*.*" value="icoorbeon@gmail.com" />
<property as="xs:string" name="oxf.fr.email.to.*.*" value="m.g.gulewicz@gmail.com" />
<property as="xs:string" name="oxf.fr.email.cc.*.*" value="" />
<property as="xs:string" name="oxf.fr.email.bcc.*.*" value="" />
<property as="xs:boolean" name="oxf.fr.email.attach-pdf.*.*" value="true" />
<property as="xs:boolean" name="oxf.fr.email.attach-tiff.*.*" value="false" />
<property as="xs:boolean" name="oxf.fr.email.attach-xml.*.*" values="false" />
<property as="xs:string" name="oxf.fr.email.attach-files.*.*" values="all" />
<property as="xs:string" name="oxf.fr.resource.*.*.*.email.subject" value="Information about new form in Orbeon."/>
<property as="xs:string" name="oxf.fr.resource.*.*.*.email.body">
Dear Sir/Madam
There is a new form in Orbeon system.
This message contains an attachment with field form.
You can download and save it or find it in Orbeon system.
Best regards
Orbeon
</property>
</properties>

View File

@ -0,0 +1,376 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app
version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/j2ee">
<display-name>Orbeon Forms</display-name>
<description>
Orbeon Forms is an open source, standard-based web forms solution, which
includes Form Builder, a WYSIWYG browser-based authoring tool, and Form
Runner, a runtime environment which facilitates the deployment and
integration of a large number of complex forms. Orbeon Forms implements
different technologies, such as XForms and Ajax, with no need for
client-side software or plug-ins.
</description>
<!--Initialize main resource manager-->
<context-param>
<param-name>oxf.resources.factory</param-name>
<param-value>org.orbeon.oxf.resources.PriorityResourceManagerFactory</param-value>
</context-param>
<!--Web application resource manager for resources-->
<context-param>
<param-name>oxf.resources.priority.2</param-name>
<param-value>org.orbeon.oxf.resources.WebAppResourceManagerFactory</param-value>
</context-param>
<context-param>
<param-name>oxf.resources.priority.2.oxf.resources.webapp.rootdir</param-name>
<param-value>/WEB-INF/resources</param-value>
</context-param>
<!--Classloader resource manager-->
<context-param>
<param-name>oxf.resources.priority.6</param-name>
<param-value>org.orbeon.oxf.resources.ClassLoaderResourceManagerFactory</param-value>
</context-param>
<!--Set run mode ("dev" or "prod")-->
<context-param>
<param-name>oxf.run-mode</param-name>
<param-value>prod</param-value>
</context-param>
<!--Set location of properties.xml-->
<context-param>
<param-name>oxf.properties</param-name>
<param-value>oxf:/config/properties-${oxf.run-mode}.xml</param-value>
</context-param>
<!--Determine whether logging initialization must take place-->
<context-param>
<param-name>oxf.initialize-logging</param-name>
<param-value>true</param-value>
</context-param>
<!--Set context listener processors-->
<!-- Uncomment this for the context listener processors -->
<!--
<context-param>
<param-name>oxf.context-initialized-processor.name</param-name>
<param-value>{http://www.orbeon.com/oxf/processors}pipeline</param-value>
</context-param>
<context-param>
<param-name>oxf.context-initialized-processor.input.config</param-name>
<param-value>oxf:/apps/context/context-initialized.xpl</param-value>
</context-param>
<context-param>
<param-name>oxf.context-destroyed-processor.name</param-name>
<param-value>{http://www.orbeon.com/oxf/processors}pipeline</param-value>
</context-param>
<context-param>
<param-name>oxf.context-destroyed-processor.input.config</param-name>
<param-value>oxf:/apps/context/context-destroyed.xpl</param-value>
</context-param>-->
<!-- End context listener processors -->
<!--Set session listener processors-->
<!-- Uncomment this for the session listener processors -->
<!--
<context-param>
<param-name>oxf.session-created-processor.name</param-name>
<param-value>{http://www.orbeon.com/oxf/processors}pipeline</param-value>
</context-param>
<context-param>
<param-name>oxf.session-created-processor.input.config</param-name>
<param-value>oxf:/apps/context/session-created.xpl</param-value>
</context-param>
<context-param>
<param-name>oxf.session-destroyed-processor.name</param-name>
<param-value>{http://www.orbeon.com/oxf/processors}pipeline</param-value>
</context-param>
<context-param>
<param-name>oxf.session-destroyed-processor.input.config</param-name>
<param-value>oxf:/apps/context/session-destroyed.xpl</param-value>
</context-param>-->
<!-- End session listener processors -->
<!--Security filter for eXist-->
<filter>
<filter-name>orbeon-exist-filter</filter-name>
<filter-class>org.orbeon.oxf.servlet.TokenSecurityFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>orbeon-exist-filter</filter-name>
<url-pattern>/exist/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<!--Limit concurrent access to Form Runner-->
<filter>
<filter-name>orbeon-limiter-filter</filter-name>
<filter-class>org.orbeon.oxf.servlet.LimiterFilter</filter-class>
<!--Include Form Runner pages and XForms Ajax requests-->
<init-param>
<param-name>include</param-name>
<param-value>(/fr/.*)|(/xforms-server)</param-value>
</init-param>
<!--Exclude resources not produced by services-->
<init-param>
<param-name>exclude</param-name>
<param-value>(?!/([^/]+)/service/).+\.(gif|css|pdf|json|js|coffee|map|png|jpg|xsd|htc|ico|swf|html|htm|txt)</param-value>
</init-param>
<!--Minimum, requested, and maximum number of concurrent threads allowed-->
<!--The `x` prefix specifies a multiple of the number of CPU cores reported by the JVM-->
<init-param>
<param-name>min-threads</param-name>
<param-value>1</param-value>
</init-param>
<init-param>
<param-name>num-threads</param-name>
<param-value>x1</param-value>
</init-param>
<init-param>
<param-name>max-threads</param-name>
<param-value>x1</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>orbeon-limiter-filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<!--Add internal Orbeon-* headers for auth-->
<filter>
<filter-name>orbeon-form-runner-auth-servlet-filter</filter-name>
<filter-class>org.orbeon.oxf.servlet.FormRunnerAuthFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>orbeon-form-runner-auth-servlet-filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<!--All JSP files under /xforms-jsp go through the XForms filter-->
<filter>
<filter-name>orbeon-xforms-filter</filter-name>
<filter-class>org.orbeon.oxf.servlet.OrbeonXFormsFilter</filter-class>
<!-- Uncomment this for the separate WAR deployment -->
<!--
<init-param>
<param-name>oxf.xforms.renderer.context</param-name>
<param-value>/orbeon</param-value>
</init-param>
<init-param>
<param-name>oxf.xforms.renderer.default-encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>-->
<!-- End separate WAR deployment -->
</filter>
<filter-mapping>
<filter-name>orbeon-xforms-filter</filter-name>
<url-pattern>/xforms-jsp/*</url-pattern>
<!--Servlet 2.4 configuration allowing the filter to run upon forward in addition to request-->
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<!--Orbeon context listener-->
<listener>
<listener-class>org.orbeon.oxf.webapp.OrbeonServletContextListener</listener-class>
</listener>
<!--Orbeon session listener-->
<listener>
<listener-class>org.orbeon.oxf.webapp.OrbeonSessionListener</listener-class>
</listener>
<!--Ehcache shutdown listener-->
<listener>
<listener-class>net.sf.ehcache.constructs.web.ShutdownListener</listener-class>
</listener>
<!--This is the main Orbeon Forms servlet-->
<servlet>
<servlet-name>orbeon-main-servlet</servlet-name>
<servlet-class>org.orbeon.oxf.servlet.OrbeonServlet</servlet-class>
<!--Set main processor-->
<init-param>
<param-name>oxf.main-processor.name</param-name>
<param-value>{http://www.orbeon.com/oxf/processors}pipeline</param-value>
</init-param>
<init-param>
<param-name>oxf.main-processor.input.config</param-name>
<param-value>oxf:/config/prologue-servlet.xpl</param-value>
</init-param>
<!--Set error processor-->
<init-param>
<param-name>oxf.error-processor.name</param-name>
<param-value>{http://www.orbeon.com/oxf/processors}page-flow</param-value>
</init-param>
<init-param>
<param-name>oxf.error-processor.input.controller</param-name>
<param-value>oxf:/config/error-page-flow.xml</param-value>
</init-param>
<!--Set supported methods-->
<init-param>
<param-name>oxf.http.accept-methods</param-name>
<param-value>get,post,head,put,delete</param-value>
</init-param>
<!--Set servlet initialization and destruction listeners-->
<!-- Uncomment this for the servlet listener processors -->
<!--
<init-param>
<param-name>oxf.servlet-initialized-processor.name</param-name>
<param-value>{http://www.orbeon.com/oxf/processors}pipeline</param-value>
</init-param>
<init-param>
<param-name>oxf.servlet-initialized-processor.input.config</param-name>
<param-value>oxf:/apps/context/servlet-initialized.xpl</param-value>
</init-param>
<init-param>
<param-name>oxf.servlet-destroyed-processor.name</param-name>
<param-value>{http://www.orbeon.com/oxf/processors}pipeline</param-value>
</init-param>
<init-param>
<param-name>oxf.servlet-destroyed-processor.input.config</param-name>
<param-value>oxf:/apps/context/servlet-destroyed.xpl</param-value>
</init-param>-->
<!-- End servlet listener processors -->
</servlet>
<!--This is the XForms Renderer servlet, used to deploy Orbeon Forms as a separate WAR-->
<servlet>
<servlet-name>orbeon-renderer-servlet</servlet-name>
<servlet-class>org.orbeon.oxf.servlet.OrbeonServlet</servlet-class>
<!--Set main processor-->
<init-param>
<param-name>oxf.main-processor.name</param-name>
<param-value>{http://www.orbeon.com/oxf/processors}page-flow</param-value>
</init-param>
<init-param>
<param-name>oxf.main-processor.input.controller</param-name>
<param-value>oxf:/ops/xforms/xforms-renderer-page-flow.xml</param-value>
</init-param>
<!--Set error processor-->
<init-param>
<param-name>oxf.error-processor.name</param-name>
<param-value>{http://www.orbeon.com/oxf/processors}pipeline</param-value>
</init-param>
<init-param>
<param-name>oxf.error-processor.input.config</param-name>
<param-value>oxf:/config/error.xpl</param-value>
</init-param>
</servlet>
<!-- Uncomment this for the eXist XMLRPC support -->
<!--
<servlet>
<servlet-name>exist-xmlrpc-servlet</servlet-name>
<servlet-class>org.exist.xmlrpc.RpcServlet</servlet-class>
</servlet>-->
<!-- End eXist XMLRPC support -->
<servlet>
<servlet-name>exist-rest-servlet</servlet-name>
<servlet-class>org.exist.http.servlets.EXistServlet</servlet-class>
<init-param>
<param-name>basedir</param-name>
<param-value>WEB-INF/</param-value>
</init-param>
<init-param>
<param-name>configuration</param-name>
<param-value>exist-conf.xml</param-value>
</init-param>
<init-param>
<param-name>start</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<!-- Uncomment this for the eXist WebDAV support -->
<!--
<servlet>
<servlet-name>exist-webdav-servlet</servlet-name>
<servlet-class>org.exist.http.servlets.WebDAVServlet</servlet-class>
<init-param>
<param-name>authentication</param-name>
<param-value>basic</param-value>
</init-param>
</servlet>-->
<!-- End eXist WebDAV support -->
<servlet-mapping>
<servlet-name>orbeon-main-servlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>orbeon-renderer-servlet</servlet-name>
<url-pattern>/xforms-renderer</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>exist-rest-servlet</servlet-name>
<url-pattern>/exist/rest/*</url-pattern>
</servlet-mapping>
<!-- Uncomment this for the eXist XMLRPC support -->
<!--
<servlet-mapping>
<servlet-name>exist-xmlrpc-servlet</servlet-name>
<url-pattern>/exist/xmlrpc</url-pattern>
</servlet-mapping>-->
<!-- End eXist XMLRPC support -->
<!-- Uncomment this for the eXist WebDAV support -->
<!--
<servlet-mapping>
<servlet-name>exist-webdav-servlet</servlet-name>
<url-pattern>/exist/webdav/*</url-pattern>
</servlet-mapping>-->
<!-- End eXist WebDAV support -->
<!-- Uncomment this for the relational persistence, and change oracle if necessary -->
<resource-ref>
<description>DataSource</description>
<res-ref-name>jdbc/postgresql</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<!-- End relational persistence, and change oracle if necessary -->
<!-- Uncomment this for the Form Runner authentication -->
<security-constraint>
<web-resource-collection>
<web-resource-name>Form Builder</web-resource-name>
<url-pattern>/fr/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>form-user</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Form Builder</web-resource-name>
<url-pattern>/fr/orbeon/builder/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>form-admin</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Form Runner services and public pages and resources</web-resource-name>
<url-pattern>/fr/service/*</url-pattern>
<url-pattern>/fr/style/*</url-pattern>
<url-pattern>/fr/not-found</url-pattern>
<url-pattern>/fr/unauthorized</url-pattern>
<url-pattern>/fr/error</url-pattern>
<url-pattern>/fr/login</url-pattern>
<url-pattern>/fr/login-error</url-pattern>
</web-resource-collection>
<!--<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>-->
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>Secure content</realm-name>
<form-login-config>
<form-login-page>/fr/login</form-login-page>
<form-error-page>/fr/login-error</form-error-page>
</form-login-config>
</login-config>
<security-role>
<role-name>form-admin</role-name>
</security-role>
<security-role>
<role-name>form-user</role-name>
</security-role>
<!-- End Form Runner authentication -->
<session-config>
<session-timeout>60</session-timeout>
</session-config>
</web-app>

2
configuration/info Normal file
View File

@ -0,0 +1,2 @@
Installation and configuration:
http://confluence.moose.local/display/HYC/Configuration+of+testing+environment

View File

@ -0,0 +1,42 @@
CREATE TABLE dropdown_currency
(
id bigint NOT NULL,
entity character varying(120) NOT NULL,
currency character varying(120) NOT NULL,
alphabetic_code character varying(3) NOT NULL,
numeric_code character varying(3) NOT NULL,
CONSTRAINT dropdown_currency_pkey PRIMARY KEY (id)
);
CREATE TABLE dropdown_country
(
id bigint NOT NULL,
iso_alpha2 character varying(2) NOT NULL,
iso_alpha3 character varying(3) NOT NULL,
iso_numeric SMALLINT NOT NULL,
name character varying(120) NOT NULL,
CONSTRAINT dropdown_country_pkey PRIMARY KEY (id)
);
CREATE TABLE dropdown_member_type
(
id bigint NOT NULL,
name character varying(120) NOT NULL,
CONSTRAINT dropdown_member_type_pkey PRIMARY KEY (id)
);
CREATE TABLE dropdown_certificate_standard
(
id bigint NOT NULL,
name character varying(60) NOT NULL,
CONSTRAINT dropdown_certificate_standard_pkey PRIMARY KEY (id)
);
CREATE TABLE dropdown_service_type
(
id bigint NOT NULL,
name character varying(120) NOT NULL,
description character varying(120) NOT NULL,
CONSTRAINT dropdown_service_type_pkey PRIMARY KEY (id)
);

View File

@ -0,0 +1,556 @@
--Currencies
INSERT INTO dropdown_currency VALUES(1,'AFGHANISTAN','Afghani','AFN','971');
INSERT INTO dropdown_currency VALUES(2,'ÅLAND ISLANDS','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(3,'ALBANIA','Lek','ALL','008');
INSERT INTO dropdown_currency VALUES(4,'ALGERIA','Algerian Dinar','DZD','012');
INSERT INTO dropdown_currency VALUES(5,'AMERICAN SAMOA','US Dollar','USD','840');
INSERT INTO dropdown_currency VALUES(6,'ANDORRA','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(7,'ANGOLA','Kwanza','AOA','973');
INSERT INTO dropdown_currency VALUES(8,'ANGUILLA','East Caribbean Dollar','XCD','951');
INSERT INTO dropdown_currency VALUES(9,'ANTARCTICA','No universal currency','N/C','');
INSERT INTO dropdown_currency VALUES(10,'ANTIGUA AND BARBUDA','East Caribbean Dollar','XCD','951');
INSERT INTO dropdown_currency VALUES(11,'ARGENTINA','Argentine Peso','ARS','032');
INSERT INTO dropdown_currency VALUES(12,'ARMENIA','Armenian Dram','AMD','051');
INSERT INTO dropdown_currency VALUES(13,'ARUBA','Aruban Florin','AWG','533');
INSERT INTO dropdown_currency VALUES(14,'AUSTRALIA','Australian Dollar','AUD','036');
INSERT INTO dropdown_currency VALUES(15,'AUSTRIA','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(16,'AZERBAIJAN','Azerbaijan Manat','AZN','944');
INSERT INTO dropdown_currency VALUES(17,'BAHAMAS (THE)','Bahamian Dollar','BSD','044');
INSERT INTO dropdown_currency VALUES(18,'BAHRAIN','Bahraini Dinar','BHD','048');
INSERT INTO dropdown_currency VALUES(19,'BANGLADESH','Taka','BDT','050');
INSERT INTO dropdown_currency VALUES(20,'BARBADOS','Barbados Dollar','BBD','052');
INSERT INTO dropdown_currency VALUES(21,'BELARUS','Belarusian Ruble','BYN','933');
INSERT INTO dropdown_currency VALUES(22,'BELGIUM','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(23,'BELIZE','Belize Dollar','BZD','084');
INSERT INTO dropdown_currency VALUES(24,'BENIN','CFA Franc BCEAO','XOF','952');
INSERT INTO dropdown_currency VALUES(25,'BERMUDA','Bermudian Dollar','BMD','060');
INSERT INTO dropdown_currency VALUES(26,'BHUTAN','Indian Rupee','INR','356');
INSERT INTO dropdown_currency VALUES(27,'BHUTAN','Ngultrum','BTN','064');
INSERT INTO dropdown_currency VALUES(28,'BOLIVIA (PLURINATIONAL STATE OF)','Boliviano','BOB','068');
INSERT INTO dropdown_currency VALUES(29,'BOLIVIA (PLURINATIONAL STATE OF)','Mvdol','BOV','984');
INSERT INTO dropdown_currency VALUES(30,'BONAIRE, SINT EUSTATIUS AND SABA','US Dollar','USD','840');
INSERT INTO dropdown_currency VALUES(31,'BOSNIA AND HERZEGOVINA','Convertible Mark','BAM','977');
INSERT INTO dropdown_currency VALUES(32,'BOTSWANA','Pula','BWP','072');
INSERT INTO dropdown_currency VALUES(33,'BOUVET ISLAND','Norwegian Krone','NOK','578');
INSERT INTO dropdown_currency VALUES(34,'BRAZIL','Brazilian Real','BRL','986');
INSERT INTO dropdown_currency VALUES(35,'BRITISH INDIAN OCEAN TERRITORY (THE)','US Dollar','USD','840');
INSERT INTO dropdown_currency VALUES(36,'BRUNEI DARUSSALAM','Brunei Dollar','BND','096');
INSERT INTO dropdown_currency VALUES(37,'BULGARIA','Bulgarian Lev','BGN','975');
INSERT INTO dropdown_currency VALUES(38,'BURKINA FASO','CFA Franc BCEAO','XOF','952');
INSERT INTO dropdown_currency VALUES(39,'BURUNDI','Burundi Franc','BIF','108');
INSERT INTO dropdown_currency VALUES(40,'CABO VERDE','Cabo Verde Escudo','CVE','132');
INSERT INTO dropdown_currency VALUES(41,'CAMBODIA','Riel','KHR','116');
INSERT INTO dropdown_currency VALUES(42,'CAMEROON','CFA Franc BEAC','XAF','950');
INSERT INTO dropdown_currency VALUES(43,'CANADA','Canadian Dollar','CAD','124');
INSERT INTO dropdown_currency VALUES(44,'CAYMAN ISLANDS (THE)','Cayman Islands Dollar','KYD','136');
INSERT INTO dropdown_currency VALUES(45,'CENTRAL AFRICAN REPUBLIC (THE)','CFA Franc BEAC','XAF','950');
INSERT INTO dropdown_currency VALUES(46,'CHAD','CFA Franc BEAC','XAF','950');
INSERT INTO dropdown_currency VALUES(47,'CHILE','Chilean Peso','CLP','152');
INSERT INTO dropdown_currency VALUES(48,'CHILE','Unidad de Fomento','CLF','990');
INSERT INTO dropdown_currency VALUES(49,'CHINA','Yuan Renminbi','CNY','156');
INSERT INTO dropdown_currency VALUES(50,'CHRISTMAS ISLAND','Australian Dollar','AUD','036');
INSERT INTO dropdown_currency VALUES(51,'COCOS (KEELING) ISLANDS (THE)','Australian Dollar','AUD','036');
INSERT INTO dropdown_currency VALUES(52,'COLOMBIA','Colombian Peso','COP','170');
INSERT INTO dropdown_currency VALUES(53,'COLOMBIA','Unidad de Valor Real','COU','970');
INSERT INTO dropdown_currency VALUES(54,'COMOROS (THE)','Comorian Franc ','KMF','174');
INSERT INTO dropdown_currency VALUES(55,'CONGO (THE DEMOCRATIC REPUBLIC OF THE)','Congolese Franc','CDF','976');
INSERT INTO dropdown_currency VALUES(56,'CONGO (THE)','CFA Franc BEAC','XAF','950');
INSERT INTO dropdown_currency VALUES(57,'COOK ISLANDS (THE)','New Zealand Dollar','NZD','554');
INSERT INTO dropdown_currency VALUES(58,'COSTA RICA','Costa Rican Colon','CRC','188');
INSERT INTO dropdown_currency VALUES(59,'CÔTE D''IVOIRE','CFA Franc BCEAO','XOF','952');
INSERT INTO dropdown_currency VALUES(60,'CROATIA','Kuna','HRK','191');
INSERT INTO dropdown_currency VALUES(61,'CUBA','Cuban Peso','CUP','192');
INSERT INTO dropdown_currency VALUES(62,'CUBA','Peso Convertible','CUC','931');
INSERT INTO dropdown_currency VALUES(63,'CURAÇAO','Netherlands Antillean Guilder','ANG','532');
INSERT INTO dropdown_currency VALUES(64,'CYPRUS','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(65,'CZECHIA','Czech Koruna','CZK','203');
INSERT INTO dropdown_currency VALUES(66,'DENMARK','Danish Krone','DKK','208');
INSERT INTO dropdown_currency VALUES(67,'DJIBOUTI','Djibouti Franc','DJF','262');
INSERT INTO dropdown_currency VALUES(68,'DOMINICA','East Caribbean Dollar','XCD','951');
INSERT INTO dropdown_currency VALUES(69,'DOMINICAN REPUBLIC (THE)','Dominican Peso','DOP','214');
INSERT INTO dropdown_currency VALUES(70,'ECUADOR','US Dollar','USD','840');
INSERT INTO dropdown_currency VALUES(71,'EGYPT','Egyptian Pound','EGP','818');
INSERT INTO dropdown_currency VALUES(72,'EL SALVADOR','El Salvador Colon','SVC','222');
INSERT INTO dropdown_currency VALUES(73,'EL SALVADOR','US Dollar','USD','840');
INSERT INTO dropdown_currency VALUES(74,'EQUATORIAL GUINEA','CFA Franc BEAC','XAF','950');
INSERT INTO dropdown_currency VALUES(75,'ERITREA','Nakfa','ERN','232');
INSERT INTO dropdown_currency VALUES(76,'ESTONIA','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(77,'ETHIOPIA','Ethiopian Birr','ETB','230');
INSERT INTO dropdown_currency VALUES(78,'EUROPEAN UNION','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(79,'FALKLAND ISLANDS (THE) [MALVINAS]','Falkland Islands Pound','FKP','238');
INSERT INTO dropdown_currency VALUES(80,'FAROE ISLANDS (THE)','Danish Krone','DKK','208');
INSERT INTO dropdown_currency VALUES(81,'FIJI','Fiji Dollar','FJD','242');
INSERT INTO dropdown_currency VALUES(82,'FINLAND','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(83,'FRANCE','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(84,'FRENCH GUIANA','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(85,'FRENCH POLYNESIA','CFP Franc','XPF','953');
INSERT INTO dropdown_currency VALUES(86,'FRENCH SOUTHERN TERRITORIES (THE)','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(87,'GABON','CFA Franc BEAC','XAF','950');
INSERT INTO dropdown_currency VALUES(88,'GAMBIA (THE)','Dalasi','GMD','270');
INSERT INTO dropdown_currency VALUES(89,'GEORGIA','Lari','GEL','981');
INSERT INTO dropdown_currency VALUES(90,'GERMANY','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(91,'GHANA','Ghana Cedi','GHS','936');
INSERT INTO dropdown_currency VALUES(92,'GIBRALTAR','Gibraltar Pound','GIP','292');
INSERT INTO dropdown_currency VALUES(93,'GREECE','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(94,'GREENLAND','Danish Krone','DKK','208');
INSERT INTO dropdown_currency VALUES(95,'GRENADA','East Caribbean Dollar','XCD','951');
INSERT INTO dropdown_currency VALUES(96,'GUADELOUPE','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(97,'GUAM','US Dollar','USD','840');
INSERT INTO dropdown_currency VALUES(98,'GUATEMALA','Quetzal','GTQ','320');
INSERT INTO dropdown_currency VALUES(99,'GUERNSEY','Pound Sterling','GBP','826');
INSERT INTO dropdown_currency VALUES(100,'GUINEA','Guinean Franc','GNF','324');
INSERT INTO dropdown_currency VALUES(101,'GUINEA-BISSAU','CFA Franc BCEAO','XOF','952');
INSERT INTO dropdown_currency VALUES(102,'GUYANA','Guyana Dollar','GYD','328');
INSERT INTO dropdown_currency VALUES(103,'HAITI','Gourde','HTG','332');
INSERT INTO dropdown_currency VALUES(104,'HAITI','US Dollar','USD','840');
INSERT INTO dropdown_currency VALUES(105,'HEARD ISLAND AND McDONALD ISLANDS','Australian Dollar','AUD','036');
INSERT INTO dropdown_currency VALUES(106,'HOLY SEE (THE)','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(107,'HONDURAS','Lempira','HNL','340');
INSERT INTO dropdown_currency VALUES(108,'HONG KONG','Hong Kong Dollar','HKD','344');
INSERT INTO dropdown_currency VALUES(109,'HUNGARY','Forint','HUF','348');
INSERT INTO dropdown_currency VALUES(110,'ICELAND','Iceland Krona','ISK','352');
INSERT INTO dropdown_currency VALUES(111,'INDIA','Indian Rupee','INR','356');
INSERT INTO dropdown_currency VALUES(112,'INDONESIA','Rupiah','IDR','360');
INSERT INTO dropdown_currency VALUES(113,'INTERNATIONAL MONETARY FUND (IMF) ','SDR (Special Drawing Right)','XDR','960');
INSERT INTO dropdown_currency VALUES(114,'IRAN (ISLAMIC REPUBLIC OF)','Iranian Rial','IRR','364');
INSERT INTO dropdown_currency VALUES(115,'IRAQ','Iraqi Dinar','IQD','368');
INSERT INTO dropdown_currency VALUES(116,'IRELAND','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(117,'ISLE OF MAN','Pound Sterling','GBP','826');
INSERT INTO dropdown_currency VALUES(118,'ISRAEL','New Israeli Sheqel','ILS','376');
INSERT INTO dropdown_currency VALUES(119,'ITALY','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(120,'JAMAICA','Jamaican Dollar','JMD','388');
INSERT INTO dropdown_currency VALUES(121,'JAPAN','Yen','JPY','392');
INSERT INTO dropdown_currency VALUES(122,'JERSEY','Pound Sterling','GBP','826');
INSERT INTO dropdown_currency VALUES(123,'JORDAN','Jordanian Dinar','JOD','400');
INSERT INTO dropdown_currency VALUES(124,'KAZAKHSTAN','Tenge','KZT','398');
INSERT INTO dropdown_currency VALUES(125,'KENYA','Kenyan Shilling','KES','404');
INSERT INTO dropdown_currency VALUES(126,'KIRIBATI','Australian Dollar','AUD','036');
INSERT INTO dropdown_currency VALUES(127,'KOREA (THE DEMOCRATIC PEOPLES REPUBLIC OF)','North Korean Won','KPW','408');
INSERT INTO dropdown_currency VALUES(128,'KOREA (THE REPUBLIC OF)','Won','KRW','410');
INSERT INTO dropdown_currency VALUES(129,'KUWAIT','Kuwaiti Dinar','KWD','414');
INSERT INTO dropdown_currency VALUES(130,'KYRGYZSTAN','Som','KGS','417');
INSERT INTO dropdown_currency VALUES(131,'LAO PEOPLES DEMOCRATIC REPUBLIC (THE)','Lao Kip','LAK','418');
INSERT INTO dropdown_currency VALUES(132,'LATVIA','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(133,'LEBANON','Lebanese Pound','LBP','422');
INSERT INTO dropdown_currency VALUES(134,'LESOTHO','Loti','LSL','426');
INSERT INTO dropdown_currency VALUES(135,'LESOTHO','Rand','ZAR','710');
INSERT INTO dropdown_currency VALUES(136,'LIBERIA','Liberian Dollar','LRD','430');
INSERT INTO dropdown_currency VALUES(137,'LIBYA','Libyan Dinar','LYD','434');
INSERT INTO dropdown_currency VALUES(138,'LIECHTENSTEIN','Swiss Franc','CHF','756');
INSERT INTO dropdown_currency VALUES(139,'LITHUANIA','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(140,'LUXEMBOURG','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(141,'MACAO','Pataca','MOP','446');
INSERT INTO dropdown_currency VALUES(142,'MACEDONIA (THE FORMER YUGOSLAV REPUBLIC OF)','Denar','MKD','807');
INSERT INTO dropdown_currency VALUES(143,'MADAGASCAR','Malagasy Ariary','MGA','969');
INSERT INTO dropdown_currency VALUES(144,'MALAWI','Malawi Kwacha','MWK','454');
INSERT INTO dropdown_currency VALUES(145,'MALAYSIA','Malaysian Ringgit','MYR','458');
INSERT INTO dropdown_currency VALUES(146,'MALDIVES','Rufiyaa','MVR','462');
INSERT INTO dropdown_currency VALUES(147,'MALI','CFA Franc BCEAO','XOF','952');
INSERT INTO dropdown_currency VALUES(148,'MALTA','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(149,'MARSHALL ISLANDS (THE)','US Dollar','USD','840');
INSERT INTO dropdown_currency VALUES(150,'MARTINIQUE','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(151,'MAURITANIA','Ouguiya','MRO','478');
INSERT INTO dropdown_currency VALUES(152,'MAURITIUS','Mauritius Rupee','MUR','480');
INSERT INTO dropdown_currency VALUES(153,'MAYOTTE','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(154,'MEMBER COUNTRIES OF THE AFRICAN DEVELOPMENT BANK GROUP','ADB Unit of Account','XUA','965');
INSERT INTO dropdown_currency VALUES(155,'MEXICO','Mexican Peso','MXN','484');
INSERT INTO dropdown_currency VALUES(156,'MEXICO','Mexican Unidad de Inversion (UDI)','MXV','979');
INSERT INTO dropdown_currency VALUES(157,'MICRONESIA (FEDERATED STATES OF)','US Dollar','USD','840');
INSERT INTO dropdown_currency VALUES(158,'MOLDOVA (THE REPUBLIC OF)','Moldovan Leu','MDL','498');
INSERT INTO dropdown_currency VALUES(159,'MONACO','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(160,'MONGOLIA','Tugrik','MNT','496');
INSERT INTO dropdown_currency VALUES(161,'MONTENEGRO','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(162,'MONTSERRAT','East Caribbean Dollar','XCD','951');
INSERT INTO dropdown_currency VALUES(163,'MOROCCO','Moroccan Dirham','MAD','504');
INSERT INTO dropdown_currency VALUES(164,'MOZAMBIQUE','Mozambique Metical','MZN','943');
INSERT INTO dropdown_currency VALUES(165,'MYANMAR','Kyat','MMK','104');
INSERT INTO dropdown_currency VALUES(166,'NAMIBIA','Namibia Dollar','NAD','516');
INSERT INTO dropdown_currency VALUES(167,'NAMIBIA','Rand','ZAR','710');
INSERT INTO dropdown_currency VALUES(168,'NAURU','Australian Dollar','AUD','036');
INSERT INTO dropdown_currency VALUES(169,'NEPAL','Nepalese Rupee','NPR','524');
INSERT INTO dropdown_currency VALUES(170,'NETHERLANDS (THE)','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(171,'NEW CALEDONIA','CFP Franc','XPF','953');
INSERT INTO dropdown_currency VALUES(172,'NEW ZEALAND','New Zealand Dollar','NZD','554');
INSERT INTO dropdown_currency VALUES(173,'NICARAGUA','Cordoba Oro','NIO','558');
INSERT INTO dropdown_currency VALUES(174,'NIGER (THE)','CFA Franc BCEAO','XOF','952');
INSERT INTO dropdown_currency VALUES(175,'NIGERIA','Naira','NGN','566');
INSERT INTO dropdown_currency VALUES(176,'NIUE','New Zealand Dollar','NZD','554');
INSERT INTO dropdown_currency VALUES(177,'NORFOLK ISLAND','Australian Dollar','AUD','036');
INSERT INTO dropdown_currency VALUES(178,'NORTHERN MARIANA ISLANDS (THE)','US Dollar','USD','840');
INSERT INTO dropdown_currency VALUES(179,'NORWAY','Norwegian Krone','NOK','578');
INSERT INTO dropdown_currency VALUES(180,'OMAN','Rial Omani','OMR','512');
INSERT INTO dropdown_currency VALUES(181,'PAKISTAN','Pakistan Rupee','PKR','586');
INSERT INTO dropdown_currency VALUES(182,'PALAU','US Dollar','USD','840');
INSERT INTO dropdown_currency VALUES(183,'PALESTINE, STATE OF','No universal currency','N/C','N/C');
INSERT INTO dropdown_currency VALUES(184,'PANAMA','Balboa','PAB','590');
INSERT INTO dropdown_currency VALUES(185,'PANAMA','US Dollar','USD','840');
INSERT INTO dropdown_currency VALUES(186,'PAPUA NEW GUINEA','Kina','PGK','598');
INSERT INTO dropdown_currency VALUES(187,'PARAGUAY','Guarani','PYG','600');
INSERT INTO dropdown_currency VALUES(188,'PERU','Sol','PEN','604');
INSERT INTO dropdown_currency VALUES(189,'PHILIPPINES (THE)','Philippine Peso','PHP','608');
INSERT INTO dropdown_currency VALUES(190,'PITCAIRN','New Zealand Dollar','NZD','554');
INSERT INTO dropdown_currency VALUES(191,'POLAND','Zloty','PLN','985');
INSERT INTO dropdown_currency VALUES(192,'PORTUGAL','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(193,'PUERTO RICO','US Dollar','USD','840');
INSERT INTO dropdown_currency VALUES(194,'QATAR','Qatari Rial','QAR','634');
INSERT INTO dropdown_currency VALUES(195,'RÉUNION','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(196,'ROMANIA','Romanian Leu','RON','946');
INSERT INTO dropdown_currency VALUES(197,'RUSSIAN FEDERATION (THE)','Russian Ruble','RUB','643');
INSERT INTO dropdown_currency VALUES(198,'RWANDA','Rwanda Franc','RWF','646');
INSERT INTO dropdown_currency VALUES(199,'SAINT BARTHÉLEMY','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(200,'SAINT HELENA, ASCENSION AND TRISTAN DA CUNHA','Saint Helena Pound','SHP','654');
INSERT INTO dropdown_currency VALUES(201,'SAINT KITTS AND NEVIS','East Caribbean Dollar','XCD','951');
INSERT INTO dropdown_currency VALUES(202,'SAINT LUCIA','East Caribbean Dollar','XCD','951');
INSERT INTO dropdown_currency VALUES(203,'SAINT MARTIN (FRENCH PART)','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(204,'SAINT PIERRE AND MIQUELON','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(205,'SAINT VINCENT AND THE GRENADINES','East Caribbean Dollar','XCD','951');
INSERT INTO dropdown_currency VALUES(206,'SAMOA','Tala','WST','882');
INSERT INTO dropdown_currency VALUES(207,'SAN MARINO','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(208,'SAO TOME AND PRINCIPE','Dobra','STD','678');
INSERT INTO dropdown_currency VALUES(209,'SAUDI ARABIA','Saudi Riyal','SAR','682');
INSERT INTO dropdown_currency VALUES(210,'SENEGAL','CFA Franc BCEAO','XOF','952');
INSERT INTO dropdown_currency VALUES(211,'SERBIA','Serbian Dinar','RSD','941');
INSERT INTO dropdown_currency VALUES(212,'SEYCHELLES','Seychelles Rupee','SCR','690');
INSERT INTO dropdown_currency VALUES(213,'SIERRA LEONE','Leone','SLL','694');
INSERT INTO dropdown_currency VALUES(214,'SINGAPORE','Singapore Dollar','SGD','702');
INSERT INTO dropdown_currency VALUES(215,'SINT MAARTEN (DUTCH PART)','Netherlands Antillean Guilder','ANG','532');
INSERT INTO dropdown_currency VALUES(216,'SISTEMA UNITARIO DE COMPENSACION REGIONAL DE PAGOS "SUCRE"','Sucre','XSU','994');
INSERT INTO dropdown_currency VALUES(217,'SLOVAKIA','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(218,'SLOVENIA','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(219,'SOLOMON ISLANDS','Solomon Islands Dollar','SBD','090');
INSERT INTO dropdown_currency VALUES(220,'SOMALIA','Somali Shilling','SOS','706');
INSERT INTO dropdown_currency VALUES(221,'SOUTH AFRICA','Rand','ZAR','710');
INSERT INTO dropdown_currency VALUES(222,'SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS','No universal currency','N/C','');
INSERT INTO dropdown_currency VALUES(223,'SOUTH SUDAN','South Sudanese Pound','SSP','728');
INSERT INTO dropdown_currency VALUES(224,'SPAIN','Euro','EUR','978');
INSERT INTO dropdown_currency VALUES(225,'SRI LANKA','Sri Lanka Rupee','LKR','144');
INSERT INTO dropdown_currency VALUES(226,'SUDAN (THE)','Sudanese Pound','SDG','938');
INSERT INTO dropdown_currency VALUES(227,'SURINAME','Surinam Dollar','SRD','968');
INSERT INTO dropdown_currency VALUES(228,'SVALBARD AND JAN MAYEN','Norwegian Krone','NOK','578');
INSERT INTO dropdown_currency VALUES(229,'SWAZILAND','Lilangeni','SZL','748');
INSERT INTO dropdown_currency VALUES(230,'SWEDEN','Swedish Krona','SEK','752');
INSERT INTO dropdown_currency VALUES(231,'SWITZERLAND','Swiss Franc','CHF','756');
INSERT INTO dropdown_currency VALUES(232,'SWITZERLAND','WIR Euro','CHE','947');
INSERT INTO dropdown_currency VALUES(233,'SWITZERLAND','WIR Franc','CHW','948');
INSERT INTO dropdown_currency VALUES(234,'SYRIAN ARAB REPUBLIC','Syrian Pound','SYP','760');
INSERT INTO dropdown_currency VALUES(235,'TAIWAN (PROVINCE OF CHINA)','New Taiwan Dollar','TWD','901');
INSERT INTO dropdown_currency VALUES(236,'TAJIKISTAN','Somoni','TJS','972');
INSERT INTO dropdown_currency VALUES(237,'TANZANIA, UNITED REPUBLIC OF','Tanzanian Shilling','TZS','834');
INSERT INTO dropdown_currency VALUES(238,'THAILAND','Baht','THB','764');
INSERT INTO dropdown_currency VALUES(239,'TIMOR-LESTE','US Dollar','USD','840');
INSERT INTO dropdown_currency VALUES(240,'TOGO','CFA Franc BCEAO','XOF','952');
INSERT INTO dropdown_currency VALUES(241,'TOKELAU','New Zealand Dollar','NZD','554');
INSERT INTO dropdown_currency VALUES(242,'TONGA','Paanga','TOP','776');
INSERT INTO dropdown_currency VALUES(243,'TRINIDAD AND TOBAGO','Trinidad and Tobago Dollar','TTD','780');
INSERT INTO dropdown_currency VALUES(244,'TUNISIA','Tunisian Dinar','TND','788');
INSERT INTO dropdown_currency VALUES(245,'TURKEY','Turkish Lira','TRY','949');
INSERT INTO dropdown_currency VALUES(246,'TURKMENISTAN','Turkmenistan New Manat','TMT','934');
INSERT INTO dropdown_currency VALUES(247,'TURKS AND CAICOS ISLANDS (THE)','US Dollar','USD','840');
INSERT INTO dropdown_currency VALUES(248,'TUVALU','Australian Dollar','AUD','036');
INSERT INTO dropdown_currency VALUES(249,'UGANDA','Uganda Shilling','UGX','800');
INSERT INTO dropdown_currency VALUES(250,'UKRAINE','Hryvnia','UAH','980');
INSERT INTO dropdown_currency VALUES(251,'UNITED ARAB EMIRATES (THE)','UAE Dirham','AED','784');
INSERT INTO dropdown_currency VALUES(252,'UNITED KINGDOM OF GREAT BRITAIN AND NORTHERN IRELAND (THE)','Pound Sterling','GBP','826');
INSERT INTO dropdown_currency VALUES(253,'UNITED STATES MINOR OUTLYING ISLANDS (THE)','US Dollar','USD','840');
INSERT INTO dropdown_currency VALUES(254,'UNITED STATES OF AMERICA (THE)','US Dollar','USD','840');
INSERT INTO dropdown_currency VALUES(255,'UNITED STATES OF AMERICA (THE)','US Dollar (Next day)','USN','997');
INSERT INTO dropdown_currency VALUES(256,'URUGUAY','Peso Uruguayo','UYU','858');
INSERT INTO dropdown_currency VALUES(257,'URUGUAY','Uruguay Peso en Unidades Indexadas (URUIURUI)','UYI','940');
INSERT INTO dropdown_currency VALUES(258,'UZBEKISTAN','Uzbekistan Sum','UZS','860');
INSERT INTO dropdown_currency VALUES(259,'VANUATU','Vatu','VUV','548');
INSERT INTO dropdown_currency VALUES(260,'VENEZUELA (BOLIVARIAN REPUBLIC OF)','Bolívar','VEF','937');
INSERT INTO dropdown_currency VALUES(261,'VIET NAM','Dong','VND','704');
INSERT INTO dropdown_currency VALUES(262,'VIRGIN ISLANDS (BRITISH)','US Dollar','USD','840');
INSERT INTO dropdown_currency VALUES(263,'VIRGIN ISLANDS (U.S.)','US Dollar','USD','840');
INSERT INTO dropdown_currency VALUES(264,'WALLIS AND FUTUNA','CFP Franc','XPF','953');
INSERT INTO dropdown_currency VALUES(265,'WESTERN SAHARA','Moroccan Dirham','MAD','504');
INSERT INTO dropdown_currency VALUES(266,'YEMEN','Yemeni Rial','YER','886');
INSERT INTO dropdown_currency VALUES(267,'ZAMBIA','Zambian Kwacha','ZMW','967');
INSERT INTO dropdown_currency VALUES(268,'ZIMBABWE','Zimbabwe Dollar','ZWL','932');
--Countries
INSERT INTO dropdown_country VALUES(1,'AF','AFG',4,'Afghanistan');
INSERT INTO dropdown_country VALUES(2,'AX','ALA',248,'Åland Islands');
INSERT INTO dropdown_country VALUES(3,'AL','ALB',8,'Albania');
INSERT INTO dropdown_country VALUES(4,'DZ','DZA',12,'Algeria');
INSERT INTO dropdown_country VALUES(5,'AS','ASM',16,'American Samoa');
INSERT INTO dropdown_country VALUES(6,'AD','AND',20,'Andorra');
INSERT INTO dropdown_country VALUES(7,'AO','AGO',24,'Angola');
INSERT INTO dropdown_country VALUES(8,'AI','AIA',660,'Anguilla');
INSERT INTO dropdown_country VALUES(9,'AQ','ATA',10,'Antarctica');
INSERT INTO dropdown_country VALUES(10,'AG','ATG',28,'Antigua and Barbuda');
INSERT INTO dropdown_country VALUES(11,'AR','ARG',32,'Argentina');
INSERT INTO dropdown_country VALUES(12,'AM','ARM',51,'Armenia');
INSERT INTO dropdown_country VALUES(13,'AW','ABW',533,'Aruba');
INSERT INTO dropdown_country VALUES(14,'AU','AUS',36,'Australia');
INSERT INTO dropdown_country VALUES(15,'AT','AUT',40,'Austria');
INSERT INTO dropdown_country VALUES(16,'AZ','AZE',31,'Azerbaijan');
INSERT INTO dropdown_country VALUES(17,'BS','BHS',44,'Bahamas');
INSERT INTO dropdown_country VALUES(18,'BH','BHR',48,'Bahrain');
INSERT INTO dropdown_country VALUES(19,'BD','BGD',50,'Bangladesh');
INSERT INTO dropdown_country VALUES(20,'BB','BRB',52,'Barbados');
INSERT INTO dropdown_country VALUES(21,'BY','BLR',112,'Belarus');
INSERT INTO dropdown_country VALUES(22,'BE','BEL',56,'Belgium');
INSERT INTO dropdown_country VALUES(23,'BZ','BLZ',84,'Belize');
INSERT INTO dropdown_country VALUES(24,'BJ','BEN',204,'Benin');
INSERT INTO dropdown_country VALUES(25,'BM','BMU',60,'Bermuda');
INSERT INTO dropdown_country VALUES(26,'BT','BTN',64,'Bhutan');
INSERT INTO dropdown_country VALUES(27,'BO','BOL',68,'Bolivia (Plurinational State of)');
INSERT INTO dropdown_country VALUES(28,'BQ','BES',535,'Bonaire, Sint Eustatius and Saba');
INSERT INTO dropdown_country VALUES(29,'BA','BIH',70,'Bosnia and Herzegovina');
INSERT INTO dropdown_country VALUES(30,'BW','BWA',72,'Botswana');
INSERT INTO dropdown_country VALUES(31,'BV','BVT',74,'Bouvet Island');
INSERT INTO dropdown_country VALUES(32,'BR','BRA',76,'Brazil');
INSERT INTO dropdown_country VALUES(33,'IO','IOT',86,'British Indian Ocean Territory');
INSERT INTO dropdown_country VALUES(34,'BN','BRN',96,'Brunei Darussalam');
INSERT INTO dropdown_country VALUES(35,'BG','BGR',100,'Bulgaria');
INSERT INTO dropdown_country VALUES(36,'BF','BFA',854,'Burkina Faso');
INSERT INTO dropdown_country VALUES(37,'BI','BDI',108,'Burundi');
INSERT INTO dropdown_country VALUES(38,'KH','KHM',116,'Cambodia');
INSERT INTO dropdown_country VALUES(39,'CM','CMR',120,'Cameroon');
INSERT INTO dropdown_country VALUES(40,'CA','CAN',124,'Canada');
INSERT INTO dropdown_country VALUES(41,'CV','CPV',132,'Cabo Verde');
INSERT INTO dropdown_country VALUES(42,'KY','CYM',136,'Cayman Islands');
INSERT INTO dropdown_country VALUES(43,'CF','CAF',140,'Central African Republic');
INSERT INTO dropdown_country VALUES(44,'TD','TCD',148,'Chad');
INSERT INTO dropdown_country VALUES(45,'CL','CHL',152,'Chile');
INSERT INTO dropdown_country VALUES(46,'CN','CHN',156,'China');
INSERT INTO dropdown_country VALUES(47,'CX','CXR',162,'Christmas Island');
INSERT INTO dropdown_country VALUES(48,'CC','CCK',166,'Cocos (Keeling) Islands');
INSERT INTO dropdown_country VALUES(49,'CO','COL',170,'Colombia');
INSERT INTO dropdown_country VALUES(50,'KM','COM',174,'Comoros');
INSERT INTO dropdown_country VALUES(51,'CG','COG',178,'Congo');
INSERT INTO dropdown_country VALUES(52,'CD','COD',180,'Congo (Democratic Republic of the)');
INSERT INTO dropdown_country VALUES(53,'CK','COK',184,'Cook Islands');
INSERT INTO dropdown_country VALUES(54,'CR','CRI',188,'Costa Rica');
INSERT INTO dropdown_country VALUES(55,'CI','CIV',384,'Côte d''Ivoire');
INSERT INTO dropdown_country VALUES(56,'HR','HRV',191,'Croatia');
INSERT INTO dropdown_country VALUES(57,'CU','CUB',192,'Cuba');
INSERT INTO dropdown_country VALUES(58,'CW','CUW',531,'Curaçao');
INSERT INTO dropdown_country VALUES(59,'CY','CYP',196,'Cyprus');
INSERT INTO dropdown_country VALUES(60,'CZ','CZE',203,'Czech Republic');
INSERT INTO dropdown_country VALUES(61,'DK','DNK',208,'Denmark');
INSERT INTO dropdown_country VALUES(62,'DJ','DJI',262,'Djibouti');
INSERT INTO dropdown_country VALUES(63,'DM','DMA',212,'Dominica');
INSERT INTO dropdown_country VALUES(64,'DO','DOM',214,'Dominican Republic');
INSERT INTO dropdown_country VALUES(65,'EC','ECU',218,'Ecuador');
INSERT INTO dropdown_country VALUES(66,'EG','EGY',818,'Egypt');
INSERT INTO dropdown_country VALUES(67,'SV','SLV',222,'El Salvador');
INSERT INTO dropdown_country VALUES(68,'GQ','GNQ',226,'Equatorial Guinea');
INSERT INTO dropdown_country VALUES(69,'ER','ERI',232,'Eritrea');
INSERT INTO dropdown_country VALUES(70,'EE','EST',233,'Estonia');
INSERT INTO dropdown_country VALUES(71,'ET','ETH',231,'Ethiopia');
INSERT INTO dropdown_country VALUES(72,'FK','FLK',238,'Falkland Islands (Malvinas)');
INSERT INTO dropdown_country VALUES(73,'FO','FRO',234,'Faroe Islands');
INSERT INTO dropdown_country VALUES(74,'FJ','FJI',242,'Fiji');
INSERT INTO dropdown_country VALUES(75,'FI','FIN',246,'Finland');
INSERT INTO dropdown_country VALUES(76,'FR','FRA',250,'France');
INSERT INTO dropdown_country VALUES(77,'GF','GUF',254,'French Guiana');
INSERT INTO dropdown_country VALUES(78,'PF','PYF',258,'French Polynesia');
INSERT INTO dropdown_country VALUES(79,'TF','ATF',260,'French Southern Territories');
INSERT INTO dropdown_country VALUES(80,'GA','GAB',266,'Gabon');
INSERT INTO dropdown_country VALUES(81,'GM','GMB',270,'Gambia');
INSERT INTO dropdown_country VALUES(82,'GE','GEO',268,'Georgia');
INSERT INTO dropdown_country VALUES(83,'DE','DEU',276,'Germany');
INSERT INTO dropdown_country VALUES(84,'GH','GHA',288,'Ghana');
INSERT INTO dropdown_country VALUES(85,'GI','GIB',292,'Gibraltar');
INSERT INTO dropdown_country VALUES(86,'GR','GRC',300,'Greece');
INSERT INTO dropdown_country VALUES(87,'GL','GRL',304,'Greenland');
INSERT INTO dropdown_country VALUES(88,'GD','GRD',308,'Grenada');
INSERT INTO dropdown_country VALUES(89,'GP','GLP',312,'Guadeloupe');
INSERT INTO dropdown_country VALUES(90,'GU','GUM',316,'Guam');
INSERT INTO dropdown_country VALUES(91,'GT','GTM',320,'Guatemala');
INSERT INTO dropdown_country VALUES(92,'GG','GGY',831,'Guernsey');
INSERT INTO dropdown_country VALUES(93,'GN','GIN',324,'Guinea');
INSERT INTO dropdown_country VALUES(94,'GW','GNB',624,'Guinea-Bissau');
INSERT INTO dropdown_country VALUES(95,'GY','GUY',328,'Guyana');
INSERT INTO dropdown_country VALUES(96,'HT','HTI',332,'Haiti');
INSERT INTO dropdown_country VALUES(97,'HM','HMD',334,'Heard Island and McDonald Islands');
INSERT INTO dropdown_country VALUES(98,'VA','VAT',336,'Holy See');
INSERT INTO dropdown_country VALUES(99,'HN','HND',340,'Honduras');
INSERT INTO dropdown_country VALUES(100,'HK','HKG',344,'Hong Kong');
INSERT INTO dropdown_country VALUES(101,'HU','HUN',348,'Hungary');
INSERT INTO dropdown_country VALUES(102,'IS','ISL',352,'Iceland');
INSERT INTO dropdown_country VALUES(103,'IN','IND',356,'India');
INSERT INTO dropdown_country VALUES(104,'ID','IDN',360,'Indonesia');
INSERT INTO dropdown_country VALUES(105,'IR','IRN',364,'Iran (Islamic Republic of)');
INSERT INTO dropdown_country VALUES(106,'IQ','IRQ',368,'Iraq');
INSERT INTO dropdown_country VALUES(107,'IE','IRL',372,'Ireland');
INSERT INTO dropdown_country VALUES(108,'IM','IMN',833,'Isle of Man');
INSERT INTO dropdown_country VALUES(109,'IL','ISR',376,'Israel');
INSERT INTO dropdown_country VALUES(110,'IT','ITA',380,'Italy');
INSERT INTO dropdown_country VALUES(111,'JM','JAM',388,'Jamaica');
INSERT INTO dropdown_country VALUES(112,'JP','JPN',392,'Japan');
INSERT INTO dropdown_country VALUES(113,'JE','JEY',832,'Jersey');
INSERT INTO dropdown_country VALUES(114,'JO','JOR',400,'Jordan');
INSERT INTO dropdown_country VALUES(115,'KZ','KAZ',398,'Kazakhstan');
INSERT INTO dropdown_country VALUES(116,'KE','KEN',404,'Kenya');
INSERT INTO dropdown_country VALUES(117,'KI','KIR',296,'Kiribati');
INSERT INTO dropdown_country VALUES(118,'KP','PRK',408,'Korea (Democratic People''s Republic of)');
INSERT INTO dropdown_country VALUES(119,'KR','KOR',410,'Korea (Republic of)');
INSERT INTO dropdown_country VALUES(120,'KO','KOS',780,'Kosovo');
INSERT INTO dropdown_country VALUES(121,'KW','KWT',414,'Kuwait');
INSERT INTO dropdown_country VALUES(122,'KG','KGZ',417,'Kyrgyzstan');
INSERT INTO dropdown_country VALUES(123,'LA','LAO',418,'Lao People''s Democratic Republic');
INSERT INTO dropdown_country VALUES(124,'LV','LVA',428,'Latvia');
INSERT INTO dropdown_country VALUES(125,'LB','LBN',422,'Lebanon');
INSERT INTO dropdown_country VALUES(126,'LS','LSO',426,'Lesotho');
INSERT INTO dropdown_country VALUES(127,'LR','LBR',430,'Liberia');
INSERT INTO dropdown_country VALUES(128,'LY','LBY',434,'Libya');
INSERT INTO dropdown_country VALUES(129,'LI','LIE',438,'Liechtenstein');
INSERT INTO dropdown_country VALUES(130,'LT','LTU',440,'Lithuania');
INSERT INTO dropdown_country VALUES(131,'LU','LUX',442,'Luxembourg');
INSERT INTO dropdown_country VALUES(132,'MO','MAC',446,'Macao');
INSERT INTO dropdown_country VALUES(133,'MK','MKD',807,'Macedonia (the former Yugoslav Republic of)');
INSERT INTO dropdown_country VALUES(134,'MG','MDG',450,'Madagascar');
INSERT INTO dropdown_country VALUES(135,'MW','MWI',454,'Malawi');
INSERT INTO dropdown_country VALUES(136,'MY','MYS',458,'Malaysia');
INSERT INTO dropdown_country VALUES(137,'MV','MDV',462,'Maldives');
INSERT INTO dropdown_country VALUES(138,'ML','MLI',466,'Mali');
INSERT INTO dropdown_country VALUES(139,'MT','MLT',470,'Malta');
INSERT INTO dropdown_country VALUES(140,'MH','MHL',584,'Marshall Islands');
INSERT INTO dropdown_country VALUES(141,'MQ','MTQ',474,'Martinique');
INSERT INTO dropdown_country VALUES(142,'MR','MRT',478,'Mauritania');
INSERT INTO dropdown_country VALUES(143,'MU','MUS',480,'Mauritius');
INSERT INTO dropdown_country VALUES(144,'YT','MYT',175,'Mayotte');
INSERT INTO dropdown_country VALUES(145,'MX','MEX',484,'Mexico');
INSERT INTO dropdown_country VALUES(146,'FM','FSM',583,'Micronesia (Federated States of)');
INSERT INTO dropdown_country VALUES(147,'MD','MDA',498,'Moldova (Republic of)');
INSERT INTO dropdown_country VALUES(148,'MC','MCO',492,'Monaco');
INSERT INTO dropdown_country VALUES(149,'MN','MNG',496,'Mongolia');
INSERT INTO dropdown_country VALUES(150,'ME','MNE',499,'Montenegro');
INSERT INTO dropdown_country VALUES(151,'MS','MSR',500,'Montserrat');
INSERT INTO dropdown_country VALUES(152,'MA','MAR',504,'Morocco');
INSERT INTO dropdown_country VALUES(153,'MZ','MOZ',508,'Mozambique');
INSERT INTO dropdown_country VALUES(154,'MM','MMR',104,'Myanmar');
INSERT INTO dropdown_country VALUES(155,'NA','NAM',516,'Namibia');
INSERT INTO dropdown_country VALUES(156,'NR','NRU',520,'Nauru');
INSERT INTO dropdown_country VALUES(157,'NP','NPL',524,'Nepal');
INSERT INTO dropdown_country VALUES(158,'NL','NLD',528,'Netherlands');
INSERT INTO dropdown_country VALUES(159,'NC','NCL',540,'New Caledonia');
INSERT INTO dropdown_country VALUES(160,'NZ','NZL',554,'New Zealand');
INSERT INTO dropdown_country VALUES(161,'NI','NIC',558,'Nicaragua');
INSERT INTO dropdown_country VALUES(162,'NE','NER',562,'Niger');
INSERT INTO dropdown_country VALUES(163,'NG','NGA',566,'Nigeria');
INSERT INTO dropdown_country VALUES(164,'NU','NIU',570,'Niue');
INSERT INTO dropdown_country VALUES(165,'NF','NFK',574,'Norfolk Island');
INSERT INTO dropdown_country VALUES(166,'MP','MNP',580,'Northern Mariana Islands');
INSERT INTO dropdown_country VALUES(167,'NO','NOR',578,'Norway');
INSERT INTO dropdown_country VALUES(168,'OM','OMN',512,'Oman');
INSERT INTO dropdown_country VALUES(169,'PK','PAK',586,'Pakistan');
INSERT INTO dropdown_country VALUES(170,'PW','PLW',585,'Palau');
INSERT INTO dropdown_country VALUES(171,'PS','PSE',275,'Palestine, State of');
INSERT INTO dropdown_country VALUES(172,'PA','PAN',591,'Panama');
INSERT INTO dropdown_country VALUES(173,'PG','PNG',598,'Papua New Guinea');
INSERT INTO dropdown_country VALUES(174,'PY','PRY',600,'Paraguay');
INSERT INTO dropdown_country VALUES(175,'PE','PER',604,'Peru');
INSERT INTO dropdown_country VALUES(176,'PH','PHL',608,'Philippines');
INSERT INTO dropdown_country VALUES(177,'PN','PCN',612,'Pitcairn');
INSERT INTO dropdown_country VALUES(178,'PL','POL',616,'Poland');
INSERT INTO dropdown_country VALUES(179,'PT','PRT',620,'Portugal');
INSERT INTO dropdown_country VALUES(180,'PR','PRI',630,'Puerto Rico');
INSERT INTO dropdown_country VALUES(181,'QA','QAT',634,'Qatar');
INSERT INTO dropdown_country VALUES(182,'RE','REU',638,'Réunion');
INSERT INTO dropdown_country VALUES(183,'RO','ROU',642,'Romania');
INSERT INTO dropdown_country VALUES(184,'RU','RUS',643,'Russian Federation');
INSERT INTO dropdown_country VALUES(185,'RW','RWA',646,'Rwanda');
INSERT INTO dropdown_country VALUES(186,'BL','BLM',652,'Saint Barthélemy');
INSERT INTO dropdown_country VALUES(187,'SH','SHN',654,'Saint Helena, Ascension and Tristan da Cunha');
INSERT INTO dropdown_country VALUES(188,'KN','KNA',659,'Saint Kitts and Nevis');
INSERT INTO dropdown_country VALUES(189,'LC','LCA',662,'Saint Lucia');
INSERT INTO dropdown_country VALUES(190,'MF','MAF',663,'Saint Martin (French part)');
INSERT INTO dropdown_country VALUES(191,'PM','SPM',666,'Saint Pierre and Miquelon');
INSERT INTO dropdown_country VALUES(192,'VC','VCT',670,'Saint Vincent and the Grenadines');
INSERT INTO dropdown_country VALUES(193,'WS','WSM',882,'Samoa');
INSERT INTO dropdown_country VALUES(194,'SM','SMR',674,'San Marino');
INSERT INTO dropdown_country VALUES(195,'ST','STP',678,'Sao Tome and Principe');
INSERT INTO dropdown_country VALUES(196,'SA','SAU',682,'Saudi Arabia');
INSERT INTO dropdown_country VALUES(197,'SN','SEN',686,'Senegal');
INSERT INTO dropdown_country VALUES(198,'RS','SRB',688,'Serbia');
INSERT INTO dropdown_country VALUES(199,'SC','SYC',690,'Seychelles');
INSERT INTO dropdown_country VALUES(200,'SL','SLE',694,'Sierra Leone');
INSERT INTO dropdown_country VALUES(201,'SG','SGP',702,'Singapore');
INSERT INTO dropdown_country VALUES(202,'SX','SXM',534,'Sint Maarten (Dutch part)');
INSERT INTO dropdown_country VALUES(203,'SK','SVK',703,'Slovakia');
INSERT INTO dropdown_country VALUES(204,'SI','SVN',705,'Slovenia');
INSERT INTO dropdown_country VALUES(205,'SB','SLB',90,'Solomon Islands');
INSERT INTO dropdown_country VALUES(206,'SO','SOM',706,'Somalia');
INSERT INTO dropdown_country VALUES(207,'ZA','ZAF',710,'South Africa');
INSERT INTO dropdown_country VALUES(208,'GS','SGS',239,'South Georgia and the South Sandwich Islands');
INSERT INTO dropdown_country VALUES(209,'SS','SSD',728,'South Sudan');
INSERT INTO dropdown_country VALUES(210,'ES','ESP',724,'Spain');
INSERT INTO dropdown_country VALUES(211,'LK','LKA',144,'Sri Lanka');
INSERT INTO dropdown_country VALUES(212,'SD','SDN',729,'Sudan');
INSERT INTO dropdown_country VALUES(213,'SR','SUR',740,'Suriname');
INSERT INTO dropdown_country VALUES(214,'SJ','SJM',744,'Svalbard and Jan Mayen');
INSERT INTO dropdown_country VALUES(215,'SZ','SWZ',748,'Swaziland');
INSERT INTO dropdown_country VALUES(216,'SE','SWE',752,'Sweden');
INSERT INTO dropdown_country VALUES(217,'CH','CHE',756,'Switzerland');
INSERT INTO dropdown_country VALUES(218,'SY','SYR',760,'Syrian Arab Republic');
INSERT INTO dropdown_country VALUES(219,'TW','TWN',158,'Taiwan, Province of China');
INSERT INTO dropdown_country VALUES(220,'TJ','TJK',762,'Tajikistan');
INSERT INTO dropdown_country VALUES(221,'TZ','TZA',834,'Tanzania, United Republic of');
INSERT INTO dropdown_country VALUES(222,'TH','THA',764,'Thailand');
INSERT INTO dropdown_country VALUES(223,'TL','TLS',626,'Timor-Leste');
INSERT INTO dropdown_country VALUES(224,'TG','TGO',768,'Togo');
INSERT INTO dropdown_country VALUES(225,'TK','TKL',772,'Tokelau');
INSERT INTO dropdown_country VALUES(226,'TO','TON',776,'Tonga');
INSERT INTO dropdown_country VALUES(227,'TT','TTO',780,'Trinidad and Tobago');
INSERT INTO dropdown_country VALUES(228,'TN','TUN',788,'Tunisia');
INSERT INTO dropdown_country VALUES(229,'TR','TUR',792,'Turkey');
INSERT INTO dropdown_country VALUES(230,'TM','TKM',795,'Turkmenistan');
INSERT INTO dropdown_country VALUES(231,'TC','TCA',796,'Turks and Caicos Islands');
INSERT INTO dropdown_country VALUES(232,'TV','TUV',798,'Tuvalu');
INSERT INTO dropdown_country VALUES(233,'UG','UGA',800,'Uganda');
INSERT INTO dropdown_country VALUES(234,'UA','UKR',804,'Ukraine');
INSERT INTO dropdown_country VALUES(235,'AE','ARE',784,'United Arab Emirates');
INSERT INTO dropdown_country VALUES(236,'GB','GBR',826,'United Kingdom of Great Britain and Northern Ireland');
INSERT INTO dropdown_country VALUES(237,'US','USA',840,'United States of America');
INSERT INTO dropdown_country VALUES(238,'UM','UMI',581,'United States Minor Outlying Islands');
INSERT INTO dropdown_country VALUES(239,'UY','URY',858,'Uruguay');
INSERT INTO dropdown_country VALUES(240,'UZ','UZB',860,'Uzbekistan');
INSERT INTO dropdown_country VALUES(241,'VU','VUT',548,'Vanuatu');
INSERT INTO dropdown_country VALUES(242,'VE','VEN',862,'Venezuela (Bolivarian Republic of)');
INSERT INTO dropdown_country VALUES(243,'VN','VNM',704,'Viet Nam');
INSERT INTO dropdown_country VALUES(244,'VG','VGB',92,'Virgin Islands (British)');
INSERT INTO dropdown_country VALUES(245,'VI','VIR',850,'Virgin Islands (U.S.)');
INSERT INTO dropdown_country VALUES(246,'WF','WLF',876,'Wallis and Futuna');
INSERT INTO dropdown_country VALUES(247,'EH','ESH',732,'Western Sahara');
INSERT INTO dropdown_country VALUES(248,'YE','YEM',887,'Yemen');
INSERT INTO dropdown_country VALUES(249,'ZM','ZMB',894,'Zambia');
INSERT INTO dropdown_country VALUES(250,'ZW','ZWE',716,'Zimbabwe');
INSERT INTO dropdown_country VALUES(251,'AN','ANT',530,'Netherlands Antilles');
--Member type
INSERT INTO dropdown_member_type VALUES(1,'Corporation');
INSERT INTO dropdown_member_type VALUES(2,'Limited Liability Company');
INSERT INTO dropdown_member_type VALUES(3,'Sole proprietorship');
INSERT INTO dropdown_member_type VALUES(4,'General partnership');
INSERT INTO dropdown_member_type VALUES(5,'Limited partnership');
INSERT INTO dropdown_member_type VALUES(6,'Other');
--Certificate standard
INSERT INTO dropdown_certificate_standard VALUES(3,'ISO 18788');
INSERT INTO dropdown_certificate_standard VALUES(2,'ISO 28007');
INSERT INTO dropdown_certificate_standard VALUES(1,'PSC.1');
INSERT INTO dropdown_certificate_standard VALUES(0,'Other');
--Service type
INSERT INTO dropdown_service_type VALUES(1,'Close Protection','Land');
INSERT INTO dropdown_service_type VALUES(2,'Static Security','Land');
INSERT INTO dropdown_service_type VALUES(3,'Mobile Escorts','Land');
INSERT INTO dropdown_service_type VALUES(4,'Security Management Consultancy','Land/Remote');
INSERT INTO dropdown_service_type VALUES(5,'Training Services','Land');
INSERT INTO dropdown_service_type VALUES(6,'Intelligence','Land/Remote');
INSERT INTO dropdown_service_type VALUES(7,'Drone Operators','Land');
INSERT INTO dropdown_service_type VALUES(8,'Vessel Protection','Maritime');
INSERT INTO dropdown_service_type VALUES(9,'Stationary Offshore Protection','Maritime');
INSERT INTO dropdown_service_type VALUES(10,'Floating armories','Maritime');

View File

@ -0,0 +1,7 @@
CREATE DATABASE orbeon_mapper
WITH OWNER = postgres
ENCODING = 'UTF8'
TABLESPACE = pg_default
LC_COLLATE = 'pl_PL.UTF-8'
LC_CTYPE = 'pl_PL.UTF-8'
CONNECTION LIMIT = -1;

View File

@ -0,0 +1,67 @@
<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>
<groupId>eu.moose</groupId>
<artifactId>documents-explorer</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>documents-explorer</name>
<dependencies>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.19</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.19</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>documents-explorer</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,102 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
* Copyright 2019 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.documents.explorer;
import org.apache.log4j.Logger;
import javax.annotation.PostConstruct;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.file.Paths;
import java.text.MessageFormat;
import java.util.Properties;
/**
* Bean used for application initialization.
*/
@ApplicationScoped
@ManagedBean(eager = true, name = "applicationBean")
public class ApplicationBean {
private static final Logger logger = Logger.getLogger( ApplicationBean.class );
/**
* Path to user configuration.
*/
private static final String CUSTOM_PROPERTIES_PATH = "/opt/documents-explorer/application.properties";
/**
* The path to the directory used to store documents.
*/
private String documentsDirectory;
/**
* Reads the configuration from the configuration file.
*/
@PostConstruct
public void readProperties() {
Properties properties = new Properties( );
properties.putAll( loadDefaultProperties() );
properties.putAll( loadCustomProperties() );
final String directoryPath = properties.getProperty("documents.directory");
final File directory = Paths.get(directoryPath).toFile();
if (!directory.exists()) {
if (!directory.mkdirs()) {
logger.error( "Create directory error" );
documentsDirectory = "";
}
}
else
documentsDirectory = directoryPath;
logger.info(MessageFormat.format("Using the {0} directory for file storing.", documentsDirectory));
}
/**
* Load custom properties.
*
* @return properties.
*/
private Properties loadCustomProperties() {
try (InputStream in = new FileInputStream( CUSTOM_PROPERTIES_PATH )) {
final Properties properties = new Properties( );
properties.load( in );
return properties;
}
catch (Exception e) {
logger.error( "The application encountered an error while loading the custom properties.", e );
return new Properties( );
}
}
/**
* Load default properties.
*
* @return properties.
*/
private Properties loadDefaultProperties() {
try (InputStream in = getClass().getClassLoader().getResourceAsStream("application.properties")) {
final Properties properties = new Properties( );
properties.load( in );
return properties;
}
catch (Exception e) {
logger.error( "The application encountered an error while loading the default properties.", e );
return new Properties( );
}
}
/**
* @return Path to the directory with files.
*/
public String getDocumentsDirectory() {
return documentsDirectory;
}
}

View File

@ -0,0 +1,127 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
* Copyright 2019 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.documents.explorer.bean;
import eu.mooseinc.documents.explorer.ApplicationBean;
import org.apache.log4j.Logger;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* Bean for operations related to files.
*/
@RequestScoped
@ManagedBean(name = "FilesBean")
public class FilesBean {
private static final Logger logger = Logger.getLogger( FilesBean.class );
private final List<String> documents = new ArrayList<>();
@ManagedProperty(value="#{applicationBean}")
private ApplicationBean application;
@PostConstruct
public void init() {
try (Stream<Path> stream = Files.walk(Paths.get(application.getDocumentsDirectory()))) {
this.documents.addAll( stream
.filter(Files::isRegularFile)
.map(file -> file.getFileName().toString())
.collect(Collectors.toList())
);
}
catch (final IOException e) {
logger.error( "Read documents error", e );
}
}
/**
* Finds uploaded files on the disk.
*
* @return List of files available for download.
*/
public List<String> getDocuments() {
return documents;
}
/**
* Returns requested file.
*
* @param documentName The name of the requested file.
*/
public void downloadDocument(final String documentName) {
final FacesContext facesContext = FacesContext.getCurrentInstance();
final ExternalContext externalContext = facesContext.getExternalContext();
final Path pathFile = Paths.get(application.getDocumentsDirectory() + File.separator + documentName);
final File file = pathFile.toFile();
if (!file.exists()) {
externalContext.responseReset();
externalContext.setResponseStatus(404);
return;
}
externalContext.responseReset();
try {
externalContext.setResponseContentType(Files.probeContentType(pathFile)); // mimetype
externalContext.setResponseContentLength((int) file.length()); // length
final String attachmentName = MessageFormat.format("attachment; filename=\"{0}\"", documentName);
externalContext.setResponseHeader("Content-Disposition", attachmentName);
final OutputStream outputStream = externalContext.getResponseOutputStream();
Files.copy(pathFile, outputStream);
facesContext.responseComplete();
} catch (final IOException e) {
logger.error( "Error ", e );
}
}
/**
* Deletes the file from the disk.
*
* @param documentName The name of the file to be deleted.
*
* @throws IOException Exception thrown during redirection.
*/
public void deleteDocument(final String documentName, final HttpServletRequest request) throws IOException {
if (!request.isUserInRole("admin")) {
final ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
externalContext.responseReset();
externalContext.setResponseStatus(403);
return;
}
final File fileToDelete = Paths.get(application.getDocumentsDirectory() + File.separator + documentName).toFile();
if (fileToDelete.exists() && fileToDelete.isFile())
Files.delete( fileToDelete.toPath() );
FacesContext.getCurrentInstance().getExternalContext().redirect("index.jsp");
}
public void setApplication( ApplicationBean application ) {
this.application = application;
}
}

View File

@ -0,0 +1,70 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
* Copyright 2019 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.documents.explorer.bean;
import eu.mooseinc.documents.explorer.ApplicationBean;
import org.apache.log4j.Logger;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.Part;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
/**
* Bean for file upload.
*/
@ManagedBean(name = "UploadFileBean")
public class UploadDocumentBean {
private static final Logger logger = Logger.getLogger( UploadDocumentBean.class );
/**
* The part of the form containing the file.
*/
private Part document;
@ManagedProperty(value="#{applicationBean}")
private ApplicationBean application;
/**
* Saves the sent file.
*/
public void save(final HttpServletRequest request) throws IOException {
if (!request.isUserInRole("admin")) {
final ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
externalContext.responseReset();
externalContext.setResponseStatus(403);
return;
}
try (final InputStream input = document.getInputStream()) {
Files.copy(input, new File(application.getDocumentsDirectory(), document.getSubmittedFileName()).toPath());
}
catch (final IOException e) {
logger.error( "Error", e );
}
FacesContext.getCurrentInstance().getExternalContext().redirect("index.jsp");
}
public Part getDocument() {
return document;
}
public void setDocument(final Part document) {
this.document = document;
}
public void setApplication( ApplicationBean application ) {
this.application = application;
}
}

View File

@ -0,0 +1,41 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
* Copyright 2019 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.documents.explorer.bean;
import java.io.IOException;
import java.security.Principal;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
/**
* Bean for operations related to users.
*/
@SessionScoped
@ManagedBean(name = "UserBean")
public class UserBean {
/**
* Gets the username from the faces context.
*
* @return Name of the currently authenticated user.
*/
public String getUserName() {
final Principal principal = FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal();
return principal != null ? principal.getName() : "";
}
/**
* Logs out the user.
*
* @throws IOException Exception thrown during redirection.
*/
public void logout() throws IOException {
FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
FacesContext.getCurrentInstance().getExternalContext().redirect("index.jsp");
}
}

View File

@ -0,0 +1,6 @@
##################################################################################################################################
# Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
# Copyright 2019 Moose Spółka z ograniczoną odpowiedzialnością
##################################################################################################################################
documents.directory=/tmp/documents-explorer

View File

@ -0,0 +1,13 @@
##################################################################################################################################
# Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
# Copyright 2019 Moose Spółka z ograniczoną odpowiedzialnością
##################################################################################################################################
# Root logger option
log4j.rootLogger=DEBUG, stdout
# Redirect log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} - %m%n

View File

@ -0,0 +1,70 @@
<?xml version = "1.0" encoding = "UTF-8"?>
<web-app version="4.0" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
id="IDoCa">
<display-name>IDoCa</display-name>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
<security-role>
<role-name>user</role-name>
</security-role>
<security-role>
<role-name>admin</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>App requires authentication</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
<role-name>user</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Allowed resources</web-resource-name>
<url-pattern>/javax.faces.resource/*</url-pattern>
</web-resource-collection>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>file</realm-name>
<form-login-config>
<form-login-page>/login.xhtml</form-login-page>
<form-error-page>/login.xhtml?failed=true</form-error-page>
</form-login-config>
</login-config>
</web-app>

View File

@ -0,0 +1,110 @@
<!DOCTYPE html>
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
~
~ Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:f="http://xmlns.jcp.org/jsf/core"
lang="pl">
<h:head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-COMPATIBLE" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>List of documents</title>
<h:outputStylesheet library="css" name="bootstrap.min.css"/>
<h:outputStylesheet library="css" name="style.css"/>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</h:head>
<h:body class="bg-light">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<span class="navbar-brand mr-auto">
<h:graphicImage library="img" name="icon.png" alt="logo" styleClass="logo mr-2"/>
List of Documents
</span>
<ul class="navbar-nav flex-row ml-md-auto d-md-flex">
<c:if test="#{UserBean.getUserName().length() > 0}">
<li class="nav-item">
<span class="navbar-text mr-2">
Hello, <h:outputText value="#{UserBean.getUserName()}"/>
</span>
</li>
</c:if>
<li class="nav-item">
<span>
<h:form>
<h:commandLink value="Logout" styleClass="nav-link btn btn-sm btn-info text-white"
action="#{UserBean.logout}"/>
</h:form>
</span>
</li>
</ul>
</nav>
<div class="container">
<c:if test="#{request.isUserInRole('admin')}">
<div class="row">
<div class="col mt-3 mb-3">
<h:form enctype="multipart/form-data" id="uploadForm">
<a type="button" class="upload-button"
onclick="document.getElementById('uploadForm:uploadControl').click();">
<h:graphicImage library="img" name="file-upload.svg" styleClass="top-icon"/>
</a>
<h:inputFile value="#{UploadFileBean.document}" id="uploadControl" style="display: none;">
<f:ajax listener="#{UploadFileBean.save(request)}"/>
</h:inputFile>
</h:form>
</div>
</div>
</c:if>
<div class="row">
<div class="col mt-3">
<table class="table table-striped">
<thead>
<tr>
<th scope="col" style="width: 10%">No.</th>
<th scope="col" style="width: 80%">Name</th>
<th scope="col" style="width: 10%">Options</th>
</tr>
</thead>
<tbody>
<c:if test="#{FilesBean.documents.size() eq 0}">
<tr>
<td colspan="3">No files</td>
</tr>
</c:if>
<ui:repeat value="#{FilesBean.documents}" var="documentName" varStatus="status">
<tr>
<th scope="row"><h:outputText value="#{status.index + 1}"/></th>
<td><h:outputText value="#{documentName}"/></td>
<td>
<h:form>
<h:commandLink action="#{FilesBean.downloadDocument(documentName)}">
<h:graphicImage library="img" name="file-download.svg" styleClass="table-icon mr-2"/>
</h:commandLink>
<c:if test="#{request.isUserInRole('admin')}">
<h:commandLink action="#{FilesBean.deleteDocument(documentName, request)}">
<h:graphicImage library="img" name="trash-alt.svg" styleClass="table-icon"/>
</h:commandLink>
</c:if>
</h:form>
</td>
</tr>
</ui:repeat>
</tbody>
</table>
</div>
</div>
</div>
<h:outputScript library="js" name="jquery.slim.min.js"/>
<h:outputScript library="js" name="popper.min.js"/>
<h:outputScript library="js" name="bootstrap.min.js"/>
</h:body>
</html>

View File

@ -0,0 +1,70 @@
<!DOCTYPE html>
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
~
~ Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:c="http://java.sun.com/jsp/jstl/core"
lang="pl">
<h:head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-COMPATIBLE" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>Login form</title>
<h:outputStylesheet library="css" name="bootstrap.min.css"/>
<h:outputStylesheet library="css" name="style.css"/>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</h:head>
<h:body class="bg-light">
<div class="container">
<div class="row">
<div class="col-lg-4 offset-lg-4">
<div class="text-center mb-4 mt-4">
<h:graphicImage library="img" name="icoca.png" align="middle" alt="ICoCa logo"
style="width:246px;height:100px;"/>
</div>
<div class="col-10 offset-1 bg-white login-box rounded">
<h2 class="mt-3 mb-3">Login</h2>
<c:if test="#{param['failed']}">
<div class="alert alert-danger" role="alert">
Incorrect username or password!
</div>
</c:if>
<form method="post" action="j_security_check">
<!--Username-->
<div class="form-group" id="username-group">
<input id="username" class="form-control" maxlength="120" tabindex="1" name="j_username"
placeholder="Username" data-error="Field username is required" required="required"/>
</div>
<!--Password-->
<div class="form-group" id="password-group">
<input id="password" class="form-control" maxlength="120" tabindex="2" name="j_password"
placeholder="Password" data-error="Field password is required" required="required"
type="password"/>
</div>
<!--Send button-->
<div class="form-group">
<div class="header">
<button name="send" class="btn btn-primary" tabindex="3">Sign in</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<h:outputScript library="js" name="jquery.slim.min.js"/>
<h:outputScript library="js" name="popper.min.js"/>
<h:outputScript library="js" name="bootstrap.min.js"/>
</h:body>
</html>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,24 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
* Copyright 2019 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
.login-box {
border: 1px solid gray;
}
.logo {
height: 1.75rem;
}
.table-icon {
height: 1.5rem;
}
.top-icon {
height: 2.5rem;
}
.upload-button {
-webkit-appearance: initial;
}

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path d="M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm76.45 211.36l-96.42 95.7c-6.65 6.61-17.39 6.61-24.04 0l-96.42-95.7C73.42 337.29 80.54 320 94.82 320H160v-80c0-8.84 7.16-16 16-16h32c8.84 0 16 7.16 16 16v80h65.18c14.28 0 21.4 17.29 11.27 27.36zM377 105L279.1 7c-4.5-4.5-10.6-7-17-7H256v128h128v-6.1c0-6.3-2.5-12.4-7-16.9z"/></svg>

After

Width:  |  Height:  |  Size: 464 B

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path d="M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm65.18 216.01H224v80c0 8.84-7.16 16-16 16h-32c-8.84 0-16-7.16-16-16v-80H94.82c-14.28 0-21.41-17.29-11.27-27.36l96.42-95.7c6.65-6.61 17.39-6.61 24.04 0l96.42 95.7c10.15 10.07 3.03 27.36-11.25 27.36zM377 105L279.1 7c-4.5-4.5-10.6-7-17-7H256v128h128v-6.1c0-6.3-2.5-12.4-7-16.9z"/></svg>

After

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M32 464a48 48 0 0 0 48 48h288a48 48 0 0 0 48-48V128H32zm272-256a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zm-96 0a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zm-96 0a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zM432 32H312l-9.4-18.7A24 24 0 0 0 281.1 0H166.8a23.72 23.72 0 0 0-21.4 13.3L136 32H16A16 16 0 0 0 0 48v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16z"/></svg>

After

Width:  |  Height:  |  Size: 439 B

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

1
exported-forms/readme.md Normal file
View File

@ -0,0 +1 @@
Folder contains forms (form sources) exported from Form Builder

19
integration-module/.gitignore vendored Normal file
View File

@ -0,0 +1,19 @@
*.sw?
.#*
*#
*~
.classpath
.project
.settings
bin
build
target
dependency-reduced-pom.xml
*.sublime-*
/scratch
.gradle
README.html
*.iml
.idea
out

Binary file not shown.

View File

@ -0,0 +1 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip

View File

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: hycom.Application

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-ext
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_1.xsd"
version="1.1">
<reload-interval value="3"/>
<enable-directory-browsing value="false"/>
<enable-file-serving value="true"/>
<enable-reloading value="true"/>
<enable-serving-servlets-by-class-name value="false" />
</web-ext>

View File

@ -0,0 +1,32 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.3.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'integration-module'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('com.jayway.jsonpath:json-path')
}

Binary file not shown.

View File

@ -0,0 +1,6 @@
#Mon Aug 29 13:08:10 CDT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip

160
integration-module/gradlew vendored Normal file
View File

@ -0,0 +1,160 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

90
integration-module/gradlew.bat vendored Normal file
View File

@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -0,0 +1,9 @@
---
applications:
- name: integration-module
memory: 256M
instances: 1
host: rest-service
domain: guides.spring.io
path: build/libs/integration-module-0.1.0.jar

233
integration-module/mvnw vendored Normal file
View File

@ -0,0 +1,233 @@
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven2 Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
#
# Look for the Apple JDKs first to preserve the existing behaviour, and then look
# for the new JDKs provided by Oracle.
#
if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
#
# Apple JDKs
#
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
fi
if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
#
# Apple JDKs
#
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
fi
if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
#
# Oracle JDKs
#
export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
fi
if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
#
# Apple JDKs
#
export JAVA_HOME=`/usr/libexec/java_home`
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Migwn, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
# TODO classpath?
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`which java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
fi
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
local basedir=$(pwd)
local wdir=$(pwd)
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
wdir=$(cd "$wdir/.."; pwd)
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} "$@"

145
integration-module/mvnw.cmd vendored Normal file
View File

@ -0,0 +1,145 @@
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven2 Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
set MAVEN_CMD_LINE_ARGS=%*
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar""
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%

View File

@ -0,0 +1,84 @@
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework</groupId>
<artifactId>integration-module
</artifactId>
<version>1.2.0</version>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4-1206-jdbc42</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.3.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0</version>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
<start-class>hycom.Application</start-class>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>

View File

@ -0,0 +1,25 @@
package hycom;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
@SpringBootApplication
@Configuration
@PropertySource("file:///opt/orbeon/integration.properties")
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public HttpMessageConverters customConverters() {
ByteArrayHttpMessageConverter arrayHttpMessageConverter = new ByteArrayHttpMessageConverter();
return new HttpMessageConverters(arrayHttpMessageConverter);
}
}

View File

@ -0,0 +1,155 @@
package hycom;
import hycom.model.Form;
import hycom.model.FormsResoult;
import hycom.model.UsersResoult;
import hycom.service.DatabaseService;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class FormsController {
@Autowired
DatabaseService databaseService;
public final String USER = "username=c2VydmljZVVzZXI=";
public final String PASSWORD = "password=UTJyVDg5JHE=";
@RequestMapping(value = "/rest/form/{id}", method = RequestMethod.GET, headers = {USER, PASSWORD})
public @ResponseBody
Form getForm(@PathVariable("id") int formId) {
return databaseService.getForm(formId);
}
@RequestMapping(value = "/rest/forms", method = RequestMethod.GET, headers = {USER, PASSWORD})
public @ResponseBody
List<Form> getForms() {
return databaseService.getForms();
}
@RequestMapping(value = "/rest/forms/{offset}/{limit}/{fromDate}/{toDate}/{formName}/{category}/{pillar}/{name}", method = RequestMethod.GET, headers = {USER, PASSWORD})
public @ResponseBody
FormsResoult getForms(@PathVariable("offset") int offset, @PathVariable("limit") int limit,
@PathVariable("fromDate") String fromDate, @PathVariable("toDate") String toDate,
@PathVariable("formName") String formName, @PathVariable("category") String category,
@PathVariable("pillar") String pillar, @PathVariable("name") String name) {
FormsResoult formsResoult = new FormsResoult();
formsResoult.setForms(
databaseService.getFormsUsingPagination(offset, limit, fromDate, toDate, formName, category, pillar, name));
formsResoult.setCount(databaseService.getFormsCount(fromDate, toDate, formName, category, pillar, name));
return formsResoult;
}
@RequestMapping(value = "/rest/users", method = RequestMethod.GET, headers = {USER, PASSWORD})
@ResponseBody
private UsersResoult getUsers() {
UsersResoult usersResoult = new UsersResoult();
usersResoult.setUsers(databaseService.getUsersContainsAttachments());
usersResoult.setCount(Long.valueOf(usersResoult.getUsers().size()));
return usersResoult;
}
@RequestMapping(value = "/rest/attachments/{userName:.+}", method = RequestMethod.GET, headers = {USER, PASSWORD})
public @ResponseBody
ResponseEntity<Resource> getAttachments(@PathVariable("userName") String userName) {
try {
File file = new File(databaseService.getAttachments(userName));
Path path = Paths.get(file.getAbsolutePath());
ByteArrayResource resource = new ByteArrayResource(Files.readAllBytes(path));
HttpHeaders headers = new HttpHeaders();
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
headers.add("Pragma", "no-cache");
headers.add("Expires", "0");
headers.add("Content-Disposition", "attachment, filename=\"" + userName + "\".zip");
return ResponseEntity.ok().headers(headers).contentLength(file.length())
.contentType(MediaType.parseMediaType("application/octet-stream")).body(resource);
}
catch (IOException e) {
return (ResponseEntity<Resource>) ResponseEntity.notFound();
}
}
@RequestMapping(value = "/rest/attachments/delete/{userName:.+}", method = RequestMethod.GET, headers = {USER, PASSWORD})
public @ResponseBody
ResponseEntity<Boolean> removeAttachments(@PathVariable("userName") String userName) {
Boolean success = databaseService.removeAttachments(userName);
if (success) {
return ResponseEntity.ok().body(Boolean.TRUE);
}
else {
return ResponseEntity.noContent().build();
}
}
@RequestMapping(value = "/rest/form/submit", method = RequestMethod.POST, headers = {USER, PASSWORD})
public @ResponseBody
Form submitForm(@RequestBody Form form) {
return form;
}
@RequestMapping(value = "/rest/form/submit/{id}", method = RequestMethod.PUT)
public @ResponseBody
String submitFormId(@PathVariable("id") String id) {
databaseService.submitForm(id);
return id;
}
@RequestMapping(value = "/rest/attachment/remove/{id}", method = RequestMethod.GET, headers = {USER, PASSWORD})
public @ResponseBody
String removeAttachment(@PathVariable("id") int attachmentId) {
return null;
}
@CrossOrigin(origins = "http://localhost:8080")
@RequestMapping(value = "/rest/form/issubmitted/{id}", method = RequestMethod.GET)
public @ResponseBody
ResponseEntity<Boolean> isFormSubmitted(@PathVariable("id") String id) {
Boolean success = databaseService.isFormSubmitted(id);
if (success) {
return ResponseEntity.ok().body(Boolean.TRUE);
}
else {
return ResponseEntity.ok().body(Boolean.FALSE);
}
}
@CrossOrigin(origins = "http://localhost:8080")
@RequestMapping(value = "/rest/form/hasremovedattachments/{id}", method = RequestMethod.GET)
public @ResponseBody
ResponseEntity<Boolean> hasRemovedAttachments(@PathVariable("id") String id) {
Boolean hasRemovedAttachments = databaseService.hasRemovedAttachments(id);
if (hasRemovedAttachments) {
return ResponseEntity.ok().body(Boolean.TRUE);
}
else {
return ResponseEntity.ok().body(Boolean.FALSE);
}
}
}

View File

@ -0,0 +1,67 @@
package hycom;
import hycom.dao.MapperPublishDao;
import hycom.dao.MapperSubmitDao;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.xml.sax.SAXException;
/**
* Kontroler zapewniający API do obsługi przesyłanych formularzy
*/
@RestController
public class MapperController {
private final MapperPublishDao mapperPublishDao;
private final MapperSubmitDao mapperSubmitDao;
public MapperController(MapperPublishDao mapperPublishDao, MapperSubmitDao mapperSubmitDao) {
this.mapperPublishDao = mapperPublishDao;
this.mapperSubmitDao = mapperSubmitDao;
}
/**
* Przyjmuje pusty formularz.
* @param appName nazwa Aplikacji formularza
* @param formName nazwa Formy formularza
* @param formXML pusty formularz
* @return Kod odpowiedzi.
* @throws ParserConfigurationException Wyjątek wyrzucany, w przypadku próby parsowania nie odpowiedniego pliku.
* @throws IOException Wyjątek wyrzucany, w przypadku odczytywania z zamkniętego strumienia danych.
* @throws SAXException Wyjątek wyrzucany, w przypadku nieudanego budowania pliku dokumentu.
*/
@RequestMapping(value = "/rest/mapper/publish/{application-name}/{form-name}", method = RequestMethod.PUT)
public @ResponseBody ResponseEntity<Object> get(@PathVariable("application-name") String appName, @PathVariable("form-name") String formName,
@RequestBody String formXML ) throws IOException, SAXException, ParserConfigurationException {
mapperPublishDao.parseStringToXML(formXML, appName, formName);
return ResponseEntity.noContent().build();
}
/**
* Przyjmuje uzupełniony formularz.
* @param appName nazwa Aplikacji formularza
* @param formName nazwa Formy formularza
* @param formXML pusty formularz
* @param username nazwa Użytkownika wysyłającego formularz
* @return Kod odpowiedzi.
* @throws ParserConfigurationException Wyjątek wyrzucany, w przypadku próby parsowania nie odpowiedniego pliku.
* @throws IOException Wyjątek wyrzucany, w przypadku odczytywania z zamkniętego strumienia danych.
* @throws SAXException Wyjątek wyrzucany, w przypadku nieudanego budowania pliku dokumentu.
*/
@RequestMapping(value = "/rest/mapper/submit/{app}/{form}/{username}", method = RequestMethod.POST)
public ResponseEntity getMapper(@PathVariable("app") String appName, @PathVariable("form") String formName,
@PathVariable("username") String username, @RequestBody String formXML) throws IOException, SAXException, ParserConfigurationException {
mapperSubmitDao.parseXML(formXML, appName, formName, username);
return ResponseEntity.noContent().build();
}
}

View File

@ -0,0 +1,14 @@
package hycom;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
/**
* Initializer class for SpringBoot
*/
public class WebInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
}

View File

@ -0,0 +1,27 @@
package hycom.dao;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.sql.DataSource;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
/**
* Abstract clas for all DAO objects
*/
@Component
public abstract class BaseDao {
@Resource
protected DataSource dataSource;
protected JdbcTemplate jdbcTemplate;
@PostConstruct
private void init() {
jdbcTemplate = new JdbcTemplate(dataSource);
System.out.println(jdbcTemplate);
}
}

View File

@ -0,0 +1,27 @@
package hycom.dao;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
/**
* Klasa obsługująca połączenie z bazą danych Mapper'a.
*/
@Component
public class BaseMapperDao {
protected ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath*:context.xml");
protected DriverManagerDataSource driverManagerDataSource = (DriverManagerDataSource) applicationContext.getBean("mapperDataSource");
protected JdbcTemplate jdbcTemplate;
@PostConstruct
public void init() {
jdbcTemplate = new JdbcTemplate(driverManagerDataSource);
}
}

View File

@ -0,0 +1,446 @@
package hycom.dao;
import hycom.exceptions.DbException;
import hycom.model.Attachment;
import hycom.model.Document;
import hycom.model.Form;
import hycom.model.User;
import hycom.utils.AppUtils;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.LinkedList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.tomcat.util.http.fileupload.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
/**
* DAO for populated forms
*/
@Component
@RequestMapping("/logger")
public class FormDao extends BaseDao {
private static final Logger logger = LoggerFactory.getLogger(FormDao.class);
@Value("${orbeon.address}")
private String hostAddress;
@Value("${form.name.input}")
private String formName;
@Value("${form.category.select}")
private String formCategory;
@Value("${form.pillar.select}")
private String formPillar;
@Value("${form.directory.temp}")
private String tmpDir;
byte[] buffer = new byte[1024];
public List<Form> getForms(Integer offset, Integer limit, String fromDate, String toDate, String formNameSearch,
String category, String pillar, String name) throws DbException {
StringBuilder sqlBuilder = new StringBuilder();
sqlBuilder
.append("SELECT ofd.document_id, s.send_date, ofd.form_version, ofd.id, ofd.app, ofd.form, ofda.count, name.val AS name, category.val AS category, pillar.val AS pillar \n" +
"FROM orbeon_form_data ofd\n" + "INNER JOIN submitted_forms s ON ofd.id = s.form_id \n" +
"LEFT JOIN (\n" + "SELECT document_id, COUNT(*) AS count FROM orbeon_form_data_attach \n" +
"GROUP BY document_id) ofda ON ofd.document_id = ofda.document_id\n" +
"LEFT JOIN (SELECT data_id, val FROM orbeon_i_control_text WHERE control LIKE '%" + formName +
"%') name ON ofd.id=name.data_id\n" +
"LEFT JOIN (SELECT data_id, val FROM orbeon_i_control_text WHERE control LIKE '%" + formCategory +
"%') category ON ofd.id=category.data_id\n" +
"LEFT JOIN (SELECT data_id, val FROM orbeon_i_control_text WHERE control LIKE '%" + formPillar +
"%') pillar ON ofd.id=pillar.data_id WHERE (1=1)");
if (!StringUtils.isEmpty(fromDate) && !fromDate.equals("*")) {
sqlBuilder.append(" AND s.send_date >= '").append(fromDate).append("'");
}
if (!StringUtils.isEmpty(toDate) && !toDate.equals("*")) {
sqlBuilder.append(" AND s.send_date <= '").append(toDate).append("'");
}
if (!StringUtils.isEmpty(formNameSearch) && !formNameSearch.equals("*")) {
sqlBuilder.append(" AND ofd.form LIKE '%").append(formNameSearch).append("%'");
}
if (!StringUtils.isEmpty(category) && !category.equals("*")) {
sqlBuilder.append(" AND category.val LIKE '%").append(category).append("%'");
}
if (!StringUtils.isEmpty(name) && !name.equals("*")) {
sqlBuilder.append(" AND name.val LIKE '%").append(name).append("%'");
}
if (!StringUtils.isEmpty(pillar) && !pillar.equals("*")) {
sqlBuilder.append(" AND pillar.val LIKE '%").append(pillar).append("%'");
}
sqlBuilder.append(" ORDER BY send_date DESC");
if (offset != null) {
sqlBuilder.append(" OFFSET ").append(offset);
}
if (limit != null) {
sqlBuilder.append(" LIMIT ").append(limit);
}
List<Form> forms = jdbcTemplate.query(sqlBuilder.toString(), (rs, i) -> {
String appName = rs.getString("app");
String formName = rs.getString("form");
String formId = rs.getString("document_id");
Form form = new Form();
form.setFormName(formName);
form.setLink(AppUtils.generateLink(hostAddress, appName, formName, formId));
form.setAttachment(rs.getInt("count") > 0);
form.setSendDate(rs.getTimestamp("send_date"));
form.setName(rs.getString("name"));
form.setCategory(rs.getString("category"));
form.setPillar(rs.getString("pillar"));
return form;
});
return forms;
}
public Long getFormsCount(String fromDate, String toDate, String formNameSearch, String category, String pillar, String name)
throws DbException {
StringBuilder sqlBuilder = new StringBuilder();
sqlBuilder.append("SELECT count(ofd.id) \n" + "FROM orbeon_form_data ofd\n" +
"INNER JOIN submitted_forms s ON ofd.id = s.form_id \n" + "LEFT JOIN (\n" +
"SELECT document_id, COUNT(*) AS count FROM orbeon_form_data_attach \n" +
"GROUP BY document_id) ofda ON ofd.document_id = ofda.document_id\n" +
"LEFT JOIN (SELECT data_id, val FROM orbeon_i_control_text WHERE control LIKE '%" + formName +
"%') name ON ofd.id=name.data_id\n" +
"LEFT JOIN (SELECT data_id, val FROM orbeon_i_control_text WHERE control LIKE '%" + formCategory +
"%') category ON ofd.id=category.data_id\n" +
"LEFT JOIN (SELECT data_id, val FROM orbeon_i_control_text WHERE control LIKE '%" + formPillar +
"%') pillar ON ofd.id=pillar.data_id WHERE (1=1)");
if (!StringUtils.isEmpty(fromDate) && !fromDate.equals("*")) {
sqlBuilder.append(" AND s.send_date >= '").append(fromDate).append("'");
}
if (!StringUtils.isEmpty(toDate) && !toDate.equals("*")) {
sqlBuilder.append(" AND s.send_date <= '").append(toDate).append("'");
}
if (!StringUtils.isEmpty(formNameSearch) && !formNameSearch.equals("*")) {
sqlBuilder.append(" AND ofd.form LIKE '%").append(formNameSearch).append("%'");
}
if (!StringUtils.isEmpty(category) && !category.equals("*")) {
sqlBuilder.append(" AND category.val LIKE '%").append(category).append("%'");
}
if (!StringUtils.isEmpty(name) && !name.equals("*")) {
sqlBuilder.append(" AND name.val LIKE '%").append(name).append("%'");
}
if (!StringUtils.isEmpty(pillar) && !pillar.equals("*")) {
sqlBuilder.append(" AND pillar.val LIKE '%").append(pillar).append("%'");
}
Long count = jdbcTemplate.queryForObject(sqlBuilder.toString(), (rs, i) -> {
return rs.getLong("count");
});
return count;
}
public List<User> getUsersContainsAttachments() throws DbException {
String sql = "SELECT DISTINCT att.username from orbeon_form_data_attach att \n" +
"INNER JOIN orbeon_form_data ofd ON ofd.document_id = att.document_id \n" +
"INNER JOIN submitted_forms sf ON sf.form_id = ofd.id\n" + "WHERE att.username IS NOT NULL";
List<User> users = jdbcTemplate.query(sql, (rs, i) -> {
User user = new User();
user.setUserName(rs.getString("username"));
user.setMember(true);
return user;
});
return users;
}
public String getAttachments(String userName) throws DbException {
String sql = "SELECT ofd.document_id, ofd.form_version, ofd.xml, ofd.app, ofd.form from orbeon_form_data ofd\n" +
"INNER JOIN submitted_forms sf ON sf.form_id = ofd.id\n" +
"WHERE EXISTS (SELECT 1 FROM orbeon_form_data_attach att WHERE att.document_id = ofd.document_id)\n" +
"AND ofd.username = '" + userName + "';";
List<Document> documents = jdbcTemplate.query(sql, (rs, i) -> {
String documentId = rs.getString("document_id");
String xmlFile = rs.getString("xml");
String appName = rs.getString("app");
String formName = rs.getString("form");
String formVersion = rs.getString("form_version");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = null;
try {
dBuilder = dbFactory.newDocumentBuilder();
InputStream stream = new ByteArrayInputStream(xmlFile.getBytes(StandardCharsets.UTF_8));
org.w3c.dom.Document doc = dBuilder.parse(stream);
doc.getDocumentElement().normalize();
Element element = doc.getDocumentElement();
NodeList nodeList = element.getChildNodes();
Document document = new Document();
document.setDocumentId(documentId);
document.setAppName(appName);
document.setFormName(formName);
document.setVersion(Long.parseLong(formVersion));
List<Attachment> attachments = new LinkedList<>();
attachments = populateList(nodeList, attachments);
document.setAttachments(attachments);
return document;
}
catch (ParserConfigurationException | IOException | SAXException e) {
e.printStackTrace();
}
return null;
});
if (!CollectionUtils.isEmpty(documents)) {
File directory = new File(tmpDir + "/" + userName);
if (!directory.exists()) {
directory.mkdir();
}
}
for (Document document : documents) {
for (Attachment attachment : document.getAttachments()) {
String sql2 =
"SELECT file_content FROM orbeon_form_data_attach WHERE file_name = '" + attachment.getFileEncodedName() +
"' ";
jdbcTemplate.query(sql2, (rs, i) -> {
try {
InputStream inputStream = rs.getBinaryStream("file_content");
OutputStream outputStream =
new FileOutputStream(tmpDir + "/" + userName + "/" + attachment.getFileName());
int bytesRead = -1;
byte[] buffer = new byte[1024];
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
inputStream.close();
outputStream.close();
}
catch (IOException e) {
e.getMessage();
}
return null;
});
}
try {
FileOutputStream fos = new FileOutputStream(tmpDir + "/" + userName + ".zip");
ZipOutputStream zos = new ZipOutputStream(fos);
File folder = new File(tmpDir + "/" + userName);
for (File file : folder.listFiles()) {
ZipEntry ze = new ZipEntry(file.getName());
zos.putNextEntry(ze);
FileInputStream in = new FileInputStream(file.getPath());
int len;
while ((len = in.read(buffer)) > 0) {
zos.write(buffer, 0, len);
}
in.close();
zos.closeEntry();
}
zos.close();
}
catch (IOException e) {
logger.error("Cannot remove attachments for :" );
}
return tmpDir + "/" + userName + ".zip";
}
return null;
}
public void removeAttachments(String userName) throws DbException {
File folder = new File(tmpDir + "/" + userName);
File zipFile = new File(tmpDir + "/" + userName + ".zip");
try {
FileUtils.deleteDirectory(folder);
}
catch (IOException e) {
logger.error("Cannot remove temp directory for user {} : {}", userName, e.getMessage());
}
zipFile.delete();
String deleteAttachmentsSql =
"DELETE FROM orbeon_form_data_attach AS ofda USING orbeon_form_data AS ofd WHERE ofda.document_id = ofd.document_id AND EXISTS (SELECT 1 FROM submitted_forms sf WHERE sf.form_id = ofd.id) AND ofd.username = '" +
userName + "'; ";
String updateAttachmentsSql = "UPDATE submitted_forms sf SET attachments_moved = TRUE where form_id IN (\n" +
"SELECT sf.form_id FROM submitted_forms sf \n" + "inner JOIN orbeon_form_data ofd ON sf.form_id = ofd.id \n" +
"WHERE ofd.username = '" + userName + "');";
try {
int i = jdbcTemplate.update(deleteAttachmentsSql);
int j = jdbcTemplate.update(updateAttachmentsSql);
logger.info("There are {} deleted attachments for user: {}", i, userName);
}
catch (Exception e) {
logger.error("Cannot remove attachments for user {} : {}", userName, e.getMessage());
}
}
/**
* Populete list of attachments for xml file node elements
*
* @param nodeList node list from xml file
*
* @param attachments list to populate
*
* @return populated list of attachments
*/
private List<Attachment> populateList(NodeList nodeList, List<Attachment> attachments) {
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (node.hasAttributes() && ((Element) node).hasAttribute("filename")) {
String fileName = ((Element) node).getAttribute("filename");
String mediaType = ((Element) node).getAttribute("mediatype");
String fileEncodedName = getFileEncodedName(node.getTextContent());
System.out.println(((Element) node).getAttribute("size"));
Attachment attachment = new Attachment();
attachment.setFileName(fileName);
attachment.setMediaType(mediaType);
attachment.setFileEncodedName(fileEncodedName);
attachments.add(attachment);
}
else {
if (node.getChildNodes().getLength() > 0) {
populateList(node.getChildNodes(), attachments);
}
else {
continue;
}
}
}
else {
continue;
}
}
return attachments;
}
/**
* Returns filename from xml node
*
* @param nodeContent node with file element
*
* @return filename
*/
private String getFileEncodedName(String nodeContent) {
int lastIndex = nodeContent.lastIndexOf("/");
return nodeContent.substring(lastIndex + 1);
}
public List<Form> getForms() throws DbException {
return getForms(null, null, null, null, null, null, null, null);
}
public Form getForm(int formId) throws DbException {
String sql = "SELECT app, form FROM orbeon_form_data WHERE id = " + formId;
return jdbcTemplate.query(sql, rs -> {
if (rs.next()) {
Form form = new Form();
form.setFormName(rs.getString("app"));
form.setName(rs.getString("form"));
return form;
}
return null;
});
}
public void submitForm(String id) throws DbException {
String sql = "INSERT INTO submitted_forms (form_id, send_date) VALUES ((SELECT id FROM orbeon_form_data ofd\n" +
"INNER JOIN (\n" + "SELECT app, form, document_id, MAX(last_modified_time) AS max_last_modified\n" +
"FROM orbeon_form_data o GROUP BY app, form, document_id) forms ON ofd.app = forms.app AND ofd.form = forms.form\n" +
"WHERE ofd.document_id = '" + id + "'\n" +
"AND ofd.last_modified_time = forms.max_last_modified), CURRENT_TIMESTAMP)";
jdbcTemplate.update(sql);
}
public void deleteSubmittedForm(String documentId) {
String sql = "DELETE FROM submitted_forms WHERE id IN (SELECT submitted_forms.id FROM submitted_forms INNER JOIN orbeon_form_data ON submitted_forms.form_id = orbeon_form_data.id WHERE document_id ='" + documentId + "')";
jdbcTemplate.update(sql);
}
public Boolean hasRemovedAttachments(String documentId) throws DbException {
String sql = "SELECT sf.id FROM submitted_forms sf INNER JOIN orbeon_form_data ofd ON sf.form_id = ofd.id AND sf.attachments_moved = TRUE AND ofd.document_id = '" + documentId + "';";
return jdbcTemplate.query(sql, rs -> {
if (rs.next()) {
return true;
}
return false;
});
}
public boolean isFormSubmitted(String documentId) throws DbException {
String sql = "SELECT sf.id from submitted_forms sf INNER JOIN orbeon_form_data ofd ON sf.form_id = ofd.id WHERE ofd.document_id = '" + documentId + "';";
return jdbcTemplate.query(sql, rs -> {
if (rs.next()) {
return true;
}
return false;
});
}
}

View File

@ -0,0 +1,116 @@
package hycom.dao;
import hycom.service.TableNameParser;
import hycom.service.XMLSerialize;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
import org.springframework.stereotype.Component;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
/**
* Klasa mapująca formularz na XML oraz obsługująca zapytania do bazy danych
*/
@Component
public class MapperPublishDao extends BaseMapperDao {
private StringBuilder sqlTableCreate = new StringBuilder();
/**
* Parsuje formularz z String na XML.
* @param stringXML pusty formularz przychodzący w formie String
* @param appName nazwa Aplikacji formularza
* @param formName nazwa Formy forumlarza
* @throws ParserConfigurationException Wyjątek wyrzucany, w przypadku próby parsowania nie odpowiedniego pliku.
* @throws IOException Wyjątek wyrzucany, w przypadku odczytywania z zamkniętego strumienia danych.
* @throws SAXException Wyjątek wyrzucany, w przypadku nieudanego budowania pliku dokumentu.
*/
public void parseStringToXML(String stringXML, String appName, String formName)
throws ParserConfigurationException, IOException, SAXException {
Document document = XMLSerialize.parseStringToXML(stringXML);
sqlTableCreate.setLength(0);
String tableName = TableNameParser.convertTableName(appName, formName);
if (!checkTable(tableName)) {
createTable(tableName);
createColumn(document);
} else {
updateTable(tableName, getXMLColumn(document));
}
}
private void createTable(String tableName) {
sqlTableCreate.setLength(0);
sqlTableCreate
.append("CREATE TABLE " + tableName);
}
private List<String> getXMLColumn(Document document) {
String section = null;
String control = null;
document.getDocumentElement().normalize();
NodeList nodeList = document.getElementsByTagName("control");
List<String> elementXML = new ArrayList<String>();
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
Element element = (Element) node;
if (element.getAttribute("name").contains("section"))
section = element.getAttribute("name").replace("-","_");
control = element.getAttribute("name").replace("-","_");
if (!element.getAttribute("name").contains("section"))
elementXML.add(section + "_" + control);
}
return elementXML;
}
private void createColumn(Document document) {
List<String> columnXML = getXMLColumn(document);
sqlTableCreate.append("\n( \n");
sqlTableCreate.append("ID BIGSERIAL PRIMARY KEY, \n");
sqlTableCreate.append("SEND_DATA TIMESTAMP NOT NULL, \n");
sqlTableCreate.append("LOGIN TEXT NOT NULL, \n");
Iterator iterator = columnXML.iterator();
while (iterator.hasNext()) {
sqlTableCreate.append(" " + iterator.next() + " TEXT, \n");
}
sqlTableCreate.deleteCharAt(sqlTableCreate.length() - 3);
sqlTableCreate.append(")\n");
jdbcTemplate.update(sqlTableCreate.toString());
}
private boolean checkTable(String tableName) {
StringBuilder sqlCheckTable = new StringBuilder();
sqlCheckTable
.append("SELECT COUNT(*) FROM information_schema.tables " +
"WHERE table_schema='public' AND table_name = '" + tableName + "'");
int exist = jdbcTemplate.queryForObject(sqlCheckTable.toString(), Integer.class);
if (exist > 0)
return true;
else
return false;
}
private void updateTable(String tableName, List<String> xmlColumn) {
List<String> columnList = jdbcTemplate.queryForList(
("SELECT column_name FROM information_schema.columns where table_name = '" + tableName + "'"),String.class);
xmlColumn.removeAll(columnList);
if (!xmlColumn.isEmpty()) {
StringBuilder sqlAddColumns = new StringBuilder();
sqlAddColumns.append("ALTER TABLE " + tableName + "\n");
Iterator iterator = xmlColumn.iterator();
while (iterator.hasNext()) {
sqlAddColumns.append("ADD COLUMN " + iterator.next() + " TEXT, \n");
}
sqlAddColumns.deleteCharAt(sqlAddColumns.length() - 3).append(";");
jdbcTemplate.update(sqlAddColumns.toString());
}
}
}

View File

@ -0,0 +1,218 @@
package hycom.dao;
import hycom.service.TableNameParser;
import hycom.service.XMLSerialize;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
/**
* Klasa mapująca dane na XML oraz obsługująca zapytania do bazy danych
*/
@Component
public class MapperSubmitDao extends BaseMapperDao {
/**
* Parsuje uzupełniony formularz na XML.
* @param formXML uzupełniony formularz przychodzący w formie String
* @param appName nazwa Aplikacji formularza
* @param formName nazwa Formy formularza
* @param userLogin login użytkownika wysyłającego formularz
* @throws ParserConfigurationException Wyjątek wyrzucany, w przypadku próby parsowania nie odpowiedniego pliku.
* @throws IOException Wyjątek wyrzucany, w przypadku odczytywania z zamkniętego strumienia danych.
* @throws SAXException Wyjątek wyrzucany, w przypadku nieudanego budowania pliku dokumentu.
*/
public void parseXML(String formXML, String appName, String formName, String userLogin)
throws ParserConfigurationException, IOException, SAXException {
StringBuilder stringBuilder = new StringBuilder();
new BufferedReader(new StringReader(formXML)).lines().forEach(
(line) -> {
if (StringUtils.isNotBlank(line))
stringBuilder.append(line);
});
Document document = XMLSerialize.parseStringToXML(stringBuilder.toString());
String tableName = TableNameParser.convertTableName(appName, formName);
if (checkTable(tableName))
getValueFromXML(document, tableName, userLogin);
}
private void getValueFromXML(Document document, String tablePrefix, String login) {
String section = null;
String control = null;
String grid = null;
String controlGrid = null;
document.getDocumentElement().normalize();
NodeList nodeList = document.getDocumentElement().getChildNodes();
List<String> controlData = new ArrayList<>();
List<String> controlColumns = new ArrayList<>();
List<String> gridData = new ArrayList<>();
List<String> gridColumns = new ArrayList<>();
List<String> gridTable = new ArrayList<>();
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
NodeList sectionNodeList = node.getChildNodes();
if (node.getNodeName().contains("section")) {
section = node.getNodeName().replace("-","_");
for (int j = 0; j < sectionNodeList.getLength(); j++) {
Node sectionNode = sectionNodeList.item(j);
if (sectionNode.getNodeName().contains("control")) {
control = sectionNode.getNodeName().replace("-","_");
controlColumns.add(section + "_" + control);
controlData.add(sectionNode.getTextContent());
updateColumns(tablePrefix, section + "_" + control);
} else if (sectionNode.getNodeName().contains("grid")) {
grid = sectionNode.getNodeName().replace("-","_");
if (sectionNode.getChildNodes().getLength() > 0)
for (int k = 0; k < sectionNode.getChildNodes().getLength(); k++) {
controlGrid = sectionNode.getChildNodes().item(k).getNodeName()
.replace("-", "_");
if (!controlGrid.contains("#text"))
gridColumns.add(controlGrid);
if (!controlGrid.contains("#text"))
gridData.add(sectionNode.getChildNodes().item(k).getTextContent());
if (!controlGrid.contains("#text"))
gridTable.add(tablePrefix + "_" + section + "_" + grid);
if (!checkTable(tablePrefix + "_" + section + "_" + grid))
createGridTableAndColumns(tablePrefix + "_" + section + "_"
+ grid, controlGrid, tablePrefix);
else
updateGridColumns(tablePrefix + "_" + section + "_" + grid, controlGrid);
}
}
}
}
}
if (!controlData.isEmpty()) {
insertControlDataToDatabase(tablePrefix, controlColumns, controlData, login);
if (!gridData.isEmpty())
insertGridData(gridTable, gridData, gridColumns, tablePrefix);
}
}
private void insertGridData(List<String> tablePrefix, List<String> textContent,
List<String> controlGrid, String originalTable) {
StringBuilder sqlInsertGrid = new StringBuilder();
List<String> addedData = new ArrayList<>();
String checkTable = tablePrefix.get(0);
Boolean flag = false;
if (tablePrefix.size() == textContent.size()
&& tablePrefix.size() == controlGrid.size()) {
for (int i = 0; i < tablePrefix.size(); i++) {
sqlInsertGrid.setLength(0);
if (!checkTable.equals(tablePrefix.get(i))) {
checkTable = tablePrefix.get(i);
flag = !flag;
}
if (flag.equals(false) || addedData.contains(controlGrid.get(i))) {
sqlInsertGrid.append("INSERT INTO " + checkTable + " (" + " id_" + originalTable + ", " + controlGrid.get(i) +
" ) \n" + "VALUES (" + " (SELECT id from " + originalTable + " order by id desc limit 1 ), '" +
textContent.get(i) + "' );");
flag = true;
addedData.add(controlGrid.get(i));
} else {
sqlInsertGrid
.append("UPDATE " + checkTable + " \n" + "SET " + controlGrid.get(i) + " = '" + textContent.get(i) +
"' \n WHERE id = " + "(SELECT id from " + checkTable + " ORDER BY id desc limit 1);");
}
jdbcTemplate.update(sqlInsertGrid.toString());
}
}
}
private void updateColumns(String tableName, String columnName) {
if (checkColumn(tableName, columnName))
jdbcTemplate.update("ALTER TABLE " + tableName + "\n" + "ADD COLUMN " + columnName + " TEXT;");
}
private void updateGridColumns(String tableName, String columnName) {
String column = null;
if (columnName.contains("control"))
column = columnName;
if (column !=null)
if (checkColumn(tableName, columnName))
jdbcTemplate.update("ALTER TABLE " + tableName + "\n" + "ADD COLUMN " + column + " TEXT;");
}
private void createGridTableAndColumns(String tableName, String columnName, String originalTable) {
String column = null;
if (columnName.contains("control"))
column = columnName;
if (column !=null)
jdbcTemplate.update("CREATE TABLE " + tableName + "\n ( id BIGSERIAL, " + "id_" + originalTable +
" INTEGER REFERENCES " + originalTable + "(id), \n" + column + " TEXT, \n" + "PRIMARY KEY (id, id_" +
originalTable + ") );");
}
private void insertControlDataToDatabase(String tablePrefix, List<String> controlColumns,
List<String> controlData, String login) {
Date date = new Date();
StringBuilder sqlInsert = new StringBuilder();
sqlInsert.setLength(0);
sqlInsert
.append("INSERT INTO " + tablePrefix + " (");
sqlInsert
.append("SEND_DATA, LOGIN,");
Iterator iteratorColumns = controlColumns.iterator();
while (iteratorColumns.hasNext() && controlColumns.size() == controlData.size()) {
sqlInsert
.append(" " + iteratorColumns.next() + ",");
}
sqlInsert
.deleteCharAt(sqlInsert.length() - 1);
sqlInsert
.append(" ) \n VALUES ( '" + date + "' , '" + login + "',");
for (int i = 0; i < controlData.size(); i++) {
if (controlData.get(i).contains("'"))
sqlInsert
.append(" '" + controlData.get(i).replace("'", "") + "',");
else
sqlInsert
.append(" '" + controlData.get(i) + "',");
}
sqlInsert
.deleteCharAt(sqlInsert.length() - 1);
sqlInsert
.append(" );");
jdbcTemplate.update(sqlInsert.toString());
}
private boolean checkTable(String tableName) {
String sqlCheckTable =
("SELECT COUNT(*) FROM information_schema.tables " + "WHERE table_schema='public' AND table_name = '" +
tableName + "'");
int exist = jdbcTemplate.queryForObject(sqlCheckTable, Integer.class);
if (exist > 0)
return true;
else
return false;
}
private boolean checkColumn(String tableName, String columnName) {
String sqlCheckColumns =
("SELECT COUNT(*) FROM information_schema.columns " + "WHERE table_name='" + tableName +
"' AND column_name = '" + columnName + "'");
int exist = jdbcTemplate.queryForObject(sqlCheckColumns, Integer.class);
if (exist > 0)
return false;
else
return true;
}
}

View File

@ -0,0 +1,10 @@
package hycom.exceptions;
/**
*
*/
public class DbException extends Exception {
public DbException(String s, Throwable throwable) {
super(s, throwable);
}
}

View File

@ -0,0 +1,68 @@
package hycom.model;
import java.io.Serializable;
public class Attachment implements Serializable{
private static final long serialVersionUID = -7788619177798333713L;
private int id;
private String userName;
private Object encodedFile;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getMediaType() {
return mediaType;
}
public void setMediaType(String mediaType) {
this.mediaType = mediaType;
}
public String getFileEncodedName() {
return fileEncodedName;
}
public void setFileEncodedName(String fileEncodedName) {
this.fileEncodedName = fileEncodedName;
}
private String fileName;
private String mediaType;
private String fileEncodedName;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Object getEncodedFile() {
return encodedFile;
}
public void setEncodedFile(Object encodedFile) {
this.encodedFile = encodedFile;
}
}

View File

@ -0,0 +1,59 @@
package hycom.model;
import java.io.Serializable;
import java.util.List;
public class Document implements Serializable{
private static final long serialVersionUID = -7788619177798333715L;
private String documentId;
private String appName;
private String formName;
public List<Attachment> getAttachments() {
return attachments;
}
public void setAttachments(List<Attachment> attachments) {
this.attachments = attachments;
}
private List<Attachment> attachments;
public long getVersion() {
return version;
}
public void setVersion(long version) {
this.version = version;
}
private long version;
public String getDocumentId() {
return documentId;
}
public void setDocumentId(String documentId) {
this.documentId = documentId;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getFormName() {
return formName;
}
public void setFormName(String formName) {
this.formName = formName;
}
}

View File

@ -0,0 +1,80 @@
package hycom.model;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.DateSerializer;
import java.io.Serializable;
import java.util.Date;
/**
* Form model
*/
public class Form implements Serializable{
private static final long serialVersionUID = -7788619177798333712L;
private String formName;
private String link;
private Date sendDate;
private boolean attachment;
private String category;
private String name;
private String pillar;
public String getFormName() {
return formName;
}
public void setFormName(String formName) {
this.formName = formName;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
public boolean getAttachment() {
return attachment;
}
public void setAttachment(boolean attachment) {
this.attachment = attachment;
}
@JsonSerialize(using=DateSerializer.class)
public Date getSendDate() {
return sendDate;
}
public void setSendDate(Date sendDate) {
this.sendDate = sendDate;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPillar() {
return pillar;
}
public void setPillar(String pillar) {
this.pillar = pillar;
}
}

View File

@ -0,0 +1,32 @@
package hycom.model;
import java.io.Serializable;
import java.util.List;
/**
* Forms response
*/
public class FormsResoult implements Serializable{
private static final long serialVersionUID = -7788619177798333715L;
public List<Form> getForms() {
return forms;
}
public void setForms(List<Form> forms) {
this.forms = forms;
}
public Long getCount() {
return count;
}
public void setCount(Long count) {
this.count = count;
}
private List<Form> forms;
private Long count;
}

View File

@ -0,0 +1,33 @@
package hycom.model;
import java.io.Serializable;
/**
* User from Orbeon
*/
public class User implements Serializable{
private static final long serialVersionUID = -7788619177798333714L;
private String userName;
private boolean isMember;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public boolean isMember() {
return isMember;
}
public void setMember(boolean isMember) {
this.isMember = isMember;
}
}

View File

@ -0,0 +1,32 @@
package hycom.model;
import java.io.Serializable;
import java.util.List;
/**
* Forms response
*/
public class UsersResoult implements Serializable{
private static final long serialVersionUID = -7788619177798333716L;
public List<User> getUsers() {
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
public Long getCount() {
return count;
}
public void setCount(Long count) {
this.count = count;
}
private List<User> users;
private Long count;
}

View File

@ -0,0 +1,133 @@
package hycom.service;
import hycom.dao.FormDao;
import hycom.exceptions.DbException;
import hycom.model.Form;
import hycom.model.User;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Database service
*/
@Service
@Transactional
@RequestMapping("/logger")
public class DatabaseService {
private static final Logger logger = LoggerFactory.getLogger(DatabaseService.class);
@Autowired
private FormDao formDao;
public List<Form> getForms() {
try {
return formDao.getForms();
}
catch (DbException e) {
logger.error("Error in method getForms(): " + e.getMessage());
}
return null;
}
public List<Form> getFormsUsingPagination(int offset, int limit, String fromDate, String toDate, String formNameSearch,
String category, String pillar, String name) {
try {
return formDao.getForms(offset, limit, fromDate, toDate, formNameSearch, category, pillar, name);
}
catch (DbException e) {
logger.error("Error in method getFormsUsingPagination(...): " + e.getMessage());
}
return null;
}
public Long getFormsCount(String fromDate, String toDate, String formNameSearch,
String category, String pillar, String name) {
try {
return formDao.getFormsCount(fromDate, toDate, formNameSearch, category, pillar, name);
}
catch (DbException e) {
logger.error("Error in getFormsCount(...): " + e.getMessage());
}
return null;
}
public List<User> getUsersContainsAttachments() {
try {
return formDao.getUsersContainsAttachments();
}
catch (DbException e) {
logger.error("Error in getUsersContainsAttachments(): " + e.getMessage());
}
return null;
}
public String getAttachments(String userName) {
try {
return formDao.getAttachments(userName);
}
catch (DbException e) {
logger.error("Error in getAttachments(...): " + e.getMessage());
}
return null;
}
public Boolean removeAttachments(String userName) {
try {
formDao.removeAttachments(userName);
return true;
}
catch (DbException e) {
logger.error("Error in removeAttachments(...): " + e.getMessage());
}
return false;
}
public Form getForm(int formId) {
try {
return formDao.getForm(formId);
}
catch (DbException e) {
logger.error("Error in getForm(...): " + e.getMessage());
}
return null;
}
public void submitForm(String id) {
try {
boolean submitted = formDao.isFormSubmitted(id);
if (submitted)
formDao.deleteSubmittedForm(id);
formDao.submitForm(id);
}
catch (DbException e) {
logger.error("Error in submitForm(...): " + e.getMessage());
}
}
public Boolean hasRemovedAttachments(String id) {
try {
return formDao.hasRemovedAttachments(id);
}
catch (DbException e) {
logger.error("Error in hasRemovedAttachments(...): " + e.getMessage());
return null;
}
}
public Boolean isFormSubmitted(String id) {
try {
return formDao.isFormSubmitted(id);
}
catch (DbException e) {
logger.error("isFormSubmitted(...): " + e.getMessage());
return null;
}
}
}

View File

@ -0,0 +1,74 @@
package hycom.service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
/**
* Serwis do parsowania nazwy tabeli.
*/
@Service
public class TableNameParser {
private static int maxColumnName = 30;
private static String tablePrefix = "ORBEON_F_";
/**
* Konwerter nazwy tabeli.
* @param appName nazwa Aplikacji formularza
* @param formName nazwa Formy formularza
* @return skrócona nazwa tabeli
*/
public static String convertTableName(String appName, String formName) {
String appXML = xmlToSQLId(appName);
String formXML = xmlToSQLId(formName);
String viewName = tablePrefix + joinParts(Arrays.asList(appXML,formXML), maxColumnName - tablePrefix.length());
return viewName.toLowerCase();
}
private static String joinParts(List<String> parts, int max) {
return String.join("_", fitParts(parts, max));
}
private static String xmlToSQLId(String id){
String result = id.replaceAll("-", "_")
.toUpperCase() // to uppercase
.replaceAll("[^A-Z0-9_]", "");
result = StringUtils.stripStart(result, "_");
result = StringUtils.stripEnd(result, "_");
return result;
}
private static List<String> fitParts(List<String> parts, int max){
int usable = max - parts.size() + 1;
return shaveParts(parts, usable);
}
private static List<String> shaveParts(List<String> parts, int usable){
List<Integer> partsLength = parts.stream().map(String::length).collect(Collectors.toList());
int totalLength = parts.stream().mapToInt(String::length).sum();
if(totalLength <= usable) {
return parts;
} else {
Integer maxPartLength = partsLength.stream().max(Comparator.naturalOrder()).orElseThrow(RuntimeException::new);
int maxPartIndex = partsLength.indexOf(maxPartLength);
String newPart = StringUtils.stripEnd(removeLastChar(parts.get(maxPartIndex)), "_");
List<String> newParts = new ArrayList<>(parts);
newParts.set(maxPartIndex, newPart);
return shaveParts(newParts, usable);
}
}
private static String removeLastChar(String str) {
return str.substring(0, str.length() - 1);
}
}

View File

@ -0,0 +1,47 @@
package hycom.service;
import com.sun.org.apache.xml.internal.serialize.OutputFormat;
import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.springframework.stereotype.Service;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
* Serwis do parsowania formularza (String -> XML)
*/
@Service
public class XMLSerialize {
/**
* Konwerter XML
* @param stringXML Formularz aplikacji
* @return dokument XML
* @throws ParserConfigurationException Wyjątek wyrzucany, w przypadku próby parsowania nie odpowiedniego pliku.
* @throws IOException Wyjątek wyrzucany, w przypadku odczytywania z zamkniętego strumienia danych.
* @throws SAXException Wyjątek wyrzucany, w przypadku nieudanego budowania pliku dokumentu.
*/
public static Document parseStringToXML(String stringXML) throws ParserConfigurationException, IOException, SAXException {
Document document;
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
InputSource inputSource = new InputSource(new StringReader(stringXML));
document = documentBuilder.parse(inputSource);
StringWriter out = new StringWriter();
OutputFormat format = new OutputFormat(document);
format.setIndenting(true);
XMLSerializer serializer = new XMLSerializer(out, format);
serializer.serialize(document);
return document;
}
}

View File

@ -0,0 +1,33 @@
package hycom.utils;
import java.net.URL;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
/**
* Narzędzia wykorzystywane w aplikacji
*/
public class AppUtils {
public static String generateLink(String hostAddress, String appName, String formName, String formId) {
StringBuilder linkBuilder = new StringBuilder();
linkBuilder.append(hostAddress);
if (!hostAddress.endsWith("/")) {
linkBuilder.append("/");
}
linkBuilder.append("fr/");
linkBuilder.append(appName.concat("/"));
linkBuilder.append(formName.concat("/"));
linkBuilder.append("view/");
linkBuilder.append(formId);
return linkBuilder.toString();
}
public static Document loadDocumentUrl(String url) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
return factory.newDocumentBuilder().parse(new URL(url).openStream());
}
}

View File

@ -0,0 +1,14 @@
#spring.datasource.url= jdbc:postgresql://localhost:5432/orbeon
#spring.datasource.username=postgres
#spring.datasource.password=postgres
logging.level.org.springframework.web=WARN
logging.level.org.hibernate=ERROR
logging.file=/opt/icoca/integration.log
spring.jpa.hibernate.ddl-auto=validate
#orbeon.address=http://localhost:8080/orbeonpe/
form.name.input=form-name-input
form.category.select=form-category-select
form.pillar.select=form-pillar-select
form.directory.temp = /opt/orbeon/temp

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<!--Baza danych przechowująca aktualnie wykonywane transakcje.-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbc:postgresql://localhost:5432/orbeon"/>
<property name="username" value="postgres"/>
<property name="password" value="postgres"/>
<property name="maxWait" value="10000"/>
</bean>
<!--Baza danych mappera -->
<bean name="mapperDataSource" id="mapperDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbc:postgresql://localhost:5432/orbeon_mapper"/>
<property name="username" value="postgres"/>
<property name="password" value="postgres"/>
</bean>
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven transaction-manager="txManager" />
<context:annotation-config/>
</beans>

View File

@ -0,0 +1,7 @@
CREATE TABLE submitted_forms
(
id serial NOT NULL,
form_id NUMERIC NOT NULL,
send_date timestamp without time zone NOT NULL,
attachments_moved boolean NOT NULL DEFAULT FALSE
);

View File

@ -0,0 +1,55 @@
/*
* Copyright 2016 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 hycom;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
// import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
public class FormsControllerTests {
@Autowired
private MockMvc mockMvc;
@Test
public void noTest() {
System.out.println("test");
}
@Test
public void getFormsTest() {
try {
this.mockMvc.perform(get("/rest/forms")).andDo(print()).andExpect(status().isOk());
// .andExpect(jsonPath("$.formName").value("orbeon"));
}
catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
</web-app>

58
registration/pom.xml Normal file
View File

@ -0,0 +1,58 @@
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>eu.mooseinc</groupId>
<artifactId>registration-parent</artifactId>
<packaging>pom</packaging>
<version>1.3.0</version>
<modules>
<module>registration-form</module>
<module>registration-doc</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>4.3.5.RELEASE</spring.version>
<thymeleaf.version>3.0.3.RELEASE</thymeleaf.version>
<jackson.version>2.8.6</jackson.version>
<slf4j.version>1.7.22</slf4j.version>
<java.mail.version>1.4.7</java.mail.version>
<apache.commons.version>3.0</apache.commons.version>
<commons-fileupload.version>1.3.2</commons-fileupload.version>
<commons-io.version>2.5</commons-io.version>
<guava.version>21.0</guava.version>
<hibernate.version>5.2.6.Final</hibernate.version>
<hibernate.validator.version>5.3.4.Final</hibernate.validator.version>
<postrgesql.version>9.4.1212.jre7</postrgesql.version>
<apache.tomcat.version>9.0.0.M15</apache.tomcat.version>
<apache.poi.version>3.7</apache.poi.version>
<apache.tika.version>1.14</apache.tika.version>
<java.el.version>3.0.0</java.el.version>
<glassfish.web.version>2.2.6</glassfish.web.version>
<apache.httpcomponents.version>4.5.3</apache.httpcomponents.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<argLine>-Xmx512m -XX:MaxPermSize=256m</argLine>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
~
~ Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>registration-parent</artifactId>
<groupId>eu.mooseinc</groupId>
<version>1.3.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<artifactId>registration-doc</artifactId>
</project>

View File

@ -0,0 +1,9 @@
CREATE TABLE registration_membership
(
id bigint NOT NULL,
version bigint NOT NULL,
membership_type character varying(60) NOT NULL,
CONSTRAINT registration_membership_pkey PRIMARY KEY (id)
);
CREATE SEQUENCE registrationform_sequence START 100 INCREMENT 1;

View File

@ -0,0 +1,5 @@
INSERT INTO registration_membership(id, version, membership_type) VALUES (1, 0, 'Membership in the Private Security Pillar');
INSERT INTO registration_membership(id, version, membership_type) VALUES (2, 0, 'Membership in the Civil Society Pillar');
INSERT INTO registration_membership(id, version, membership_type) VALUES (3, 0, 'Membership in the Government Pillar');
INSERT INTO registration_membership(id, version, membership_type) VALUES (4, 0, 'Observer status');
INSERT INTO registration_membership(id, version, membership_type) VALUES (5, 0, 'Affiliate status');

View File

@ -0,0 +1,189 @@
<?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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>registration-parent</artifactId>
<groupId>eu.mooseinc</groupId>
<version>1.3.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<artifactId>registration-form</artifactId>
<dependencies>
<!--Spring-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<!--Thymeleaf-->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>${thymeleaf.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
<version>${thymeleaf.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<!--Logi-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!--Postgresql-->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postrgesql.version}</version>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate.validator.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
<version>${apache.tomcat.version}</version>
<scope>runtime</scope>
</dependency>
<!--Maile-->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>${java.mail.version}</version>
</dependency>
<!--Upload plików-->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>${commons-fileupload.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<!--Json-->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<!--Utils-->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${apache.commons.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
<version>${apache.tika.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${apache.poi.version}</version>
</dependency>
<!--Walidatory-->
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>${java.el.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.el</artifactId>
<version>${glassfish.web.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>fluent-hc</artifactId>
<version>${apache.httpcomponents.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<contextFile>${project.build.outputDirectory}/embedded/tomcat-context.xml</contextFile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,23 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.dao;
import eu.mooseinc.dell.form.dao.base.Dao;
import eu.mooseinc.dell.form.entity.MembershipType;
import java.util.List;
/**
* DAO interface for entity {@link MembershipType}
*/
public interface MembershipTypeDao extends Dao<MembershipType> {
/**
* Returns list of membership types.
*
* @return list of membership types.
*/
List<MembershipType> getMembershipTypes();
}

View File

@ -0,0 +1,67 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.dao.base;
import eu.mooseinc.dell.form.exception.ObjectNotFoundException;
import java.util.List;
/**
* Base dao
*/
public interface Dao<T> {
/**
* Store object in database and get its identifier.
*
* @param t object to store.
*
* @return stored object.
*/
T persist(T t);
/**
* Delete object from database with provided id.
*
* @param id object id.
*
* @throws ObjectNotFoundException object not found in database.
*/
void delete(long id) throws ObjectNotFoundException;
/**
* Delete object from database.
*
* @param t object to delete.
*/
void remove(T t);
/**
* Returns object with provided id. If there is no such object, it terurns {@code null}.
*
* @param id object id.
*
* @return object with provided id.
*/
T find(long id);
/**
* Returns object from database.
*
* @param id object id.
*
* @return object with provided id.
*
* @throws ObjectNotFoundException object not found in database.
*/
T get(long id) throws ObjectNotFoundException;
/**
* List of all objects in database
*
* @return list of objects.
*/
List<T> getAll();
}

View File

@ -0,0 +1,35 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.dao.impl;
import eu.mooseinc.dell.form.dao.MembershipTypeDao;
import eu.mooseinc.dell.form.dao.impl.base.AbstractDao;
import eu.mooseinc.dell.form.entity.MembershipType;
import eu.mooseinc.dell.form.entity.query.MembershipTypeQueries.GetMembershipTypesQuery;
import eu.mooseinc.dell.form.type.Entity;
import java.util.List;
import org.hibernate.query.Query;
import org.springframework.stereotype.Repository;
/**
* DAO implementation for entity {@link MembershipType}
*/
@Repository
public class MembershipTypeDaoImpl extends AbstractDao<MembershipType> implements MembershipTypeDao {
/**
* Constructor.
*/
public MembershipTypeDaoImpl() {
super(Entity.MEMBERSHIP_TYPE);
}
@Override
public List<MembershipType> getMembershipTypes() {
final Query<MembershipType> query = createNamedQuery(GetMembershipTypesQuery.NAME);
return query.getResultList();
}
}

View File

@ -0,0 +1,114 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.dao.impl.base;
import eu.mooseinc.dell.form.dao.base.Dao;
import eu.mooseinc.dell.form.entity.base.BaseEntity;
import eu.mooseinc.dell.form.exception.ObjectNotFoundException;
import eu.mooseinc.dell.form.type.Entity;
import java.lang.reflect.ParameterizedType;
import java.text.MessageFormat;
import java.util.List;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Bazowa implementacja dla {@link Dao}.
*
* @param <T> typ encji.
*/
public abstract class AbstractDao<T extends BaseEntity> implements Dao<T> {
@Autowired
protected SessionFactory sessionFactory;
/**
* Klasa obiektu obsługiwanego przez DAO.
*/
private final Class<T> clazz;
/**
* Typ encji.
*/
private final Entity entity;
/**
* Konstruktor.
*
* @param entity typ encji.
*/
public AbstractDao(final Entity entity) {
this.clazz = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
this.entity = entity;
}
@Override
public T persist(final T t) {
sessionFactory.getCurrentSession().persist(t);
return t;
}
@Override
public void delete(final long id) throws ObjectNotFoundException {
sessionFactory.getCurrentSession().delete(get(id));
}
@Override
public void remove(final T t) {
sessionFactory.getCurrentSession().delete(t);
}
@Override
public T find(final long id) {
return sessionFactory.getCurrentSession().get(clazz, id);
}
@Override
public T get(final long id) throws ObjectNotFoundException {
final T t = find(id);
if (t == null)
throw new ObjectNotFoundException(
MessageFormat.format("Nie odnaleziono obiektu {0} o identyfikatorze {1}", entity.getName(), id));
return t;
}
@Override
public List<T> getAll() {
final Session session = sessionFactory.getCurrentSession();
final CriteriaBuilder builder = session.getCriteriaBuilder();
final CriteriaQuery<T> criteriaQuery = builder.createQuery(clazz);
final Root<T> from = criteriaQuery.from(clazz);
criteriaQuery.select(from);
final Query<T> query = session.createQuery(criteriaQuery);
return query.getResultList();
}
/**
* Tworzy zapytanie nazwane.
*
* @param queryName nazwa zapytania HQL.
*
* @return obiekt zapytania.
*/
protected Query<T> createNamedQuery(final String queryName) {
return sessionFactory.getCurrentSession().createNamedQuery(queryName, clazz);
}
/**
* Zwraca rodzaj encji.
*
* @return rodzaj encji.
*/
protected Entity getEntity() {
return entity;
}
}

View File

@ -0,0 +1,66 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.entity;
import eu.mooseinc.dell.form.entity.base.BaseEntity;
import eu.mooseinc.dell.form.entity.query.MembershipTypeQueries.GetMembershipTypesQuery;
import eu.mooseinc.dell.form.util.ColumnLengthConstants;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
/**
* Type of membership entity
*/
@Entity
@Table(name = MembershipType.TABLE_NAME)
@NamedQueries(//
@NamedQuery(//
name = GetMembershipTypesQuery.NAME,//
query = GetMembershipTypesQuery.QUERY//
)//
)
public class MembershipType extends BaseEntity {
/**
* Table name.
*/
public static final String TABLE_NAME = "registration_membership";
/**
* Type of membership.
*/
@Column(name = "membership_type", length = ColumnLengthConstants.SHORT_TEXT_LENGTH, nullable = false)
private String registrationMembership;
/**
* Constructor.
*/
public MembershipType() {
}
/**
* Get type of membership.
*
* @return nazwa firmy.
*/
public String getRegistrationMembership() {
return registrationMembership;
}
/**
* Set type of membership.
*
* @param registrationMembership nazwa firmy.
*/
public void setRegistrationMembership(String registrationMembership) {
this.registrationMembership = registrationMembership;
}
}

View File

@ -0,0 +1,203 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.entity;
import eu.mooseinc.dell.form.entity.base.BaseEntity;
import eu.mooseinc.dell.form.util.ColumnLengthConstants;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
* Entity model for registration
*/
public class Registration extends BaseEntity {
/**
* Entity name.
*/
@NotNull(message = "{notification.entityName.required}")
@Size(min = 1, max = ColumnLengthConstants.SHORT_TEXT_LENGTH, message = "{notification.entityName.size}")
private String entityName;
/**
* Name.
*/
@NotNull(message = "{notification.name.required}")
@Size(min = 1, max = ColumnLengthConstants.SHORT_TEXT_LENGTH, message = "${notification.name.size}")
private String name;
/**
* Surname
*/
@NotNull(message = "{notification.surname.required}")
@Size(min = 1, max = ColumnLengthConstants.SHORT_TEXT_LENGTH, message = "${notification.name.size}")
private String surname;
/**
* E-mail address.
*/
@NotNull(message = "{notification.email.required}")
@Size(min = 1, max = ColumnLengthConstants.EMAIL_LENGTH, message = "{notification.email.size}")
private String email;
/**
* Type of membership.
*/
@NotNull(message = "{notification.marketSegment.required}")
private MembershipType membershipType;
/**
* Message body.
*/
@Size(max = ColumnLengthConstants.STANDARD_TEXT_LENGTH, message = "{notification.message.size}")
private String message;
/**
* Registration date.
*/
@Column(name = "registration_date", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date registrationDate;
/**
* Constructor.
*/
public Registration() {
}
/**
* Returns entity name.
*
* @return entity name.
*/
public String getEntityName() {
return entityName;
}
/**
* Set entity name.
*
* @param entityName entity name.
*/
public void setEntityName(String entityName) {
this.entityName = entityName;
}
/**
* Returns name.
*
* @return name.
*/
public String getName() {
return name;
}
/**
* Set name.
*
* @param name name.
*/
public void setName(String name) {
this.name = name;
}
/**
* Returns surname.
*
* @return surname.
*/
public String getSurname() {
return surname;
}
/**
* Set surname.
*
* @param surname surname.
*/
public void setSurname(String surname) {
this.surname = surname;
}
/**
* Returns e-mail.
*
* @return e-mail.
*/
public String getEmail() {
return email;
}
/**
* Set e-mail.
*
* @param email e-mail.
*/
public void setEmail(String email) {
this.email = email;
}
/**
* Returns membership type
*
* @return membership type.
*/
public MembershipType getMembershipType() {
return membershipType;
}
/**
* Set membership type.
*
* @param membershipType Membership Type
*/
public void setMembershipType(MembershipType membershipType) {
this.membershipType = membershipType;
}
/**
* Returns message body.
*
* @return message body.
*/
public String getMessage() {
return message;
}
/**
* Set message body.
*
* @param message message body.
*/
public void setMessage(String message) {
this.message = message;
}
/**
* Set registration date.
*
* @param registrationDate registration date.
*/
public void setRegistrationDate(Date registrationDate) {
this.registrationDate = registrationDate;
}
/**
* Returns registration date.
*
* @return registration date.
*/
public Date getRegistrationDate() {
return registrationDate;
}
}

View File

@ -0,0 +1,68 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.entity.base;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.id.enhanced.SequenceStyleGenerator;
/**
* Base class for entity.
*/
@MappedSuperclass
public class BaseEntity {
/**
* Sequence name.
*/
private static final String SEQUENCE_GENERATOR = "registrationform_sequence";
/**
* Min value for id.
*/
private static final String MIN_SEQUENCE_VALUE = "100";
/**
* id in database.
*/
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = SEQUENCE_GENERATOR)
@GenericGenerator(//
name = SEQUENCE_GENERATOR,//
strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",//
parameters = {//
@Parameter(name = SequenceStyleGenerator.SEQUENCE_PARAM, value = SEQUENCE_GENERATOR),//
@Parameter(name = SequenceStyleGenerator.INITIAL_PARAM, value = MIN_SEQUENCE_VALUE)//
})
private Long id;
/**
* Object version for optimistic locking.
*/
@Version
private long version;
/**
* Returns id of database object.
*
* @return id of database object.
*/
public Long getId() {
return id;
}
/**
* Returns version of object.
*
* @return object version.
*/
public long getVersion() {
return version;
}
}

View File

@ -0,0 +1,27 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.entity.query;
/**
* Named query for entity {@link eu.mooseinc.dell.form.entity.MembershipType}
*/
public class MembershipTypeQueries {
/**
* Returns all membership types.
*/
public static final class GetMembershipTypesQuery {
/**
* Nazwa zapytania.
*/
public static final String NAME = "MembershipTypeQuery";
/**
* Zapytanie nazwane.
*/
public static final String QUERY = "SELECT n FROM MembershipType n";
}
}

View File

@ -0,0 +1,40 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.exception;
/**
* Base exception class for DAO layer.
*/
public class DataAccessObjectException extends Exception {
/**
* Constructor.
*
* @param message exception message.
*/
public DataAccessObjectException(final String message) {
super(message);
}
/**
* Constructor.
*
* @param cause exception cause.
*/
public DataAccessObjectException(final Throwable cause) {
super(cause);
}
/**
* Constructor.
*
* @param message exception message.
* @param cause exception cause.
*/
public DataAccessObjectException(final String message, final Throwable cause) {
super(message, cause);
}
}

View File

@ -0,0 +1,40 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.exception;
/**
* Exception that throws if object not exist in database
*/
public class ObjectNotFoundException extends DataAccessObjectException {
/**
* Constructor.
*
* @param message exception message.
*/
public ObjectNotFoundException(String message) {
super(message);
}
/**
* Constructor.
*
* @param cause exception cause.
*/
public ObjectNotFoundException(Throwable cause) {
super(cause);
}
/**
* Constructor.
*
* @param message exception message.
* @param cause exception cause.
*/
public ObjectNotFoundException(String message, Throwable cause) {
super(message, cause);
}
}

View File

@ -0,0 +1,40 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.exception;
/**
* Bazowa klasa wyjątku warstwy serwisowej.
*/
public class ServiceException extends Exception {
/**
* Constructor.
*
* @param message exception message.
*/
public ServiceException(String message) {
super(message);
}
/**
* Constructor.
*
* @param message exception message.
* @param cause exception cause.
*/
public ServiceException(String message, Throwable cause) {
super(message, cause);
}
/**
* Constructor.
*
* @param cause exception cause.
*/
public ServiceException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,104 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.util.Date;
/**
* Registration form attachment
*/
public class Attachment implements Serializable {
/**
* File id.
*/
@JsonProperty(value = "id")
private final String id;
/**
* File name.
*/
@JsonProperty(value = "name")
private final String fileName;
/**
* File path.
*/
@JsonIgnore
private final String filePath;
/**
* Constructor.
*
* @param id file id.
* @param fileName file name.
* @param filePath file path.
*/
public Attachment(final String id, final String fileName, final String filePath) {
this.id = id;
this.fileName = fileName;
this.filePath = filePath;
}
/**
* Constructor.
*
* @param fileName file name.
* @param filePath file path..
*/
public Attachment(final String fileName, final String filePath) {
this.id = String.valueOf(new Date().getTime());
this.fileName = fileName;
this.filePath = filePath;
}
/**
* Returns file id.
*
* @return file id.
*/
public String getId() {
return id;
}
/**
* Returns file name.
*
* @return file name.
*/
public String getFileName() {
return fileName;
}
/**
* Returns file path.
*
* @return file path.
*/
public String getFilePath() {
return filePath;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Attachment attachment = (Attachment) o;
return id.equals(attachment.id);
}
@Override
public int hashCode() {
return id.hashCode();
}
}

View File

@ -0,0 +1,29 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.model;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Error message
*/
public class ErrorMessage {
@JsonProperty(value = "message")
private String message;
public ErrorMessage(final String message) {
this.message = message;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

View File

@ -0,0 +1,21 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.service;
/**
* Interfejs serwisu do obsługi captcha.
*/
public interface CaptchaService {
/**
* Sprawdza, czy captcha wprowadzona przez użytkownika jest prawidłowa.
*
* @param captcha captcha wprowadzona przez użytkownika
*
* @return {@code true} jeśli captcha jest prawidłowa, {@code false} w przeciwnym wypadku.
*/
boolean isCaptchaValid(String captcha);
}

View File

@ -0,0 +1,41 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.service;
import eu.mooseinc.dell.form.exception.ServiceException;
import eu.mooseinc.dell.form.model.Attachment;
import java.util.List;
/**
* Email Service
*/
public interface MailService {
/**
* Send message
*
* @param to message recipients
* @param subject message subject
* @param text body message
* @param attachments list of attachments, cannot be {@code null}.
*
* @throws ServiceException jeśli wystąpi błąd podczas wysyłania wiadomości.
*/
void send(String[] to, String subject, String text, List<Attachment> attachments) throws ServiceException;
/**
* Sending e-mail message.
*
* @param to message recipients
* @param cc message copy recipients
* @param subject message subject
* @param text body message
* @param attachments list of attachments, cannot be {@code null}.
*
* @throws ServiceException jeśli wystąpi błąd podczas wysyłania wiadomości.
*/
void send(String[] to, String cc, String subject, String text, List<Attachment> attachments) throws ServiceException;
}

View File

@ -0,0 +1,33 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.service;
import eu.mooseinc.dell.form.entity.MembershipType;
import eu.mooseinc.dell.form.exception.ServiceException;
import java.util.List;
/**
* Membership type service
*/
public interface MembershipTypeService {
/**
* @return list of membership types.
*
* @throws ServiceException
*/
List<MembershipType> getMembershipTypes();
/**
* @param membershipTypeId membershipType id
*
* @return membership type with provided id.
*/
MembershipType findMembershipType(Long membershipTypeId);
}

View File

@ -0,0 +1,30 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.service;
import eu.mooseinc.dell.form.entity.Registration;
import eu.mooseinc.dell.form.exception.ObjectNotFoundException;
import eu.mooseinc.dell.form.exception.ServiceException;
/**
* Registration service interface.
*/
public interface RegistrationService {
/**
* Send registration request as e-mail.
*
* @param registration registration data.
*
* @return registration data.
*
* @throws ObjectNotFoundException jeśli nie odnaleziono segmentu rynku.
* @throws ServiceException jeśli wystąpi błąd podczas wysyłania wiadomości.
*/
Registration sendRegistration(Registration registration) throws ObjectNotFoundException,
ServiceException;
}

View File

@ -0,0 +1,75 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.service.impl;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.mooseinc.dell.form.service.CaptchaService;
import java.io.IOException;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.fluent.Request;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
/**
* Implementacja serwisu do obsługi captcha.
*/
@Service
public class CaptchaServiceImpl implements CaptchaService {
/**
* Logger zdarzeń.
*/
private static final Logger logger = LoggerFactory.getLogger(CaptchaServiceImpl.class);
@Value("${captcha.secret}")
private String secret;
@Value("${captcha.url}")
private String url;
@Value("${captcha.timeout}")
private Integer timeout;
@Override
public boolean isCaptchaValid(final String captcha) {
if (StringUtils.isEmpty(captcha))
return false;
final String urlWithParams = createUrlWithParams(captcha);
try {
final String respons =
Request.Get(urlWithParams).connectTimeout(timeout).socketTimeout(timeout).execute().returnContent()
.asString();
ObjectMapper mapper = new ObjectMapper();
final Map map = mapper.readValue(respons, Map.class);
return (boolean) map.get("success");
}
catch (final IOException e) {
logger.warn("Wystąpił błąd podczas potwierdzenia captcha", e);
return true;
}
}
/**
* Tworzy adres z parametrami.
*
* @param captcha captcha użytkownika.
*
* @return adres z parametrami.
*/
private String createUrlWithParams(final String captcha) {
final StringBuilder urlWithParams = new StringBuilder();
urlWithParams.append(url);
urlWithParams.append("?secret=");
urlWithParams.append(secret);
urlWithParams.append("&response=");
urlWithParams.append(captcha);
return urlWithParams.toString();
}
}

View File

@ -0,0 +1,109 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.service.impl;
import com.google.common.base.Preconditions;
import eu.mooseinc.dell.form.exception.ServiceException;
import eu.mooseinc.dell.form.model.Attachment;
import eu.mooseinc.dell.form.service.MailService;
import java.io.File;
import java.util.List;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Service;
/**
* Email Service implementation
*/
@Service
public class MailServiceImpl implements MailService {
/**
* legger
*/
private static final Logger logger = LoggerFactory.getLogger(MailServiceImpl.class);
/**
* codding standard for e-mail.
*/
private static final String ENCODING = "UTF-8";
/**
* Email sender address
*/
@Value("${mail.from}")
private String from;
@Autowired
@Qualifier("mailSender")
private JavaMailSender mailSender;
@Override
public void send(String[] to, String subject, String text, List<Attachment> attachments) throws ServiceException {
Preconditions.checkArgument(to != null && to.length > 0);
Preconditions.checkArgument(StringUtils.isNotEmpty(subject));
Preconditions.checkArgument(StringUtils.isNotEmpty(text));
Preconditions.checkArgument(attachments != null);
sendMail(to, null, subject, text, attachments);
}
@Override
public void send(String[] to, String cc, String subject, String text, List<Attachment> attachments) throws ServiceException {
Preconditions.checkArgument(to != null && to.length > 0);
Preconditions.checkArgument(StringUtils.isNotEmpty(subject));
Preconditions.checkArgument(StringUtils.isNotEmpty(text));
sendMail(to, cc, subject, text, attachments);
}
/**
* Sending email message
*
* @param to message recipient
* @param cc meessage copy recipient
* @param subject message subject
* @param text message body
* @param attachments list of attachments
*
* @throws ServiceException when ther is a problem with sending email
*/
private void sendMail(String[] to, String cc, String subject, String text, List<Attachment> attachments)
throws ServiceException {
final MimeMessage message = mailSender.createMimeMessage();
try {
final MimeMessageHelper helper = new MimeMessageHelper(message, true, ENCODING);
helper.setTo(to);
helper.setFrom(from);
helper.setSubject(subject);
helper.setText(text, true);
if (StringUtils.isNotEmpty(cc))
helper.setCc(cc);
if (attachments != null) {
for (final Attachment attachment : attachments) {
final File file = new File(attachment.getFilePath());
helper.addAttachment(attachment.getFileName(), file);
}
}
}
catch (final MessagingException e) {
logger.error("Wystąpił błąd podczas tworzenia wiadomości", e);
throw new ServiceException("Wystąpił błąd podczas tworzenia wiadomości", e);
}
mailSender.send(message);
}
}

View File

@ -0,0 +1,51 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.service.impl;
import com.google.common.base.Preconditions;
import eu.mooseinc.dell.form.dao.MembershipTypeDao;
import eu.mooseinc.dell.form.entity.MembershipType;
import eu.mooseinc.dell.form.exception.ObjectNotFoundException;
import eu.mooseinc.dell.form.service.MembershipTypeService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Membership type service implementation.
*/
@Service
public class MembershipTypeServiceImpl implements MembershipTypeService {
@Autowired
MembershipTypeDao membershipTypeDao;
@Override
@Transactional(readOnly = true)
public List<MembershipType> getMembershipTypes() {
try {
return membershipTypeDao.getMembershipTypes();
}
catch (Exception e) {
return null;
}
}
@Override
@Transactional(readOnly = true)
public MembershipType findMembershipType(final Long id) {
Preconditions.checkArgument(id != null);
try {
return membershipTypeDao.get(id);
}
catch (ObjectNotFoundException e) {
return null;
}
}
}

View File

@ -0,0 +1,91 @@
/*********************************************************************************************************************************
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
*
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
********************************************************************************************************************************/
package eu.mooseinc.dell.form.service.impl;
import com.google.common.base.Preconditions;
import eu.mooseinc.dell.form.entity.Registration;
import eu.mooseinc.dell.form.exception.ObjectNotFoundException;
import eu.mooseinc.dell.form.exception.ServiceException;
import eu.mooseinc.dell.form.service.MailService;
import eu.mooseinc.dell.form.service.RegistrationService;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;
/**
* Implementation of registration service.
*/
@Service
public class RegistrationServiceImpl implements RegistrationService {
/**
* E-mail message template.
*/
private static final String MAIL_FORM_TEMPLATE = "mailForm.html";
@Autowired
private MailService mailService;
@Value("${mail.recipients}")
private String recipients;
@Value("${mail.title:'Thank you for your registration with the International Code of Conduct Association.'}")
private String emailTitle;
@Autowired
@Qualifier("emailTemplateEngine")
private TemplateEngine templateEngine;
@Override
@Transactional(rollbackFor = {ObjectNotFoundException.class, ServiceException.class})
public Registration sendRegistration(final Registration registration)
throws ObjectNotFoundException, ServiceException {
Preconditions.checkArgument(registration != null);
final Set<String> recipientEmails = new HashSet<>();
recipientEmails.addAll(Arrays.asList(recipients.split(",")));
String[] emails = recipientEmails.toArray(new String[recipientEmails.size()]);
final String cc = registration.getEmail();
registration.setRegistrationDate(new Date());
final String content = getMailContent(registration);
final String subject = emailTitle;
mailService.send(emails, cc, subject, content, null);
return null;
}
/**
* Compiled message body.
*
* @param registration registration data.
*
* @return treść wiadomości.
*/
private String getMailContent(final Registration registration) {
final Context ctx = new Context();
ctx.setVariable("fullName", registration.getName() + " " + registration.getSurname());
ctx.setVariable("entityName", registration.getEntityName());
ctx.setVariable("name", registration.getName());
ctx.setVariable("surname", registration.getSurname());
ctx.setVariable("email", registration.getEmail());
ctx.setVariable("membershipType", registration.getMembershipType().getRegistrationMembership());
ctx.setVariable("message", registration.getMessage());
ctx.setVariable("registrationDate", registration.getRegistrationDate());
return templateEngine.process(MAIL_FORM_TEMPLATE, ctx);
}
}

Some files were not shown because too many files have changed in this diff Show More