feature/mapstruct #49
@@ -0,0 +1,485 @@
|
||||
<code_scheme name="DefaultIntelliJCodeStyleCST" version="173">
|
||||
<option name="OTHER_INDENT_OPTIONS">
|
||||
<value>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="LINE_SEPARATOR" value="
" />
|
||||
<option name="GENERATE_FINAL_PARAMETERS" value="true" />
|
||||
<option name="RIGHT_MARGIN" value="200" />
|
||||
<option name="HTML_KEEP_LINE_BREAKS" value="false" />
|
||||
<option name="HTML_KEEP_LINE_BREAKS_IN_TEXT" value="false" />
|
||||
<option name="HTML_INLINE_ELEMENTS" value="a,abbr,acronym,b,basefont,bdo,big,br,cite,cite,code,dfn,em,font,i,img,kbd,label,q,s,samp,select,span,strike,strong,sub,sup,textarea,tt,u,var" />
|
||||
<AndroidXmlCodeStyleSettings>
|
||||
<option name="USE_CUSTOM_SETTINGS" value="true" />
|
||||
</AndroidXmlCodeStyleSettings>
|
||||
<CssCodeStyleSettings>
|
||||
<option name="HEX_COLOR_LOWER_CASE" value="true" />
|
||||
<option name="HEX_COLOR_LONG_FORMAT" value="true" />
|
||||
</CssCodeStyleSettings>
|
||||
<HTMLCodeStyleSettings>
|
||||
<option name="HTML_KEEP_LINE_BREAKS" value="false" />
|
||||
<option name="HTML_KEEP_LINE_BREAKS_IN_TEXT" value="false" />
|
||||
<option name="HTML_INLINE_ELEMENTS" value="abbr,acronym,b,basefont,bdo,big,br,cite,cite,code,dfn,em,font,i,img,kbd,q,s,samp,span,strike,strong,sub,sup,textarea,tt,u,var" />
|
||||
</HTMLCodeStyleSettings>
|
||||
<JavaeeCodeStyleSettings>
|
||||
<option name="ENTITY_VO_SUFFIX" value="DTO" />
|
||||
</JavaeeCodeStyleSettings>
|
||||
<Objective-C-extensions>
|
||||
<file>
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
|
||||
</file>
|
||||
<class>
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
|
||||
</class>
|
||||
<extensions>
|
||||
<pair source="cpp" header="hpp" fileNamingConvention="LOWERCASE" />
|
||||
<pair source="c" header="h" fileNamingConvention="NONE" />
|
||||
</extensions>
|
||||
</Objective-C-extensions>
|
||||
<Properties>
|
||||
<option name="KEEP_BLANK_LINES" value="true" />
|
||||
</Properties>
|
||||
<TypeScriptCodeStyleSettings version="0">
|
||||
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
||||
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
||||
<option name="OBJECT_LITERAL_WRAP" value="1" />
|
||||
</TypeScriptCodeStyleSettings>
|
||||
<XML>
|
||||
<option name="XML_TEXT_WRAP" value="0" />
|
||||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
||||
</XML>
|
||||
<codeStyleSettings language="CFML">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="CMake">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="CSS">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="CoffeeScript">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="8" />
|
||||
<option name="TAB_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="DB2">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="Derby">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="ECMA Script Level 4">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="GSP">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="Gherkin">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="Groovy">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="H2">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="HAML">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="HSQLDB">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="HTML">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="Haml">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="JAVA">
|
||||
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
||||
<option name="ELSE_ON_NEW_LINE" value="true" />
|
||||
<option name="WHILE_ON_NEW_LINE" value="true" />
|
||||
<option name="CATCH_ON_NEW_LINE" value="true" />
|
||||
<option name="FINALLY_ON_NEW_LINE" value="true" />
|
||||
<option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />
|
||||
<option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" />
|
||||
<option name="METHOD_CALL_CHAIN_WRAP" value="5" />
|
||||
<option name="WRAP_COMMENTS" value="true" />
|
||||
<option name="ENUM_CONSTANTS_WRAP" value="1" />
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
<arrangement>
|
||||
<groups>
|
||||
<group>
|
||||
<type>GETTERS_AND_SETTERS</type>
|
||||
<order>KEEP</order>
|
||||
</group>
|
||||
<group>
|
||||
<type>OVERRIDDEN_METHODS</type>
|
||||
<order>KEEP</order>
|
||||
</group>
|
||||
<group>
|
||||
<type>DEPENDENT_METHODS</type>
|
||||
<order>DEPTH_FIRST</order>
|
||||
</group>
|
||||
</groups>
|
||||
<rules>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<FIELD>true</FIELD>
|
||||
<FINAL>true</FINAL>
|
||||
<STATIC>true</STATIC>
|
||||
<visibility />
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<FIELD>true</FIELD>
|
||||
<STATIC>true</STATIC>
|
||||
<visibility />
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<FIELD>true</FIELD>
|
||||
<FINAL>true</FINAL>
|
||||
<visibility />
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<FIELD>true</FIELD>
|
||||
<visibility />
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<INITIALIZER_BLOCK>true</INITIALIZER_BLOCK>
|
||||
<STATIC>true</STATIC>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<INITIALIZER_BLOCK>true</INITIALIZER_BLOCK>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<CONSTRUCTOR>true</CONSTRUCTOR>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<METHOD>true</METHOD>
|
||||
<NAME>main</NAME>
|
||||
<PUBLIC>true</PUBLIC>
|
||||
<STATIC>true</STATIC>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<ABSTRACT>true</ABSTRACT>
|
||||
<METHOD>true</METHOD>
|
||||
<visibility />
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<ABSTRACT>false</ABSTRACT>
|
||||
<METHOD>true</METHOD>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<METHOD>true</METHOD>
|
||||
<STATIC>true</STATIC>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<ENUM>true</ENUM>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<INTERFACE>true</INTERFACE>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<CLASS>true</CLASS>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<CLASS>true</CLASS>
|
||||
<STATIC>true</STATIC>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
</rules>
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="JSON">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="JSP">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="JSPX">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="JavaScript">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="LESS">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="MySQL">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="ObjectiveC">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="Oracle">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="PostgreSQL">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="Puppet">
|
||||
<indentOptions>
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="RHTML">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="8" />
|
||||
<option name="TAB_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="SASS">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="SCSS">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="SQL">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="SQLite">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="Stylus">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="Sybase">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="TSQL">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="TypeScript">
|
||||
<option name="ELSE_ON_NEW_LINE" value="true" />
|
||||
<option name="CATCH_ON_NEW_LINE" value="true" />
|
||||
<option name="FINALLY_ON_NEW_LINE" value="true" />
|
||||
<option name="TERNARY_OPERATION_WRAP" value="1" />
|
||||
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
|
||||
<option name="IF_BRACE_FORCE" value="1" />
|
||||
<option name="DOWHILE_BRACE_FORCE" value="1" />
|
||||
<option name="WHILE_BRACE_FORCE" value="1" />
|
||||
<option name="FOR_BRACE_FORCE" value="1" />
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="XML">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="kotlin">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="ruby">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="8" />
|
||||
<option name="TAB_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
@@ -1,12 +1,16 @@
|
||||
description = 'Mowesta Service Ejb'
|
||||
|
||||
ext{
|
||||
mapstructVersion = "1.3.1.Final"
|
||||
}
|
||||
dependencies {
|
||||
compile project(':common-api')
|
||||
compile project(':service-data')
|
||||
|
||||
compile("org.mapstruct:mapstruct-jdk8:${mapstructVersion}")
|
||||
|
||||
compileOnly "javax:javaee-api:${versionJavaee}"
|
||||
compileOnly "com.fasterxml.jackson.core:jackson-annotations:${versionJackson}"
|
||||
compileOnly "org.hibernate:hibernate-search-orm:${versionHibernateSearch}"
|
||||
compileOnly("org.mapstruct:mapstruct-processor:${mapstructVersion}")
|
||||
|
||||
testCompile "org.hibernate:hibernate-search-orm:${versionHibernateSearch}"
|
||||
testCompile "javax:javaee-api:${versionJavaee}"
|
||||
@@ -16,6 +20,8 @@ dependencies {
|
||||
testCompile "org.picketbox:picketbox:${versionPicketbox}"
|
||||
testCompile "org.jboss.arquillian.junit:arquillian-junit-container:${versionArquillianJunit}"
|
||||
testCompile "org.wildfly.arquillian:wildfly-arquillian-container-managed:${versionArquillianContainer}"
|
||||
|
||||
annotationProcessor "org.mapstruct:mapstruct-processor:${mapstructVersion}"
|
||||
}
|
||||
|
||||
// depend on wildfly task for testing
|
||||
@@ -32,4 +38,12 @@ jar {
|
||||
'Implementation-Build' : "${System.properties['jenkins.build.number']}"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDir "${buildDir.absolutePath}/generated/sources/annotationProcessor/java/main"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.mowesta.service.conversion;
|
||||
|
||||
import com.mowesta.api.location.CityDigest;
|
||||
import com.mowesta.service.entity.CityEntity;
|
||||
|
||||
/**
|
||||
* A base class for converters for cities.
|
||||
*
|
||||
* @author Marcus
|
||||
*
|
||||
* @param <C> The city type.
|
||||
*/
|
||||
public abstract class AbstractCityConverter<C extends CityDigest> extends AbstractLocationConverter<CityEntity, C> {
|
||||
|
||||
/**
|
||||
* The converter.
|
||||
*/
|
||||
protected LocationConverter converter;
|
||||
|
||||
/**
|
||||
* Creates a new converter.
|
||||
*
|
||||
* @param filtered True to filter the deleted values.
|
||||
*/
|
||||
public AbstractCityConverter(boolean filtered) {
|
||||
super(filtered);
|
||||
this.converter = new LocationConverter(filtered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public C convert(CityEntity source) {
|
||||
C c = super.convert(source);
|
||||
c.setType(source.getType());
|
||||
c.setCountry(converter.convert(source.getCountry()));
|
||||
c.setState(converter.convert(source.getState()));
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.mowesta.service.conversion;
|
||||
|
||||
import com.mowesta.api.device.Device;
|
||||
import com.mowesta.service.entity.DeviceEntity;
|
||||
|
||||
/**
|
||||
* Base class to convert device entities.
|
||||
*
|
||||
* @author Marcus
|
||||
* @param <D> The data type to convert to.
|
||||
*/
|
||||
public abstract class AbstractDeviceConverter<D extends Device> extends AbstractEntityConverter<DeviceEntity, D> {
|
||||
|
||||
/**
|
||||
* Creates a new converter.
|
||||
*
|
||||
* @param filtered True to filter out deleted devices.
|
||||
*/
|
||||
public AbstractDeviceConverter(boolean filtered) {
|
||||
super(filtered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public D convert(DeviceEntity source) {
|
||||
D result = super.convert(source);
|
||||
if (source.getUser() != null) {
|
||||
result.setUser(source.getUser().getId());
|
||||
}
|
||||
result.setDevice(source.getDevice());
|
||||
result.setManufacturer(source.getManufacturer());
|
||||
result.setModel(source.getModel());
|
||||
result.setOs(source.getOs());
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
package com.mowesta.service.conversion;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.mowesta.api.location.Coordinate;
|
||||
import com.mowesta.api.location.LanguageCode;
|
||||
import com.mowesta.api.location.Location;
|
||||
import com.mowesta.service.entity.AbstractLocationEntity;
|
||||
import com.mowesta.service.entity.EmbeddedCoordinate;
|
||||
|
||||
/**
|
||||
* An abstract base class for location converters.
|
||||
*
|
||||
* @author Marcus
|
||||
*
|
||||
* @param <L> The location type.
|
||||
* @param <E> The location entity type.
|
||||
*/
|
||||
public abstract class AbstractLocationConverter<E extends AbstractLocationEntity, L extends Location> extends AbstractEntityConverter<E, L> {
|
||||
|
||||
/**
|
||||
* Creates a new converter.
|
||||
*
|
||||
* @param filtered True to filter deleted.
|
||||
*/
|
||||
public AbstractLocationConverter(boolean filtered) {
|
||||
super(filtered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public L convert(E source) {
|
||||
L location = super.convert(source);
|
||||
if (location != null) {
|
||||
Map<LanguageCode, String> names = new HashMap<>();
|
||||
names.put(LanguageCode.LOCAL, source.getNames().getLocal());
|
||||
if (source.getNames().getGerman() != null)
|
||||
names.put(LanguageCode.GERMAN, source.getNames().getGerman());
|
||||
if (source.getNames().getEnglish() != null)
|
||||
names.put(LanguageCode.ENGLISH, source.getNames().getEnglish());
|
||||
if (source.getNames().getItalian() != null)
|
||||
names.put(LanguageCode.ITALIAN, source.getNames().getItalian());
|
||||
if (source.getNames().getSpanish() != null)
|
||||
names.put(LanguageCode.SPANISH, source.getNames().getSpanish());
|
||||
if (source.getNames().getFrench() != null)
|
||||
names.put(LanguageCode.FRENCH, source.getNames().getFrench());
|
||||
location.setNames(names);
|
||||
EmbeddedCoordinate c = source.getCoordiante();
|
||||
location.setCoordinate(new Coordinate(c.getLongitude(), c.getLatitude()));
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +1,30 @@
|
||||
package com.mowesta.service.conversion;
|
||||
|
||||
import com.mowesta.api.location.City;
|
||||
import com.mowesta.service.conversion.internal.AbstractEntityConverterWrapper;
|
||||
import com.mowesta.service.conversion.internal.IEntityConverter;
|
||||
import com.mowesta.service.entity.CityEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* A converter for cities.
|
||||
*
|
||||
* A converter for emails.
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
public class CityConverter extends AbstractCityConverter<City>{
|
||||
|
||||
/**
|
||||
* Creates a converter.
|
||||
*
|
||||
* @param filtered True to filter deleted.
|
||||
*/
|
||||
public CityConverter(boolean filtered) {
|
||||
super(filtered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public City create() {
|
||||
return new City();
|
||||
}
|
||||
|
||||
@Override
|
||||
public City convert(CityEntity source) {
|
||||
City c = super.convert(source);
|
||||
if (c != null) {
|
||||
c.setCapital(source.isCapital());
|
||||
c.setPopulation(source.getPopulation());
|
||||
c.setTimezone(source.getTimezone());
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Mapper(config = IEntityConverter.class)
|
||||
public abstract class CityConverter implements ILocationConverter<CityEntity, City> {
|
||||
public static final CityConverter INSTANCE = Mappers.getMapper(CityConverter.class);
|
||||
|
||||
public static class CityConverterWrapper extends AbstractEntityConverterWrapper<CityEntity, City> {
|
||||
/**
|
||||
* Creates a new entity converter.
|
||||
*
|
||||
* @param filtered A flag to indicate whether
|
||||
* deleted objects should be filtered.
|
||||
*/
|
||||
public CityConverterWrapper(boolean filtered) {
|
||||
super(INSTANCE, filtered);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,30 @@
|
||||
package com.mowesta.service.conversion;
|
||||
|
||||
import com.mowesta.api.location.CityDigest;
|
||||
import com.mowesta.service.conversion.internal.AbstractEntityConverterWrapper;
|
||||
import com.mowesta.service.conversion.internal.IEntityConverter;
|
||||
import com.mowesta.service.entity.CityEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* A converter for city digests.
|
||||
*
|
||||
* A converter for emails.
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
public class CityDigestConverter extends AbstractCityConverter<CityDigest>{
|
||||
|
||||
/**
|
||||
* Creates a converter for digests.
|
||||
*
|
||||
* @param filtered True to filter deleted.
|
||||
*/
|
||||
public CityDigestConverter(boolean filtered) {
|
||||
super(filtered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CityDigest create() {
|
||||
return new CityDigest();
|
||||
}
|
||||
|
||||
@Mapper(config = IEntityConverter.class)
|
||||
public abstract class CityDigestConverter implements ILocationConverter<CityEntity, CityDigest> {
|
||||
public static final CityDigestConverter INSTANCE = Mappers.getMapper(CityDigestConverter.class);
|
||||
|
||||
public static class CityDigestConverterWrapper extends AbstractEntityConverterWrapper<CityEntity, CityDigest> {
|
||||
/**
|
||||
* Creates a new entity converter.
|
||||
*
|
||||
* @param filtered A flag to indicate whether
|
||||
* deleted objects should be filtered.
|
||||
*/
|
||||
public CityDigestConverterWrapper(boolean filtered) {
|
||||
super(INSTANCE, filtered);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mowesta.service.conversion;
|
||||
|
||||
import com.mowesta.api.location.Location;
|
||||
import com.mowesta.service.conversion.internal.AbstractEntityConverterWrapper;
|
||||
import com.mowesta.service.conversion.internal.IEntityConverter;
|
||||
import com.mowesta.service.entity.CountryEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* A converter for emails.
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
@Mapper(config = IEntityConverter.class)
|
||||
public abstract class CountryConverter implements ILocationConverter<CountryEntity, Location> {
|
||||
public static final CountryConverter INSTANCE = Mappers.getMapper(CountryConverter.class);
|
||||
|
||||
public static class CountryConverterWrapper extends AbstractEntityConverterWrapper<CountryEntity, Location> {
|
||||
/**
|
||||
* Creates a new entity converter.
|
||||
*
|
||||
* @param filtered A flag to indicate whether
|
||||
* deleted objects should be filtered.
|
||||
*/
|
||||
public CountryConverterWrapper(boolean filtered) {
|
||||
super(INSTANCE, filtered);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mowesta.service.conversion;
|
||||
|
||||
import com.mowesta.api.Entity;
|
||||
import com.mowesta.service.conversion.internal.AbstractEntityConverterWrapper;
|
||||
import com.mowesta.service.conversion.internal.IEntityConverter;
|
||||
import com.mowesta.service.entity.CurrentWeatherEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* A converter for emails.
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
@Mapper(config = IEntityConverter.class)
|
||||
public abstract class CurrentWeatherConverter implements IEntityConverter<CurrentWeatherEntity, Entity> {
|
||||
public static final CurrentWeatherConverter INSTANCE = Mappers.getMapper(CurrentWeatherConverter.class);
|
||||
|
||||
public static class CurrentWeatherConverterWrapper extends AbstractEntityConverterWrapper<CurrentWeatherEntity, Entity> {
|
||||
/**
|
||||
* Creates a new entity converter.
|
||||
*
|
||||
* @param filtered A flag to indicate whether
|
||||
* deleted objects should be filtered.
|
||||
*/
|
||||
public CurrentWeatherConverterWrapper(boolean filtered) {
|
||||
super(INSTANCE, filtered);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,29 @@
|
||||
package com.mowesta.service.conversion;
|
||||
|
||||
import com.mowesta.api.device.Device;
|
||||
import com.mowesta.service.conversion.internal.AbstractEntityConverterWrapper;
|
||||
import com.mowesta.service.entity.DeviceEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* Converts device entities to devices.
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
public class DeviceConverter extends AbstractDeviceConverter<Device> {
|
||||
|
||||
/**
|
||||
* Creates a converter.
|
||||
*
|
||||
* @param filtered True to filter deleted.
|
||||
*/
|
||||
public DeviceConverter(boolean filtered) {
|
||||
super(filtered);
|
||||
@Mapper(config = IDeviceConverter.class)
|
||||
public abstract class DeviceConverter implements IDeviceConverter<Device> {
|
||||
public static final DeviceConverter INSTANCE = Mappers.getMapper(DeviceConverter.class);
|
||||
|
||||
public static class DeviceConverterWrapper extends AbstractEntityConverterWrapper<DeviceEntity, Device> {
|
||||
/**
|
||||
* Creates a new entity converter.
|
||||
*
|
||||
* @param filtered A flag to indicate whether
|
||||
* deleted objects should be filtered.
|
||||
*/
|
||||
public DeviceConverterWrapper(boolean filtered) {
|
||||
super(INSTANCE, filtered);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device create() {
|
||||
return new Device();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+16
-23
@@ -1,35 +1,28 @@
|
||||
package com.mowesta.service.conversion;
|
||||
|
||||
import com.mowesta.api.device.DeviceHandle;
|
||||
import com.mowesta.service.conversion.internal.AbstractEntityConverterWrapper;
|
||||
import com.mowesta.service.entity.DeviceEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* Converts device entities to device handles.
|
||||
*
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
public class DeviceHandleConverter extends AbstractDeviceConverter<DeviceHandle> {
|
||||
|
||||
/**
|
||||
* Creates a new converter.
|
||||
*
|
||||
* @param filtered True to filter deleted.
|
||||
*/
|
||||
public DeviceHandleConverter(boolean filtered) {
|
||||
super(filtered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceHandle create() {
|
||||
return new DeviceHandle();
|
||||
}
|
||||
@Mapper(config = IDeviceConverter.class)
|
||||
public abstract class DeviceHandleConverter implements IDeviceConverter<DeviceHandle> {
|
||||
public static final DeviceHandleConverter INSTANCE = Mappers.getMapper(DeviceHandleConverter.class);
|
||||
|
||||
@Override
|
||||
public DeviceHandle convert(DeviceEntity source) {
|
||||
DeviceHandle result = super.convert(source);
|
||||
result.setToken(source.getToken());
|
||||
return result;
|
||||
public static class DeviceHandleConverterWrapper extends AbstractEntityConverterWrapper<DeviceEntity, DeviceHandle> {
|
||||
/**
|
||||
* Creates a new entity converter.
|
||||
*
|
||||
* @param filtered A flag to indicate whether deleted objects should be filtered.
|
||||
*/
|
||||
public DeviceHandleConverterWrapper(boolean filtered) {
|
||||
super(INSTANCE, filtered);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,38 +1,29 @@
|
||||
package com.mowesta.service.conversion;
|
||||
|
||||
import com.mowesta.api.user.Email;
|
||||
import com.mowesta.service.conversion.internal.AbstractEntityConverterWrapper;
|
||||
import com.mowesta.service.conversion.internal.IEntityConverter;
|
||||
import com.mowesta.service.entity.EmailEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* A converter for emails.
|
||||
*
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
public class EmailConverter extends AbstractEntityConverter<EmailEntity, Email>{
|
||||
|
||||
/**
|
||||
* Creates a new email converter.
|
||||
*
|
||||
* @param filtered True to filter deleted
|
||||
* objects, false to keep them.
|
||||
*/
|
||||
public EmailConverter(boolean filtered) {
|
||||
super(filtered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Email create() {
|
||||
return new Email();
|
||||
}
|
||||
@Mapper(config = IEntityConverter.class)
|
||||
public abstract class EmailConverter implements IEntityConverter<EmailEntity, Email> {
|
||||
public static final EmailConverter INSTANCE = Mappers.getMapper(EmailConverter.class);
|
||||
|
||||
@Override
|
||||
public Email convert(EmailEntity source) {
|
||||
Email result = super.convert(source);
|
||||
if (result == null) return null;
|
||||
result.setAddress(source.getAddress());
|
||||
result.setCorrespondence(source.isCorrespondence());
|
||||
result.setVerified(source.isVerified());
|
||||
return result;
|
||||
public static class EmailConverterWrapper extends AbstractEntityConverterWrapper<EmailEntity, Email> {
|
||||
/**
|
||||
* Creates a new entity converter.
|
||||
*
|
||||
* @param filtered A flag to indicate whether deleted objects should be filtered.
|
||||
*/
|
||||
public EmailConverterWrapper(boolean filtered) {
|
||||
super(INSTANCE, filtered);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mowesta.service.conversion;
|
||||
|
||||
import com.mowesta.api.device.Device;
|
||||
import com.mowesta.service.conversion.internal.IEntityConverter;
|
||||
import com.mowesta.service.entity.DeviceEntity;
|
||||
import org.mapstruct.Context;
|
||||
import org.mapstruct.MapperConfig;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
/**
|
||||
* Base class to convert device entities.
|
||||
*
|
||||
* @author Marcus
|
||||
* @param <D> The data type to convert to.
|
||||
*/
|
||||
@MapperConfig(
|
||||
uses = com.mowesta.service.conversion.internal.IEntityConverter.class
|
||||
)
|
||||
public interface IDeviceConverter<D extends Device> extends IEntityConverter<DeviceEntity, D> {
|
||||
|
||||
@Mapping(target = "user", source = "user.id")
|
||||
@Override
|
||||
D convert(DeviceEntity source, @Context boolean filtered);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.mowesta.service.conversion;
|
||||
|
||||
import com.mowesta.api.location.Coordinate;
|
||||
import com.mowesta.api.location.LanguageCode;
|
||||
import com.mowesta.api.location.Location;
|
||||
import com.mowesta.service.conversion.CountryConverter.CountryConverterWrapper;
|
||||
import com.mowesta.service.conversion.StateConverter.StateConverterWrapper;
|
||||
import com.mowesta.service.conversion.internal.IEntityConverter;
|
||||
import com.mowesta.service.entity.*;
|
||||
import org.mapstruct.Context;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ILocationConverter<S extends AbstractLocationEntity, T extends Location> extends IEntityConverter<S, T> {
|
||||
|
||||
default Location convertState(StateEntity sourceState, @Context boolean filtered) {
|
||||
final StateConverterWrapper wrapper = new StateConverterWrapper(filtered);
|
||||
return wrapper.convert(sourceState);
|
||||
}
|
||||
|
||||
default Location convertCountry(CountryEntity sourceWeather, @Context boolean filtered) {
|
||||
final CountryConverterWrapper wrapper = new CountryConverterWrapper(filtered);
|
||||
return wrapper.convert(sourceWeather);
|
||||
}
|
||||
|
||||
default Map<LanguageCode, String> mapNames(EmbeddedName embeddedName) {
|
||||
Map<LanguageCode, String> names = new HashMap<>();
|
||||
names.put(LanguageCode.LOCAL, embeddedName.getLocal());
|
||||
if (embeddedName.getGerman() != null)
|
||||
names.put(LanguageCode.GERMAN, embeddedName.getGerman());
|
||||
if (embeddedName.getEnglish() != null)
|
||||
names.put(LanguageCode.ENGLISH, embeddedName.getEnglish());
|
||||
if (embeddedName.getItalian() != null)
|
||||
names.put(LanguageCode.ITALIAN, embeddedName.getItalian());
|
||||
if (embeddedName.getSpanish() != null)
|
||||
names.put(LanguageCode.SPANISH, embeddedName.getSpanish());
|
||||
if (embeddedName.getFrench() != null)
|
||||
names.put(LanguageCode.FRENCH, embeddedName.getFrench());
|
||||
return names;
|
||||
}
|
||||
|
||||
Coordinate mapCoordinate(EmbeddedCoordinate coordinate);
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.mowesta.service.conversion;
|
||||
|
||||
import com.mowesta.api.location.Location;
|
||||
import com.mowesta.service.entity.AbstractLocationEntity;
|
||||
|
||||
/**
|
||||
* A concrete implementation of the location converter for locations.
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
public class LocationConverter extends AbstractLocationConverter<AbstractLocationEntity, Location> {
|
||||
|
||||
/**
|
||||
* Creates a location converter.
|
||||
*
|
||||
* @param filtered True to filter deleted.
|
||||
*/
|
||||
public LocationConverter(boolean filtered) {
|
||||
super(filtered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location create() {
|
||||
return new Location();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mowesta.service.conversion;
|
||||
|
||||
import com.mowesta.api.location.Location;
|
||||
import com.mowesta.service.conversion.internal.AbstractEntityConverterWrapper;
|
||||
import com.mowesta.service.conversion.internal.IEntityConverter;
|
||||
import com.mowesta.service.entity.StateEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* A converter for emails.
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
@Mapper(config = IEntityConverter.class)
|
||||
public abstract class StateConverter implements ILocationConverter<StateEntity, Location> {
|
||||
public static final StateConverter INSTANCE = Mappers.getMapper(StateConverter.class);
|
||||
|
||||
public static class StateConverterWrapper extends AbstractEntityConverterWrapper<StateEntity, Location> {
|
||||
/**
|
||||
* Creates a new entity converter.
|
||||
*
|
||||
* @param filtered A flag to indicate whether
|
||||
* deleted objects should be filtered.
|
||||
*/
|
||||
public StateConverterWrapper(boolean filtered) {
|
||||
super(INSTANCE, filtered);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +1,48 @@
|
||||
package com.mowesta.service.conversion;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.mowesta.api.user.Email;
|
||||
import com.mowesta.api.user.User;
|
||||
import com.mowesta.service.conversion.EmailConverter.EmailConverterWrapper;
|
||||
import com.mowesta.service.conversion.internal.AbstractEntityConverterWrapper;
|
||||
import com.mowesta.service.conversion.internal.IEntityConverter;
|
||||
import com.mowesta.service.entity.EmailEntity;
|
||||
import com.mowesta.service.entity.RoleEntity;
|
||||
import com.mowesta.service.entity.UserEntity;
|
||||
import org.mapstruct.Context;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A converter for users.
|
||||
*
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
public class UserConverter extends AbstractEntityConverter<UserEntity, User> {
|
||||
|
||||
/**
|
||||
* The converter for email entities.
|
||||
*/
|
||||
protected EmailConverter emailConverter;
|
||||
@Mapper(config = IEntityConverter.class)
|
||||
public abstract class UserConverter implements IEntityConverter<UserEntity, User> {
|
||||
public static final UserConverter INSTANCE = Mappers.getMapper(UserConverter.class);
|
||||
|
||||
/**
|
||||
* Creates a user converter.
|
||||
*
|
||||
* @param filtered A flag to indicate whether
|
||||
* deleted elements should be filtered.
|
||||
*/
|
||||
public UserConverter(boolean filtered) {
|
||||
super(filtered);
|
||||
emailConverter = new EmailConverter(filtered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User create() {
|
||||
return new User();
|
||||
protected String convertRole(RoleEntity source) {
|
||||
return source.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public User convert(UserEntity source) {
|
||||
User result = super.convert(source);
|
||||
if (result == null) return null;
|
||||
result.setLogin(source.getLogin());
|
||||
result.setName(source.getName());
|
||||
result.setSuspended(source.isSuspended());
|
||||
if (source.getEmails() != null) {
|
||||
result.setEmails(emailConverter.convert(new ArrayList<>(source.getEmails())));
|
||||
protected List<Email> convertEmails(Set<EmailEntity> sourceEmails, @Context boolean filtered) {
|
||||
final EmailConverterWrapper wrapper = new EmailConverterWrapper(filtered);
|
||||
return new ArrayList<>(wrapper.convert(sourceEmails));
|
||||
}
|
||||
|
||||
public static class UserConverterWrapper extends AbstractEntityConverterWrapper<UserEntity, User> {
|
||||
/**
|
||||
* Creates a new entity converter.
|
||||
*
|
||||
* @param filtered A flag to indicate whether
|
||||
* deleted objects should be filtered.
|
||||
*/
|
||||
public UserConverterWrapper(boolean filtered) {
|
||||
super(INSTANCE, filtered);
|
||||
}
|
||||
if (source.getRoles() != null) {
|
||||
for (RoleEntity re: source.getRoles()) {
|
||||
result.getRoles().add(re.getName());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.mowesta.service.conversion;
|
||||
|
||||
import com.mowesta.api.Entity;
|
||||
import com.mowesta.service.conversion.internal.AbstractEntityConverterWrapper;
|
||||
import com.mowesta.service.conversion.internal.IEntityConverter;
|
||||
import com.mowesta.service.entity.WeatherForecastEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* A converter for emails.
|
||||
*
|
||||
* @author Marcus
|
||||
*/
|
||||
@Mapper(config = IEntityConverter.class)
|
||||
public abstract class WeatherForecastConverter implements IEntityConverter<WeatherForecastEntity, Entity> {
|
||||
public static final WeatherForecastConverter INSTANCE = Mappers.getMapper(WeatherForecastConverter.class);
|
||||
|
||||
public static class WeatherForecastConverterWrapper extends AbstractEntityConverterWrapper<WeatherForecastEntity, Entity> {
|
||||
/**
|
||||
* Creates a new entity converter.
|
||||
*
|
||||
* @param filtered A flag to indicate whether
|
||||
* deleted objects should be filtered.
|
||||
*/
|
||||
public WeatherForecastConverterWrapper(boolean filtered) {
|
||||
super(INSTANCE, filtered);
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-9
@@ -1,12 +1,7 @@
|
||||
package com.mowesta.service.conversion;
|
||||
package com.mowesta.service.conversion.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* An abstract base class to simplify the implementation
|
||||
@@ -17,7 +12,7 @@ import java.util.Set;
|
||||
* @param <S> The source type.
|
||||
* @param <T> The target type.
|
||||
*/
|
||||
public abstract class AbstractConverter<S, T> implements IConverter<S, T>{
|
||||
public abstract class AbstractConverterWrapper<S, T> implements IConverterWrapper<S, T> {
|
||||
|
||||
@Override
|
||||
public List<T> convert(List<S> source) {
|
||||
@@ -59,5 +54,4 @@ public abstract class AbstractConverter<S, T> implements IConverter<S, T>{
|
||||
public boolean isFiltered(S source) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+13
-14
@@ -1,36 +1,41 @@
|
||||
package com.mowesta.service.conversion;
|
||||
package com.mowesta.service.conversion.internal;
|
||||
|
||||
import com.mowesta.api.Entity;
|
||||
import com.mowesta.service.entity.AbstractEntity;
|
||||
|
||||
/**
|
||||
* A converter for entities.
|
||||
*
|
||||
*
|
||||
* @author Marcus
|
||||
* @param <S> The source type to convert from.
|
||||
* @param <T> The target type to convert to.
|
||||
*/
|
||||
public abstract class AbstractEntityConverter<S extends AbstractEntity, T extends Entity> extends AbstractConverter<S, T> {
|
||||
|
||||
public abstract class AbstractEntityConverterWrapper<S extends AbstractEntity, T extends Entity> extends AbstractConverterWrapper<S, T> {
|
||||
|
||||
/**
|
||||
* A flag to indicate whether deleted objects
|
||||
* should be filtered.
|
||||
*/
|
||||
private boolean filtered;
|
||||
/**
|
||||
* The Mapstruct converter used for the actual conversion
|
||||
*/
|
||||
private final IEntityConverter<S, T> converter;
|
||||
|
||||
/**
|
||||
* Creates a new entity converter.
|
||||
*
|
||||
*
|
||||
* @param filtered A flag to indicate whether
|
||||
* deleted objects should be filtered.
|
||||
*/
|
||||
public AbstractEntityConverter(boolean filtered) {
|
||||
public AbstractEntityConverterWrapper(IEntityConverter<S, T> converter, boolean filtered) {
|
||||
this.converter = converter;
|
||||
this.filtered = filtered;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the converter should filter.
|
||||
*
|
||||
*
|
||||
* @return True to filter.
|
||||
*/
|
||||
public boolean isFiltered() {
|
||||
@@ -40,17 +45,11 @@ public abstract class AbstractEntityConverter<S extends AbstractEntity, T extend
|
||||
@Override
|
||||
public T convert(S source) {
|
||||
if (source == null || isFiltered(source)) return null;
|
||||
T result = create();
|
||||
result.setId(source.getId());
|
||||
result.setCreationTime(source.getCreationTime());
|
||||
result.setModificationTime(source.getModificationTime());
|
||||
result.setDeleted(source.isDeleted());
|
||||
return result;
|
||||
return converter.convert(source, filtered);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFiltered(S source) {
|
||||
return filtered && source != null && source.isDeleted();
|
||||
}
|
||||
|
||||
}
|
||||
+2
-11
@@ -1,4 +1,4 @@
|
||||
package com.mowesta.service.conversion;
|
||||
package com.mowesta.service.conversion.internal;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -12,14 +12,7 @@ import java.util.Set;
|
||||
* @param <S> The source type.
|
||||
* @param <T> The target type.
|
||||
*/
|
||||
public interface IConverter<S, T> {
|
||||
|
||||
/**
|
||||
* Creates a new instance of the target type.
|
||||
*
|
||||
* @return A new instance of the target type.
|
||||
*/
|
||||
T create();
|
||||
public interface IConverterWrapper<S, T> {
|
||||
|
||||
/**
|
||||
* Converts a source element into a target element.
|
||||
@@ -63,6 +56,4 @@ public interface IConverter<S, T> {
|
||||
* @return The target map.
|
||||
*/
|
||||
<K> Map<K, T> convert(Map<K, S> source);
|
||||
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.mowesta.service.conversion.internal;
|
||||
|
||||
import com.mowesta.api.Entity;
|
||||
import com.mowesta.service.entity.AbstractEntity;
|
||||
import org.mapstruct.Context;
|
||||
import org.mapstruct.MapperConfig;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* A converter for entities.
|
||||
*
|
||||
* @param <S> The source type to convert from.
|
||||
* @param <T> The target type to convert to.
|
||||
* @author Marcus
|
||||
*/
|
||||
@MapperConfig(
|
||||
unmappedTargetPolicy = ReportingPolicy.ERROR,
|
||||
disableSubMappingMethodsGeneration = true
|
||||
)
|
||||
public interface IEntityConverter<S extends AbstractEntity, T extends Entity> {
|
||||
/**
|
||||
* Converts a source element into a target element. If the source is null, the target shall also be null.
|
||||
*
|
||||
* @param source The source element.
|
||||
* @param filtered A flag to indicate whether deleted objects should be filtered.
|
||||
* @return The target element.
|
||||
*/
|
||||
T convert(S source, @Context boolean filtered);
|
||||
}
|
||||
@@ -1,19 +1,14 @@
|
||||
package com.mowesta.service.entity;
|
||||
|
||||
import java.util.List;
|
||||
import org.hibernate.search.annotations.Field;
|
||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
||||
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.TypedQuery;
|
||||
import javax.persistence.*;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Root;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.hibernate.search.annotations.Field;
|
||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The base class for locations.
|
||||
@@ -37,7 +32,7 @@ public abstract class AbstractLocationEntity extends AbstractEntity {
|
||||
@Embedded
|
||||
@NotNull
|
||||
@IndexedEmbedded
|
||||
private EmbeddedCoordinate coordiante;
|
||||
private EmbeddedCoordinate coordinate;
|
||||
|
||||
/**
|
||||
* The names of the location.
|
||||
@@ -99,8 +94,8 @@ public abstract class AbstractLocationEntity extends AbstractEntity {
|
||||
*
|
||||
* @return The coordiante.
|
||||
*/
|
||||
public EmbeddedCoordinate getCoordiante() {
|
||||
return coordiante;
|
||||
public EmbeddedCoordinate getCoordinate() {
|
||||
return coordinate;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,8 +103,8 @@ public abstract class AbstractLocationEntity extends AbstractEntity {
|
||||
*
|
||||
* @param coordiante The coordiante to set.
|
||||
*/
|
||||
public void setCoordiante(EmbeddedCoordinate coordiante) {
|
||||
this.coordiante = coordiante;
|
||||
public void setCoordinate(EmbeddedCoordinate coordiante) {
|
||||
this.coordinate = coordiante;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
package com.mowesta.service.principal;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import com.mowesta.api.device.Device;
|
||||
import com.mowesta.api.user.User;
|
||||
import com.mowesta.service.conversion.DeviceConverter;
|
||||
@@ -14,6 +9,10 @@ import com.mowesta.service.entity.DeviceEntity;
|
||||
import com.mowesta.service.entity.EmailEntity;
|
||||
import com.mowesta.service.entity.UserEntity;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Implements the basic login procedure and security checks.
|
||||
*
|
||||
@@ -63,7 +62,7 @@ public class LoginManager {
|
||||
SecureHash hash = new SecureHash(entity.getIterations(), entity.getSalt(), entity.getHash());
|
||||
if (hash.verify(password)) {
|
||||
log.log(Level.INFO, "User '" + login + "' authenticated.");
|
||||
UserConverter c = new UserConverter(true);
|
||||
UserConverter.UserConverterWrapper c = new UserConverter.UserConverterWrapper(true);
|
||||
return c.convert(entity);
|
||||
} else {
|
||||
log.log(Level.SEVERE, "User '" + login + "' provided wrong password.");
|
||||
@@ -105,7 +104,7 @@ public class LoginManager {
|
||||
log.log(Level.SEVERE, "User '" + entity.getUser().getLogin() + "' is suspended.");
|
||||
} else {
|
||||
log.log(Level.INFO, "Device '" + entity.getId() + "' authenticated.");
|
||||
DeviceConverter c = new DeviceConverter(true);
|
||||
DeviceConverter.DeviceConverterWrapper c = new DeviceConverter.DeviceConverterWrapper(true);
|
||||
return c.convert(entity);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
package com.mowesta.service.session;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import com.mowesta.api.Entity;
|
||||
import com.mowesta.api.Page;
|
||||
import com.mowesta.api.PageConfig;
|
||||
import com.mowesta.service.conversion.IConverter;
|
||||
import com.mowesta.service.conversion.internal.IConverterWrapper;
|
||||
import com.mowesta.service.entity.AbstractEntity;
|
||||
import com.mowesta.service.entity.OrderCriterion;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* An abstract base class for session beans. The base class
|
||||
* provides access to the default logger and the default
|
||||
@@ -39,7 +38,7 @@ public abstract class AbstractSessionBean {
|
||||
* @param converter The converter.
|
||||
* @return The page with the users.
|
||||
*/
|
||||
protected <S extends AbstractEntity, T extends Entity, P extends Page<T>> P getAll(Class<S> type, PageConfig config, OrderCriterion order, boolean filtered, P page, IConverter<S, T> converter) {
|
||||
protected <S extends AbstractEntity, T extends Entity, P extends Page<T>> P getAll(Class<S> type, PageConfig config, OrderCriterion order, boolean filtered, P page, IConverterWrapper<S, T> converter) {
|
||||
int count = AbstractEntity.getCount(em, type, filtered);
|
||||
List<S> data = new ArrayList<>();
|
||||
if (count > config.getOffset()) {
|
||||
|
||||
+5
-5
@@ -1,16 +1,16 @@
|
||||
package com.mowesta.service.session;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mowesta.api.Entity;
|
||||
import com.mowesta.api.Page;
|
||||
import com.mowesta.api.PageConfig;
|
||||
import com.mowesta.service.conversion.IConverter;
|
||||
import com.mowesta.service.conversion.internal.IConverterWrapper;
|
||||
import com.mowesta.service.entity.AbstractUserSpecificEntity;
|
||||
import com.mowesta.service.entity.OrderCriterion;
|
||||
import com.mowesta.service.entity.UserEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A base class for session beans that perform operations on user-specific data.
|
||||
*
|
||||
@@ -31,7 +31,7 @@ public class AbstractUserSpecificSessionBean extends AbstractPrincipalSessionBea
|
||||
* @param converter The converter.
|
||||
* @return The page.
|
||||
*/
|
||||
protected <S extends AbstractUserSpecificEntity, T extends Entity, P extends Page<T>> P getAllForUser(Class<S> type, UserEntity user, PageConfig config, OrderCriterion order, boolean filtered, P page, IConverter<S, T> converter) {
|
||||
protected <S extends AbstractUserSpecificEntity, T extends Entity, P extends Page<T>> P getAllForUser(Class<S> type, UserEntity user, PageConfig config, OrderCriterion order, boolean filtered, P page, IConverterWrapper<S, T> converter) {
|
||||
int count = AbstractUserSpecificEntity.getCountForUser(em, type, user, filtered);
|
||||
List<S> data = new ArrayList<>();
|
||||
if (count > config.getOffset()) {
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
package com.mowesta.service.session;
|
||||
|
||||
import javax.annotation.security.DeclareRoles;
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.ejb.Stateful;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
|
||||
import com.mowesta.api.PageConfig;
|
||||
import com.mowesta.api.access.Roles;
|
||||
import com.mowesta.api.device.Device;
|
||||
@@ -16,14 +10,13 @@ import com.mowesta.service.conversion.DeviceConverter;
|
||||
import com.mowesta.service.conversion.DeviceHandleConverter;
|
||||
import com.mowesta.service.crypto.SecureToken;
|
||||
import com.mowesta.service.crypto.TokenType;
|
||||
import com.mowesta.service.entity.AbstractEntity;
|
||||
import com.mowesta.service.entity.AbstractUserSpecificEntity;
|
||||
import com.mowesta.service.entity.DeviceEntity;
|
||||
import com.mowesta.service.entity.EntityConflictException;
|
||||
import com.mowesta.service.entity.EntityForbiddenException;
|
||||
import com.mowesta.service.entity.EntityNotFoundException;
|
||||
import com.mowesta.service.entity.OrderCriterion;
|
||||
import com.mowesta.service.entity.UserEntity;
|
||||
import com.mowesta.service.entity.*;
|
||||
|
||||
import javax.annotation.security.DeclareRoles;
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.ejb.Stateful;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
|
||||
/**
|
||||
* A stateful session bean to manage devices.
|
||||
@@ -52,7 +45,7 @@ public class DeviceSessionBean extends AbstractUserSpecificSessionBean {
|
||||
entity.setToken(SecureToken.createToken(TokenType.INTERNAL));
|
||||
em.persist(entity);
|
||||
em.flush();
|
||||
return new DeviceHandleConverter(true).convert(entity);
|
||||
return new DeviceHandleConverter.DeviceHandleConverterWrapper(true).convert(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +66,7 @@ public class DeviceSessionBean extends AbstractUserSpecificSessionBean {
|
||||
if (device.getUser() != null) throw new EntityConflictException(DeviceEntity.class, device.getId());
|
||||
device.setUser(user);
|
||||
em.flush();
|
||||
return new DeviceConverter(true).convert(device);
|
||||
return new DeviceConverter.DeviceConverterWrapper(true).convert(device);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +82,7 @@ public class DeviceSessionBean extends AbstractUserSpecificSessionBean {
|
||||
DeviceEntity entity = getPrincipalDevice();
|
||||
if (entity == null) throw new EntityNotFoundException(DeviceEntity.class, null, "Cannot find principal device.");
|
||||
if (entity.isDeleted()) throw new EntityForbiddenException(DeviceEntity.class, entity.getId(), "Device is deleted.");
|
||||
return new DeviceConverter(true).convert(entity);
|
||||
return new DeviceConverter.DeviceConverterWrapper(true).convert(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +108,7 @@ public class DeviceSessionBean extends AbstractUserSpecificSessionBean {
|
||||
*/
|
||||
@RolesAllowed({Roles.ADMIN})
|
||||
public DevicePage getAllDevices(PageConfig pageConfig, boolean filtered) {
|
||||
return getAll(DeviceEntity.class, pageConfig, new OrderCriterion("id", true), filtered, new DevicePage(), new DeviceConverter(filtered));
|
||||
return getAll(DeviceEntity.class, pageConfig, new OrderCriterion("id", true), filtered, new DevicePage(), new DeviceConverter.DeviceConverterWrapper(filtered));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,7 +123,7 @@ public class DeviceSessionBean extends AbstractUserSpecificSessionBean {
|
||||
public DevicePage getAllDevicesForCurrentUser(PageConfig pageConfig, boolean filtered) throws EntityNotFoundException {
|
||||
UserEntity user = getPrincipalUser();
|
||||
if (user == null) throw new EntityNotFoundException(UserEntity.class, null, "Cannot find principal user.");
|
||||
return getAllForUser(DeviceEntity.class, user, pageConfig, new OrderCriterion("id"), filtered, new DevicePage(), new DeviceConverter(filtered));
|
||||
return getAllForUser(DeviceEntity.class, user, pageConfig, new OrderCriterion("id"), filtered, new DevicePage(), new DeviceConverter.DeviceConverterWrapper(filtered));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,7 +172,7 @@ public class DeviceSessionBean extends AbstractUserSpecificSessionBean {
|
||||
}
|
||||
}
|
||||
em.flush();
|
||||
return new DeviceConverter(false).convert(device);
|
||||
return new DeviceConverter.DeviceConverterWrapper(false).convert(device);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,7 +198,7 @@ public class DeviceSessionBean extends AbstractUserSpecificSessionBean {
|
||||
entity.setUser(null);
|
||||
}
|
||||
em.flush();
|
||||
return new DeviceConverter(false).convert(entity);
|
||||
return new DeviceConverter.DeviceConverterWrapper(false).convert(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,22 +1,17 @@
|
||||
package com.mowesta.service.session;
|
||||
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.ejb.Stateful;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
|
||||
import com.mowesta.api.PageConfig;
|
||||
import com.mowesta.api.location.City;
|
||||
import com.mowesta.api.location.CityDigestPage;
|
||||
import com.mowesta.api.location.CityPage;
|
||||
import com.mowesta.api.location.SearchContext;
|
||||
import com.mowesta.service.conversion.CityConverter;
|
||||
import com.mowesta.service.conversion.CityDigestConverter;
|
||||
import com.mowesta.service.entity.AbstractEntity;
|
||||
import com.mowesta.service.entity.CityEntity;
|
||||
import com.mowesta.service.entity.CountryEntity;
|
||||
import com.mowesta.service.entity.EntityNotFoundException;
|
||||
import com.mowesta.service.entity.OrderCriterion;
|
||||
import com.mowesta.service.entity.StateEntity;
|
||||
import com.mowesta.service.conversion.CityConverter.CityConverterWrapper;
|
||||
import com.mowesta.service.conversion.CityDigestConverter.CityDigestConverterWrapper;
|
||||
import com.mowesta.service.entity.*;
|
||||
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.ejb.Stateful;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
|
||||
/**
|
||||
* A session bean to access locations.
|
||||
@@ -41,7 +36,7 @@ public class LocationSessionBean extends AbstractSessionBean {
|
||||
page.setOffset(config.getOffset());
|
||||
page.setSize(config.getSize());
|
||||
page.setTotal(CityEntity.countAllByTerm(em, context.getLanguage(), term));
|
||||
CityDigestConverter converter = new CityDigestConverter(false);
|
||||
CityDigestConverterWrapper converter = new CityDigestConverterWrapper(false);
|
||||
page.setElements(converter.convert(CityEntity.findAllByTerm(em, config, context.getLanguage(), term)));
|
||||
if (page.getTotal() < page.getOffset() + page.getElements().size()) {
|
||||
page.setTotal(page.getOffset() + page.getElements().size());
|
||||
@@ -62,7 +57,7 @@ public class LocationSessionBean extends AbstractSessionBean {
|
||||
public City getCity(long id, boolean filtered) throws EntityNotFoundException {
|
||||
CityEntity city = em.find(CityEntity.class, new Long(id));
|
||||
if (city == null || (filtered && city.isDeleted())) throw new EntityNotFoundException(CityEntity.class, id, "City not found.");
|
||||
return new CityConverter(filtered).convert(city);
|
||||
return new CityConverterWrapper(filtered).convert(city);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,7 +121,7 @@ public class LocationSessionBean extends AbstractSessionBean {
|
||||
*/
|
||||
@PermitAll
|
||||
public CityPage getAllCities(PageConfig config, boolean filtered) {
|
||||
return getAll(CityEntity.class, config, new OrderCriterion("id"), filtered, new CityPage(), new CityConverter(filtered));
|
||||
return getAll(CityEntity.class, config, new OrderCriterion("id"), filtered, new CityPage(), new CityConverterWrapper(filtered));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,30 +1,23 @@
|
||||
package com.mowesta.service.session;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.enterprise.context.Dependent;
|
||||
import javax.transaction.Transactional;
|
||||
import javax.transaction.Transactional.TxType;
|
||||
|
||||
import org.geojson.Geometry;
|
||||
import org.hibernate.search.jpa.Search;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.mowesta.data.nominatim.NominatimCity;
|
||||
import com.mowesta.data.nominatim.NominatimCountry;
|
||||
import com.mowesta.data.nominatim.NominatimObject;
|
||||
import com.mowesta.data.nominatim.NominatimState;
|
||||
import com.mowesta.service.entity.AbstractLocationEntity;
|
||||
import com.mowesta.service.entity.CityEntity;
|
||||
import com.mowesta.service.entity.CountryEntity;
|
||||
import com.mowesta.service.entity.EmbeddedCoordinate;
|
||||
import com.mowesta.service.entity.EmbeddedName;
|
||||
import com.mowesta.service.entity.StateEntity;
|
||||
import com.mowesta.service.entity.*;
|
||||
import org.geojson.Geometry;
|
||||
import org.hibernate.search.jpa.Search;
|
||||
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.enterprise.context.Dependent;
|
||||
import javax.transaction.Transactional;
|
||||
import javax.transaction.Transactional.TxType;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* A session bean to synchronize the external data.
|
||||
@@ -152,7 +145,7 @@ public class SyncSessionBean extends AbstractSessionBean {
|
||||
*/
|
||||
private void updateLocation(NominatimObject object, AbstractLocationEntity entity) {
|
||||
entity.setAddressRank(object.getAddressRank());
|
||||
entity.setCoordiante(new EmbeddedCoordinate(object.getCentroid().getCoordinates().getLongitude(), object.getCentroid().getCoordinates().getLatitude()));
|
||||
entity.setCoordinate(new EmbeddedCoordinate(object.getCentroid().getCoordinates().getLongitude(), object.getCentroid().getCoordinates().getLatitude()));
|
||||
entity.setDeleted(false);
|
||||
entity.setExternalId(object.getId());
|
||||
entity.setImportance(object.getImportance());
|
||||
|
||||
@@ -1,19 +1,5 @@
|
||||
package com.mowesta.service.session;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.annotation.security.DeclareRoles;
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.ejb.Stateful;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.mowesta.api.PageConfig;
|
||||
import com.mowesta.api.access.Roles;
|
||||
import com.mowesta.api.user.Email;
|
||||
@@ -24,21 +10,20 @@ import com.mowesta.service.conversion.UserConverter;
|
||||
import com.mowesta.service.crypto.SecureHash;
|
||||
import com.mowesta.service.crypto.SecureToken;
|
||||
import com.mowesta.service.crypto.TokenType;
|
||||
import com.mowesta.service.entity.AbstractEntity;
|
||||
import com.mowesta.service.entity.CodeEntity;
|
||||
import com.mowesta.service.entity.CodeType;
|
||||
import com.mowesta.service.entity.DeviceEntity;
|
||||
import com.mowesta.service.entity.EmailEntity;
|
||||
import com.mowesta.service.entity.EntityConflictException;
|
||||
import com.mowesta.service.entity.EntityForbiddenException;
|
||||
import com.mowesta.service.entity.EntityNotFoundException;
|
||||
import com.mowesta.service.entity.OrderCriterion;
|
||||
import com.mowesta.service.entity.RoleEntity;
|
||||
import com.mowesta.service.entity.UserEntity;
|
||||
import com.mowesta.service.entity.*;
|
||||
import com.mowesta.service.principal.LoginManager;
|
||||
import com.mowesta.service.template.EmailAssignment;
|
||||
import com.mowesta.service.template.EmailTemplate;
|
||||
|
||||
import javax.annotation.security.DeclareRoles;
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.ejb.Stateful;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* A stateful session bean that provides methods to manipulate
|
||||
* users.
|
||||
@@ -100,7 +85,7 @@ public class UserSessionBean extends AbstractPrincipalSessionBean {
|
||||
public User getCurrentDeviceUser() throws EntityForbiddenException {
|
||||
DeviceEntity d = getPrincipalDevice();
|
||||
if (d == null) throw new EntityForbiddenException(DeviceEntity.class, null, "Cnnot access principal device.");
|
||||
return new UserConverter(true).convert(d.getUser());
|
||||
return new UserConverter.UserConverterWrapper(true).convert(d.getUser());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +100,7 @@ public class UserSessionBean extends AbstractPrincipalSessionBean {
|
||||
UserEntity u = getPrincipalUser();
|
||||
if (u == null) throw new EntityNotFoundException(UserEntity.class, null, "Cannot access current user.");
|
||||
if (u.isDeleted() || u.isSuspended()) throw new EntityForbiddenException(UserEntity.class, u.getId(), "Cannot access suspended or deleted user.");
|
||||
return new UserConverter(true).convert(u);
|
||||
return new UserConverter.UserConverterWrapper(true).convert(u);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,7 +132,7 @@ public class UserSessionBean extends AbstractPrincipalSessionBean {
|
||||
setEmails(u, user.getEmails(), currentTime, expirationTime, minimumTime, false);
|
||||
}
|
||||
em.flush();
|
||||
return new UserConverter(true).convert(u);
|
||||
return new UserConverter.UserConverterWrapper(true).convert(u);
|
||||
}
|
||||
|
||||
|
||||
@@ -166,7 +151,7 @@ public class UserSessionBean extends AbstractPrincipalSessionBean {
|
||||
if (u.isSuspended() || u.isDeleted()) throw new EntityForbiddenException(UserEntity.class, u.getId(), "Password modification rejected for suspended or deleted user.");
|
||||
setPassword(u, password);
|
||||
em.flush();
|
||||
return new UserConverter(true).convert(u);
|
||||
return new UserConverter.UserConverterWrapper(true).convert(u);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,7 +173,7 @@ public class UserSessionBean extends AbstractPrincipalSessionBean {
|
||||
*/
|
||||
@RolesAllowed({ Roles.ADMIN })
|
||||
public UserPage getAllUsers(PageConfig config, boolean filtered) {
|
||||
return getAll(UserEntity.class, config, new OrderCriterion("id"), filtered, new UserPage(), new UserConverter(filtered));
|
||||
return getAll(UserEntity.class, config, new OrderCriterion("id"), filtered, new UserPage(), new UserConverter.UserConverterWrapper(filtered));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,7 +192,7 @@ public class UserSessionBean extends AbstractPrincipalSessionBean {
|
||||
page.setSize(config.getSize());
|
||||
page.setTotal((int)count);
|
||||
if (count > config.getOffset()) {
|
||||
UserConverter c = new UserConverter(filtered);
|
||||
UserConverter.UserConverterWrapper c = new UserConverter.UserConverterWrapper(filtered);
|
||||
page.getElements().addAll(c.convert(UserEntity.findByTerm(em, term, config, filtered)));
|
||||
}
|
||||
return page;
|
||||
@@ -244,7 +229,7 @@ public class UserSessionBean extends AbstractPrincipalSessionBean {
|
||||
EmailAssignment assignment = new EmailAssignment(c.getValue(), u.getName());
|
||||
emailSession.sendEmailTemplate(e.getAddress(), EmailTemplate.NEW_USER, assignment);
|
||||
em.flush();
|
||||
return new UserConverter(true).convert(u);
|
||||
return new UserConverter.UserConverterWrapper(true).convert(u);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -285,7 +270,7 @@ public class UserSessionBean extends AbstractPrincipalSessionBean {
|
||||
return null;
|
||||
} else {
|
||||
em.flush(); // create the user id before conversion
|
||||
return new UserConverter(false).convert(u);
|
||||
return new UserConverter.UserConverterWrapper(false).convert(u);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,7 +286,7 @@ public class UserSessionBean extends AbstractPrincipalSessionBean {
|
||||
public User getUser(long id, boolean filtered) throws EntityNotFoundException {
|
||||
UserEntity u = em.find(UserEntity.class, id);
|
||||
if (u == null) throw new EntityNotFoundException(UserEntity.class, id, "User request by admin for non-existing user.");
|
||||
return new UserConverter(filtered).convert(u);
|
||||
return new UserConverter.UserConverterWrapper(filtered).convert(u);
|
||||
}
|
||||
|
||||
|
||||
@@ -331,7 +316,7 @@ public class UserSessionBean extends AbstractPrincipalSessionBean {
|
||||
// TODO replace with validation on user (currently does not return error information)
|
||||
setEmails(u, user.getEmails(), currentTime, expirationTime, minimumTime, true);
|
||||
em.flush(); // generate ids for new objects
|
||||
return new UserConverter(filtered).convert(u);
|
||||
return new UserConverter.UserConverterWrapper(filtered).convert(u);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -465,7 +450,7 @@ public class UserSessionBean extends AbstractPrincipalSessionBean {
|
||||
if (u == null) throw new EntityNotFoundException(UserEntity.class, null, "Password modification rejected for non-existing account.");
|
||||
setPassword(u, password);
|
||||
em.flush();
|
||||
return new UserConverter(false).convert(u);
|
||||
return new UserConverter.UserConverterWrapper(false).convert(u);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -488,7 +473,7 @@ public class UserSessionBean extends AbstractPrincipalSessionBean {
|
||||
code.setDeleted(true);
|
||||
setPassword(code.getEmail().getUser(), password);
|
||||
em.flush();
|
||||
return new UserConverter(true).convert(code.getEmail().getUser());
|
||||
return new UserConverter.UserConverterWrapper(true).convert(code.getEmail().getUser());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.mowesta.service.test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.jboss.shrinkwrap.api.Filters;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.asset.StringAsset;
|
||||
import org.jboss.shrinkwrap.api.spec.JavaArchive;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* The class that defines the deployment that will be used for
|
||||
* all tests. While this might be less flexible, it will be a lot
|
||||
@@ -26,7 +26,7 @@ public class EjbDeployment {
|
||||
public static JavaArchive createEjb() {
|
||||
return ShrinkWrap.create(JavaArchive.class)
|
||||
.addAsManifestResource(new StringAsset(getManifest()), "MANIFEST.MF")
|
||||
.addPackages(true, "org.apache.commons.compress", "org.geojson")
|
||||
.addPackages(true, "org.apache.commons.compress", "org.geojson", "org.mapstruct")
|
||||
.addPackages(true, Filters.exclude("com.mowesta.service.test.*"), "com.mowesta.api", "com.mowesta.service", "com.mowesta.data")
|
||||
.addAsManifestResource(new File("src/test/resources/META-INF/beans.xml"), "beans.xml")
|
||||
// use the persistence.xml from the test resource (in-memory db)
|
||||
|
||||
@@ -81,6 +81,7 @@ public class MowestaThorntail {
|
||||
deployment.addPackages(true, "com.google");
|
||||
deployment.addPackages(true, "org.reflections");
|
||||
deployment.addPackages(true, "io.swagger");
|
||||
deployment.addPackages(true, "org.mapstruct");
|
||||
// add swagger ui from webapp folder
|
||||
String swaggerUiFolder = "src/main/webapp/";
|
||||
String nominatimFolder = "../service-ejb/src/test/resources/nominatim/";
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.mowesta.service.test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
|
||||
import org.jboss.shrinkwrap.api.asset.StringAsset;
|
||||
@@ -9,6 +7,8 @@ import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
|
||||
import org.jboss.shrinkwrap.api.spec.JavaArchive;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* A helper to configure the ear in a similar fashion as done
|
||||
* by the maven-ejb-plugin, maven-war-plugin and maven-ear-plugin.
|
||||
@@ -37,6 +37,7 @@ public class WarDeployment {
|
||||
.addPackages(true, "com.mowesta.service.injection")
|
||||
.addPackages(true, "com.mowesta.service.session")
|
||||
.addPackages(true, "com.mowesta.service.template")
|
||||
.addPackages(true, "org.mapstruct")
|
||||
.addAsResource(new File("../service-ejb/src/test/resources/nominatim/cities.json.bz2"), "nominatim/cities.json.bz2")
|
||||
.addAsResource(new File("../service-ejb/src/test/resources/nominatim/states.json.bz2"), "nominatim/states.json.bz2")
|
||||
.addAsResource(new File("../service-ejb/src/test/resources/nominatim/countries.json.bz2"), "nominatim/countries.json.bz2")
|
||||
|
||||
Generated
+12622
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user