Commit a4d9039b authored by Andrey Lugovskiy's avatar Andrey Lugovskiy
Browse files

-without parse implementation method. it need will do correct.

parent 05c4aaf8
Pipeline #490 passed with stage
in 41 seconds
......@@ -9,3 +9,5 @@ data
/*.csv
.pmd
/taxonomychecker-cli/dependency-reduced-pom.xml
.idea/
*.iml
\ No newline at end of file
......@@ -5,3 +5,5 @@
.settings
.project
data
*.iml
target/
......@@ -16,7 +16,11 @@
-->
<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>
<parent>
<packaging>pom</packaging>
<modules>
<module>taxonomychecker-web</module>
</modules>
<parent>
<groupId>org.genesys-pgr</groupId>
<artifactId>taxonomy-tools</artifactId>
<version>0.2-SNAPSHOT</version>
......
<?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>taxonomychecker-cli</artifactId>
<groupId>org.genesys-pgr</groupId>
<version>0.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<artifactId>taxonomychecker-web</artifactId>
<name>Taxonomy checker web</name>
<prerequisites>
<maven>3.0</maven>
</prerequisites>
<properties>
<source.version>1.8</source.version>
<target.version>1.8</target.version>
<jstl.version>1.2</jstl.version>
<servlet.version>3.0.1</servlet.version>
<spring.version>4.3.4.RELEASE</spring.version>
<jetty.version>9.3.12.v20160915</jetty.version>
<slf4j.version>1.7.21</slf4j.version>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<!--maven-compiler-plugin-->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${source.version}</source>
<target>${target.version}</target>
</configuration>
</plugin>
<!-->maven-war-plugin-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<!--jetty-maven-plugin-->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<stopPort>8888</stopPort>
<stopKey>stop</stopKey>
<jvmArgs>-Dspring.profiles.active=dev -Xmx512M -Xms128M -Djava.awt.headless=true -server</jvmArgs>
</configuration>
</plugin>
<!--maven-surefire-plugin-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<skip>false</skip>
<testFailureIgnore>false</testFailureIgnore>
<includes>
<include>**/*Test.java</include>
<include>**/*Tests.java</include>
</includes>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>application.properties</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<!--LOG-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!--Jstl-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package org.genesys2.gringlobal.taxonomy.config;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
import javax.servlet.MultipartConfigElement;
import javax.servlet.ServletRegistration;
/**
* Created by Lugovskoy Andrey.
*/
public class ApplicationInit extends AbstractAnnotationConfigDispatcherServletInitializer {
private static final long MAX_FILE_SIZE = Long.MAX_VALUE;
private static final long MAX_REQUEST_SIZE = 20971520;
private static final int FILE_SIZE_THRESHOLD = 0;
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class<?>[]{WebConfiguration.class};
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class<?>[]{WebConfiguration.class};
}
@Override
protected String[] getServletMappings() {
return new String[]{"/"};
}
@Override
protected void customizeRegistration(ServletRegistration.Dynamic registration) {
registration.setMultipartConfig(getMultipartConfigElement());
}
private MultipartConfigElement getMultipartConfigElement() {
MultipartConfigElement multipartConfigElement = new MultipartConfigElement("",
MAX_FILE_SIZE, MAX_REQUEST_SIZE, FILE_SIZE_THRESHOLD);
return multipartConfigElement;
}
}
package org.genesys2.gringlobal.taxonomy.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* Created by Lugovskoy Andrey.
*/
@Component
public class ApplicationProperties {
private String databaseFolderPath;
public String getDatabaseFolderPath() {
return databaseFolderPath;
}
@Value("${database.folder.path}")
public void setDatabaseFolderPath(String databaseFolderPath) {
this.databaseFolderPath = databaseFolderPath;
}
}
package org.genesys2.gringlobal.taxonomy.config;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
import java.util.Locale;
/**
* Created by Lugovskoy Andrey.
*/
@Configuration
@EnableWebMvc
@ComponentScan({"org.genesys2.gringlobal.taxonomy"})
public class WebConfiguration extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/WEB-INF/pages/**", "/WEB-INF/css/**", "/WEB-INF/js/**")
.addResourceLocations("/pages/", "/css/", "/js/");
}
@Bean
public InternalResourceViewResolver setupViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/pages/");
resolver.setSuffix(".jsp");
resolver.setViewClass(JstlView.class);
return resolver;
}
@Bean
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
final PropertyPlaceholderConfigurer propertyPlaceholderConfigurer = new PropertyPlaceholderConfigurer();
propertyPlaceholderConfigurer.setIgnoreResourceNotFound(true);
propertyPlaceholderConfigurer.setFileEncoding("utf-8");
propertyPlaceholderConfigurer.setLocations(new Resource[]{new ClassPathResource("application.properties")});
return propertyPlaceholderConfigurer;
}
@Bean(name = "localeResolver")
public CookieLocaleResolver getLocaleResolver() {
CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver();
cookieLocaleResolver.setDefaultLocale(new Locale("en"));
cookieLocaleResolver.setCookieMaxAge(100000);
return cookieLocaleResolver;
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
LocaleChangeInterceptor interceptor = new LocaleChangeInterceptor();
interceptor.setParamName("lang");
registry.addInterceptor(interceptor);
}
@Bean(name = "messageSource")
public ReloadableResourceBundleMessageSource getMessageSource() {
ReloadableResourceBundleMessageSource resource = new ReloadableResourceBundleMessageSource();
resource.setBasename("classpath:/messages");
resource.setCacheSeconds(1);
resource.setDefaultEncoding("UTF-8");
return resource;
}
}
package org.genesys2.gringlobal.taxonomy.controller;
import org.genesys2.gringlobal.taxonomy.component.TaxonomyException;
import org.genesys2.gringlobal.taxonomy.service.ProcessService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.text.ParseException;
import java.util.Locale;
/**
* Created by Lugovskoy Andrey.
*/
@Controller
public class ApplicationController {
private final static Logger LOG = LoggerFactory.getLogger(ApplicationController.class);
@Autowired
private ProcessService processService;
@RequestMapping(method = RequestMethod.GET)
public String get(Locale locale) {
return "index";
}
@RequestMapping(value = "process", method = RequestMethod.POST)
public String process(@RequestParam MultipartFile file,
@RequestParam(name = "separator", required = false, defaultValue = ",") String separator,
@RequestParam(name = "coyFromExcel", required = false, defaultValue = "") String coyFromExcel,
@RequestParam(name = "toCurrentTaxa", required = false) Boolean toCurrentTaxa,
ModelMap model) throws IOException, ParseException, TaxonomyException {
model.addAttribute("result", processService.process(file, separator, coyFromExcel, toCurrentTaxa));
return "result";
}
}
package org.genesys2.gringlobal.taxonomy.service;
import org.springframework.web.multipart.MultipartFile;
/**
* Created by Lugovskoy Andrey.
*/
public interface ProcessService {
/**
* Method parse csv.
* @return String result
*/
String process(MultipartFile file, String separator, String coyFromExcel, Boolean toCurrentTaxa);
}
package org.genesys2.gringlobal.taxonomy.service.impl;
import org.genesys2.gringlobal.taxonomy.config.ApplicationProperties;
import org.genesys2.gringlobal.taxonomy.service.ProcessService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
/**
* Created by Lugovskoy Andrey.
*/
@Service
public class ProcessServiceImpl implements ProcessService{
private final static Logger LOG = LoggerFactory.getLogger(ProcessServiceImpl.class);
@Autowired
private ApplicationProperties applicationProperties;
@Override
public String process(MultipartFile file, String separator, String coyFromExcel, Boolean toCurrentTaxa) {
LOG.info("Start process with file: '{}', separator: '{}', coyFromExcel: '{}', toCurrentTaxa: '{}'",
file.getOriginalFilename(), separator, coyFromExcel, toCurrentTaxa);
return "Parse result";
}
}
database.folder.path = taxonomy_data
\ No newline at end of file
#-------------------------------------------------------------------------------
# Copyright 2016 Global Crop Diversity Trust
#
# 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.
#-------------------------------------------------------------------------------
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.target=System.err
log4j.appender.stdout.encoding=UTF-8
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %t %5p %c{1}:%L - %m%n
### set log levels - for more verbose logging change 'info' to 'debug' ###
log4j.rootLogger=error, stdout
log4j.category.org.genesys2=warn
log4j.category.org.genesys2.gringlobal.taxonomy=info
label.coy.from.excel=Kopie von Excel
label.file=Datei
label.no=Nein
label.non.current.taxa=Nicht aktuell taxa
label.run.test=Lauf test
label.separator=Separator
label.title=Parse csv
label.yes=Ja
\ No newline at end of file
label.coy.from.excel=Copy from Excel
label.file=File
label.no=No
label.non.current.taxa=Non-current taxa
label.run.test=Run test
label.separator=Separator
label.title=Parse csv
label.yes=Yes
\ No newline at end of file
label.coy.from.excel= Excel
label.file=
label.no=
label.non.current.taxa=
label.run.test=
label.separator=
label.title=Parse csv
label.yes=
\ No newline at end of file
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<html>
<head>
<title><spring:message code="label.title"/></title>
</head>
<body>
<div>
<span style="float: right">
<a href="?lang=ru">ru</a>
|
<a href="?lang=en">en</a>
|
<a href="?lang=de">de</a>
</span>
</div>
<form id="process" action="process" method="POST" enctype="multipart/form-data">
<div>
<label for="file"><spring:message code="label.file"/>:</label>
<input id="file" type="file" name="file"/>
</div>
<br/>
<div>
<label for="file"><spring:message code="label.separator"/>:</label>
<input id="separator" name="separator" placeholder=","/>
</div>
<br/>
<div>
<label><spring:message code="label.coy.from.excel"/>:</label>
<textarea name="coyFromExcel" id="coyFromExcel"></textarea>
</div>
<br/>
<div>
<label><spring:message code="label.non.current.taxa"/>:</label></br>
<input type="radio" name="toCurrentTaxa" value="true"><spring:message code="label.yes"/> </br>
<input type="radio" name="toCurrentTaxa" value="false" checked><spring:message code="label.no"/>
</div>
<br/>
<div>
<button type="submit"><spring:message code="label.run.test"/></button>
</div>
</form>
</body>
</html>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title><spring:message code="label.title"/></title>
</head>
<body>
<h1>${result}</h1>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment