Commit e6dadf36 by ercsenyiandras

xxx

parents
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>telepules_CKANApplication3_JPA_inRepo</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.springframework.ide.eclipse.core.springbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.springframework.ide.eclipse.core.springnature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
eclipse.preferences.version=1
org.eclipse.jpt.core.platform=generic2_1
org.eclipse.jpt.jpa.core.discoverAnnotatedClasses=true
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
<root>
<facet id="jpt.jpa">
<node name="libprov">
<attribute name="provider-id" value="jpa-no-op-library-provider"/>
</node>
</facet>
</root>
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="cloudfoundry.standalone.app" version="1.0"/>
<installed facet="java" version="1.8"/>
<installed facet="jpt.jpa" version="2.1"/>
</faceted-project>
eclipse.preferences.version=1
org.jboss.ide.eclipse.as.core.singledeployable.deployableList=
package com.springjpa.repo;
import org.springframework.data.repository.CrudRepository;
import com.springjpa.model.County;
public interface CountyRepo extends CrudRepository<County, Long>, CountyRepoCustom{
County findByName(String name);
}
package com.springjpa.repo;
import com.springjpa.model.County;
public interface CountyRepoCustom {
public County saveSpec(County arg0) ;
public boolean createTable();
public void deleteTable();
}
package com.springjpa.repo;
import java.text.MessageFormat;
import org.springframework.beans.factory.annotation.Autowired;
import com.google.gson.JsonObject;
import com.springjpa.model.County;
import com.springjpa.persistence.DatastoreManager;
public class CountyRepoImpl implements CountyRepoCustom {
static final String FIELDS = "[ {\"id\": \"id\", \"type\": \"int\"}, {\"id\": \"name\", \"type\": \"text\"} ]";
static final String RECORD = "[ {\"id\": {0}, \"name\": \"{1}\"} ]"; //ebből lesz: [ {"id": 1, "name": "Heves megye"} ]
static final String TABLE = "megye";
static int ID = 1;
String resourceId;
/* CKAN-save lesz, aminek lényege, h REST-tel megy fel az adatbázisba :((
* @see com.springjpa.repo.CountyRepoCustom#saveSpec(com.springjpa.model.County)
*/
@Override
public County saveSpec(County arg) {
int id = (int)arg.getId();
String name = arg.getName();
//a fentiekből kell egy ilyen: [{"id": .. (nem kell idézőjel), "name": "..."}]
String records = createRecord(id, name);
String result = insertTableOf(TABLE, records);
County ret = getCounty(result);
return ret;
}
private County getCounty(String result) {
JsonObject jobject = getArray(result, 0);
County ret = new County();
ret.setId(jobject.get("id").getAsInt());
ret.setName(jobject.get("name").getAsString());
return ret;
}
private String createRecord(int id, String name) {
//innen: https://examples.javacodegeeks.com/core-java/text/messageformat/java-messageformat-example/
MessageFormat mf = new MessageFormat(RECORD);
Object[] objArray = {new Integer(id), name};
String record = mf.format(objArray);
return record;
}
@Override
public boolean createTable() {
boolean ret = true;
resourceId = createTableOf(FIELDS); //"[ {\"id\": \"id\", \"type\": \"int\"}, {\"id\": \"name\", \"type\": \"text\"} ]" );
if (resourceId == null) {
System.out.println("Nem sikerült az adatbázis létrehozása!");
ret = false;
}
if (ret) {
String check = renameResourceOf(resourceId, TABLE);
if (check == null) {
System.out.println("Nem sikerült az adatbázis-erőforrás átnevezése!");
ret = false;
}
}
return ret;
}
@Override
public void deleteTable() {
// TODO Auto-generated method stub
}
}
package com.springjpa.repo;
import org.springframework.data.repository.CrudRepository;
import com.springjpa.model.County;
public interface CountyRepository extends CrudRepository<County, Long>{
County findByName(String name);
}
//innen: http://www.tugay.biz/2016/06/spring-web-mvc-with-h2-database.html
package com.springjpa.persistence;
import javax.sql.DataSource;
import org.h2.server.web.WebServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
@Configuration
@ComponentScan(value = "hu.bme.spring")
public class DataSourceConfiguration {
@Autowired
Environment env;
@Bean
public DataSource dataSource() {
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("org.h2.Driver");
// dataSource.setUrl("jdbc:h2:mem:CKAN");
dataSource.setUrl("jdbc:h2:tcp://localhost//etc/CKAN");
dataSource.setUsername("sa");
dataSource.setPassword("");
return dataSource;
}
@Bean
public ServletRegistrationBean h2servletRegistration() {
ServletRegistrationBean registration = new ServletRegistrationBean(new WebServlet());
registration.addUrlMappings("/h2-console/*");
registration.setEnabled(true);
return registration;
}
}
\ No newline at end of file
package com.springjpa.persistence;
import java.util.Properties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
@Configuration
@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactory", transactionManagerRef = "transactionManager",
basePackages = {"com.springjpa.repo"})
public class DatabaseConfiguration extends DataSourceConfiguration {
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setGenerateDdl(true);
vendorAdapter.setShowSql(false);
LocalContainerEntityManagerFactoryBean entityManagerFactory =
new LocalContainerEntityManagerFactoryBean();
entityManagerFactory.setJpaVendorAdapter(vendorAdapter);
entityManagerFactory.setPackagesToScan("com.springjpa.model");
entityManagerFactory.setDataSource(dataSource());
entityManagerFactory.setJpaProperties(jpaProperties());
return entityManagerFactory;
}
@Bean
public JpaTransactionManager transactionManager() {
JpaTransactionManager txManager = new JpaTransactionManager();
txManager.setEntityManagerFactory(entityManagerFactory().getObject());
return txManager;
}
@Bean
public PersistenceExceptionTranslationPostProcessor persistenceExceptionTranslationPostProcessor() {
return new PersistenceExceptionTranslationPostProcessor();
}
// @Bean
// public DataSource dataSource() {
// //This uses JNDI, you could create the data source in any way you want
// try {
// Context initCtx = new InitialContext();
// Context envCtx = (Context) initCtx.lookup("java:comp/env");
// return (DataSource) envCtx.lookup("jdbc/yourDS");
// } catch (Exception e) {
// e.printStackTrace();
// throw new RuntimeException("Unable to lookup datasource", e);
// }
// }
private Properties jpaProperties() {
Properties props = new Properties();
props.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
return props;
}
}
package com.springjpa.repo;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@EnableTransactionManagement
@EnableAutoConfiguration
@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactory", transactionManagerRef = "transactionManager", basePackages = {
"com.springjpa.repo" })
public class RepositoryConfig {
@Autowired
JpaVendorAdapter jpaVendorAdapter;
@Autowired
DataSource dataSource;
@Bean(name = "entityManager")
public EntityManager entityManager() {
return entityManagerFactory().createEntityManager();
}
@Bean(name = "entityManagerFactory")
public EntityManagerFactory entityManagerFactory() {
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(dataSource);
emf.setJpaVendorAdapter(jpaVendorAdapter);
emf.setPackagesToScan("com.springjpa.model");
emf.setPersistenceUnitName("default"); // <- giving 'default' as name
emf.afterPropertiesSet();
return emf.getObject();
}
@Bean(name = "transactionManager")
public PlatformTransactionManager transactionManager() {
JpaTransactionManager tm = new JpaTransactionManager();
tm.setEntityManagerFactory(entityManagerFactory());
return tm;
}
}
\ No newline at end of file
package com.springjpa.repo;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import com.springjpa.model.County;
import com.springjpa.model.Town;
import com.springjpa.model.TownShip;
public interface TownRepository extends CrudRepository<Town, Long>{
List<Town> findByName(String name);
List<Town> findAll();
@Query("SELECT t.township FROM Town t INNER JOIN t.township ts WHERE ts.county.name = :county AND t.name = :town")
TownShip findByTown(@Param("town") String town, @Param("county") String county);
}
package com.springjpa.repo;
import java.util.List;
import org.springframework.data.repository.CrudRepository;
import com.springjpa.model.TownShip;
public interface TownShipRepository extends CrudRepository<TownShip, Long>{
List<TownShip> findByName(String name);
}
ez a jó hely:(és magyar)
http://stackoverflow.com/questions/40993532/converting-html-tables-to-bootstrap-columns-responsive-design
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.springjpa</groupId>
<artifactId>springJPA-postgreSQL</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>SpringJPA-PostgreSQL</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<hibernate.version>4.3.6.Final</hibernate.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.192</version>
</dependency>
<dependency>
<groupId>org.ckan.jdbc</groupId>
<artifactId>ckanjdbc</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- JPA -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
<!-- For connection pooling -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>${hibernate.version}</version>
</dependency>
<!-- ckan-jar miatt -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.1</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<!-- saját ckan-client -->
<dependency>
<groupId>org.ckan</groupId>
<artifactId>ckan</artifactId>
<version>2.1</version>
</dependency>
<!-- google elemeknek kell -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cloud-connectors</artifactId>
</dependency>
<!-- thymeleaf -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<description>1. Adott telepulesre megmondja, h melyik megye (megye-szekhellyel), melyik jaras (jaras-szekhellyel)
2. Terkepre teszi a telepulest, megye- ill. jaras-szekhelyet, ami adott esetben egy es uaz. is lehet :)
3. Kiirja a jaras tobbi telepulesenek nevet (valtozo oszlopszammal).
Mobile-friendly kialakitasu.
Technikailag CKAN-Datastore-t hasznal, mégpedig úgy, hogy van egy CkanJdbcDriver, amivel a JPA működik.</description>
</project>
package com.springjpa.model;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "\"ca33d78d-ab3e-45a0-a97b-bdfaed227274\"")
public class School implements Serializable {
private static final long serialVersionUID = -3009157732242241606L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(name = "pos")
private int pos;
@Column(name = "zip", length=4)
private String zip;
@Column(name = "name", length=100)
private String name;
@Column(name = "comp_m")
private int comp_m;
@Column(name = "comp_s")
private int comp_s;
public School() {
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public int getPos() {
return pos;
}
public void setPos(int pos) {
this.pos = pos;
}
public String getZip() {
return zip;
}
public void setZip(String zip) {
this.zip = zip;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getComp_m() {
return comp_m;
}
public void setComp_m(int comp_m) {
this.comp_m = comp_m;
}
public int getComp_s() {
return comp_s;
}
public void setComp_s(int comp_s) {
this.comp_s = comp_s;
}
public void setAll(int pos, int zip, String name, int mat, int scr) {
this.pos = pos;
this.zip = "" + zip;
this.name = name;
this.comp_m = mat;
this.comp_s = scr;
}
@Override
public String toString() {
return String.format("%d. irsz='%s' név='%s' matek='%d' szöveg='%d'", pos, zip, name, comp_m, comp_s);
}
}
package com.springjpa.repo;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import com.springjpa.model.School;
public interface SchoolRepository extends CrudRepository<School, Long>{
List<School> findByName(String name);
public List<School> findAll();
@Query("SELECT t FROM School t WHERE t.id = :id")
public School findOne(@Param("id") long id);
// @Query("SELECT ts FROM TownShip ts WHERE ts.county.id = :id")
// /** A megyéhez tartozó összes járás
// * @param id
// * @return
// */
// public School findAllForCounty(@Param("id") long id);
}
package com.springjpa;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.CriteriaSpecification;
import org.hibernate.criterion.Restrictions;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.springjpa.model.County;
import com.springjpa.model.Town;
import com.springjpa.model.TownShip;
import com.springjpa.repo.CountyRepository;
import com.springjpa.repo.TownRepository;
import com.springjpa.repo.TownShipRepository;
@RunWith(SpringRunner.class)
@SpringBootTest
public class SpringJpaApplicationIntelligentTests {
@Autowired
private SessionFactory sessionFactory;
@Autowired
private TownRepository townRepo;
@Autowired
private TownShipRepository tsRepo;
@Autowired
private CountyRepository countyRepo;
@BeforeClass
public static void init() {
}
@Ignore
@Test
public void contextLoads() {
}
@Test
public void testTownsAll() {
System.out.println("\n-----testTownsAll---------");
List<Town> towns = townRepo.findAll();
for (Town town : towns) {
System.out.println(town);
}
}
@Ignore
@Test
public void testCountiesAll() {
System.out.println("\n-----testCountiesAll---------");
List<County> counties = countyRepo.findAll();
for (County county : counties) {
System.out.println(county.getName());
}
}
@Ignore
//select varos.* FROM TELEPULES2 varos join JARAS2 jaras ON jaras.id = varos.ts_id WHERE jaras.cityname = 'Mohács'
@Test
public void testTownsInTownship() {
System.out.println("\n-----testTownsInTownship: Mohácsi járás---------");
Session session = sessionFactory.openSession();
Criteria c = session.createCriteria(Town.class, "varos");
c.createAlias("varos.township", "jaras");
c.add(Restrictions.eq("jaras.cityname", "Mohács"));
c.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
List<Town> list = c.list();
if (!list.isEmpty())
for (Town town : list) {
System.out.println(town);
}
else
System.out.println("--üres--");
}
@Ignore
//select jaras.* FROM JARAS2 jaras join TELEPULES2 telepules ON telepules.ts_id = jaras.id WHERE telepules.name = 'Hímesháza'
/** Település alapján keressük az járást a megyében
* @param address benne megye és településnév
* @param plus az itteni szöveg ("- összes megye - ") is lehet a megye értéke
* @return
*/
@Test
public void testTownshipByTown() {
System.out.println("\n-----testTownshipByTown---------");
Session session = sessionFactory.openSession();
Criteria c = session.createCriteria(TownShip.class, "jaras");
c.createAlias("jaras.towns", "telepules");
c.add(Restrictions.eq("telepules.name", "Basal"));
c.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
List<TownShip> list = c.list();
if (!list.isEmpty())
System.out.println(list.get(0));
else
System.out.println("--üres--");
}
@Ignore
@Test
public void testTownShipsAll() {
System.out.println("\n-----testTownShipsAll---------");
List<TownShip> tss = tsRepo.findAll();
for (TownShip ts : tss) {
System.out.println(ts);
}
}
@Ignore
@Test
public void testTownsInTownship0() {
System.out.println("\n-----testTownsInTownship0: Mohácsi járás---------");
List<TownShip> tss = tsRepo.findByName("Mohácsi Járási Hivatal");
for (TownShip ts : tss) {
System.out.println(ts);
}
long ts_id = tss.get(0).getId();
// long ts_id = 6;
List<Town> list = townRepo.findAllForTS(ts_id);
if (!list.isEmpty())
for (Town town : list) {
System.out.println(town);
}
else
System.out.println("--üres--");
}
@Ignore
@Test
public void testTownsInCountry() {
System.out.println("\n-----testTownsInCountry---------");
String NAME = "Ercsi";
TownShip ret;
List<County> counties = countyRepo.findAll();
for (County county : counties) {
ret = townRepo.findByTownAndCounty(NAME, county.getName());
if (ret != null) {
System.out.println(NAME + " ---> " + ret);
break;
}
}
}
@Ignore
@Test
public void testTownShipsOfTown() {
System.out.println("\n-----testTownShipsOfTown---------");
TownShip ts = townRepo.findByTownAndCounty("Ercsi", "Baranya megye");
System.out.println(ts);
for (Town town : ts.getTowns()) {
System.out.println("\t" + town);
}
}
@Ignore
@Test
public void testTownsOfCounty() {
System.out.println("\n-----testTownsOfCounty---------");
int ID = 7;
List<Town> ret = new ArrayList<>();
List<TownShip> tss = tsRepo.findAllForCounty(ID);
for (TownShip ts : tss) {
List<Town> towns = townRepo.findAllForTS(ts.getId());
for(Town town : towns) {
ret.add(town);
}
}
System.out.println("Megye = " + ID);
for (Town town : ret) {
System.out.println("\t" + town);
}
}
}
package com.springjpa;
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.springjpa.model.County;
import com.springjpa.model.Town;
import com.springjpa.model.TownShip;
import com.springjpa.repo.CountyRepository;
import com.springjpa.repo.TownRepository;
import com.springjpa.repo.TownShipRepository;
@RunWith(SpringRunner.class)
@SpringBootTest
public class SpringJpaApplicationTests {
@Autowired
private TownRepository townRepo;
@Autowired
private TownShipRepository tsRepo;
@Autowired
private CountyRepository countyRepo;
@BeforeClass
public static void init() {
}
@Ignore
@Test
public void contextLoads() {
}
@Ignore
@Test
public void testTownsAll() {
System.out.println("\n-----testTownsAll---------");
List<Town> towns = townRepo.findAll();
for (Town town : towns) {
System.out.println(town);
}
}
@Ignore @Test
public void testTownsInCountry() {
System.out.println("\n-----testTownsInCountry---------");
String NAME = "Ercsi";
TownShip ret;
List<County> counties = countyRepo.findAll();
for (County county : counties) {
ret = townRepo.findByTownAndCounty(NAME, county.getName());
if (ret != null) {
System.out.println(NAME + " ---> " + ret);
break;
}
}
}
@Test //mert rossz a megye :))
public void testTownShipOfTown() {
System.out.println("\n-----testTownShipOfTown---------");
try{
TownShip ts = townRepo.findByTownAndCounty("Ercsi", "Baranya megye");
System.out.println(ts);
System.out.println(ts);
for (Town town : ts.getTowns()) {
System.out.println("\t" + town);
}
} catch(Exception ex) {
assertThat(ex.getMessage(), containsString("bad"));
}
fail("expected SQLException because of bad county-name");
}
@Test
public void testTownShipOfTown2() {
System.out.println("\n-----testTownShipOfTown2---------");
try{
TownShip ts = townRepo.findByTown("Ercsi");
System.out.println(ts);
System.out.println(ts);
for (Town town : ts.getTowns()) {
System.out.println("\t" + town);
}
} catch(Exception ex) {
assertThat(ex.getMessage(), containsString("bad"));
}
}
@Ignore @Test
public void testTownsOfCounty() {
System.out.println("\n-----testTownsOfCounty---------");
int ID = 7;
List<Town> ret = new ArrayList<>();
List<TownShip> tss = tsRepo.findAllForCounty(ID);
for (TownShip ts : tss) {
List<Town> towns = townRepo.findAllForTS(ts.getId());
for(Town town : towns) {
ret.add(town);
}
}
System.out.println("Megye = " + ID);
for (Town town : ret) {
System.out.println("\t" + town);
}
}
}
package com.springjpa.persistence;
import java.util.List;
import com.springjpa.io.AddressForm;
import com.springjpa.model.Town;
import com.springjpa.model.TownShip;
public interface TableMethods {
/** Visszaadja az öszes megye nevét, de a lista végéhez hozzábiggyeszti a plus-t, ami ilyen "- összes megye -"
* @param plus
* @return
*/
List<String> getAllCountyNames(String plus);
/** Beállítja az aktuális megyét sorszáma alapján
* @param id
*/
void setCountyById(long id);
/** Beállítja az aktuális megyét név szerint
* @param district itt a megye neve
* @param plus az itteni szöveg ("- összes megye - ") is lehet a district értéke
*/
void setCountyByName(String district, String plus);
/** Az aktuáluis megyeszámot kitörli
*
*/
void deleteCounty();
/** Az aktuális megye össze települését adja vissza
* @return
*/
List<Town> getCityList();
/** Település alapján keressük az járást a megyében
* @param address benne megye és településnév
* @param plus az itteni szöveg ("- összes megye - ") is lehet a megye értéke
* @return
*/
TownShip getTownShipOf(AddressForm address, String plus);
/** Ellenőrzi, h van-e azonos nevű település az országban (pl. ékezethiba miatt)
* @return
*/
boolean checkAllTowns();
/** Megnézi, h megvan-e mind a 3 tábla: megye, járás, település
* @return meglevő táblák száma; ha 3, akkor teljesen jó
*/
int checkTables();
}
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="DEV_HOME" value="/home/cloud/CKAN/telepulesek/log" />
<appender name="FILE-AUDIT"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${DEV_HOME}/debug.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} - %msg%n
</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>${DEV_HOME}/archived/debug.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<logger name="com.springjpa" level="debug" additivity="false">
<appender-ref ref="FILE-AUDIT" />
</logger>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="cts-pu" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<!-- add classes -->
<class>com.springjpa.model.County</class>
<class>com.springjpa.model.Town</class>
<class>com.springjpa.model.TownShip</class>
<properties>
<!-- JDBC properties -->
<property name="javax.persistence.jdbc.url" value="jdbc:ckan:rest:vm.ik.bme.hu:10851/hu/api/3?apikey=485baae6-5394-4af9-a76a-cbd1b902bfb0"/>
<property name="javax.persistence.jdbc.driver" value="hu.bme.ckan.jdbc.rest.CkanDriver"/>
<!-- <property name="javax.persistence.jdbc.user" value="sa"/> -->
<!-- <property name="javax.persistence.jdbc.password" value=""/> -->
<!-- <property name="javax.persistence.jdbc.apikey" value="485baae6-5394-4af9-a76a-cbd1b902bfb0"/> -->
<!-- Hibernate properties -->
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<!-- ez ki kell venni, mert különben hibát ír ki -->
<!-- <property name="hibernate.hbm2ddl.auto" value="update"/> -->
<property name="hibernate.format_sql" value="false"/>
<property name="hibernate.show_sql" value="false"/>
</properties>
</persistence-unit>
</persistence>
\ No newline at end of file
package com.springjpa;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Description;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.orm.jpa.vendor.HibernateJpaSessionFactoryBean;
import org.thymeleaf.templateresolver.ServletContextTemplateResolver;
@SpringBootApplication
public class SpringJpaApplication {
public static void main(String[] args) {
SpringApplication.run(SpringJpaApplication.class, args);
}
@Bean
@Description("Thymeleaf template resolver serving HTML 5")
public ServletContextTemplateResolver templateResolver() {
ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver();
templateResolver.setCacheable(false);
templateResolver.setTemplateMode("HTML5");
templateResolver.setCharacterEncoding("UTF-8");
templateResolver.setPrefix("classpath*:templates/");
templateResolver.setSuffix(".html");
return templateResolver;
}
//
// @Bean
// @Description("Thymeleaf template engine with Spring integration")
// public SpringTemplateEngine templateEngine() {
// SpringTemplateEngine templateEngine = new SpringTemplateEngine();
//// templateEngine.addDialect(new SpringSecurityDialect());
//// templateEngine.addDialect(new LayoutDialect(new GroupingStrategy()));
// templateEngine.setTemplateResolver(templateResolver());
//
// return templateEngine;
// }
//
// @Bean
// @Description("Thymeleaf view resolver")
// public ViewResolver viewResolver() {
//
// ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
// viewResolver.setTemplateEngine(templateEngine());
// viewResolver.setCharacterEncoding("UTF-8");
// viewResolver.setCache(false);
// viewResolver.setOrder(1);
//
// return viewResolver;
// }
//templates-ek innen: http://stackoverflow.com/questions/39262370/spring-boot-how-to-correctly-define-template-locations
//innen: http://stackoverflow.com/questions/36545667/spring-boot-thymeleaf-not-finding-message-properties
@Bean
public MessageSource messageSource() {
final ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasenames("classpath:/i18n/messages");
messageSource.setUseCodeAsDefaultMessage(true);
messageSource.setDefaultEncoding("UTF-8");
messageSource.setCacheSeconds(5);
return messageSource;
}
//innen: http://stackoverflow.com/questions/29226099/access-sessionfactory-from-spring-boot-application
@Bean
public HibernateJpaSessionFactoryBean sessionFactory() {
return new HibernateJpaSessionFactoryBean();
}
}
package com.springjpa.controller;
//innen: http://javainsimpleway.com/spring-mvc-form-validation-with-custom-validator/
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;
import com.springjpa.io.AddressForm;
import com.springjpa.model.Town;
import com.springjpa.repo.TownRepository;
@Component
public class AddressFromValidator implements Validator {
@Autowired
TownRepository townRepo;
private AddressForm addressNormed;
@Override
public boolean supports(Class<?> clazz) {
return AddressForm.class.isAssignableFrom(clazz);
}
@Override
public void validate(Object target, Errors errors) {
AddressForm addr = (AddressForm)target;
String city = StringUtils.trimToNull(addr.getCity());
addressNormed = new AddressForm();
addressNormed.setCity(city);
//településnév
if (city == null)
errors.rejectValue("city", "ERROR_NOT_DEFINED", "A településnév nem lehet üres.");
else
try {
List<Town> towns = townRepo.findByName(city);
if (towns == null || towns.isEmpty() || towns.size() > 1) errors.rejectValue("city", "ERROR_NOT_DEFINED", "Érvénytelen a településnév.");
} catch (Exception e) {
// System.out.println(e); //IndexOutOfBoundException
//nem tudom, h miért kell a 2. param, de így jó :))
boolean letters = city.chars().allMatch(Character::isLetter);
errors.rejectValue("city", "ERROR_NOT_DEFINED", letters
? "Nincs az országban ilyen nevű település."
: "Érvénytelen karakter(ek) a településnévben." );
}
}
public AddressForm getNormed() {
return addressNormed;
}
}
package com.springjpa.controller;
public class SearchBean {
private String label;
private String value;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getValue() {
return value;
}
public void setValue(String id) {
this.value = id;
}
}
package com.springjpa.google;
import java.util.List;
import org.codehaus.jackson.annotate.JsonProperty;
class AddressComponent {
@JsonProperty("long_name")
private String longName;
@JsonProperty("short_name")
private String shortName;
private List<String> types;
public String getLongName() {
return longName;
}
public void setLongName(String longName) {
this.longName = longName;
}
public String getShortName() {
return shortName;
}
public void setShortName(String shortName) {
this.shortName = shortName;
}
public List<String> getTypes() {
return types;
}
public void setTypes(List<String> types) {
this.types = types;
}
}
\ No newline at end of file
package com.springjpa.google;
import org.codehaus.jackson.annotate.JsonProperty;
class Geometry {
private Location location;
@JsonProperty("location_type")
private String locationType;
@JsonProperty("viewport")
private ViewPort viewPort;
private ViewPort bounds;
public Location getLocation() {
return location;
}
public void setLocation(Location location) {
this.location = location;
}
public String getLocationType() {
return locationType;
}
public void setLocationType(String locationType) {
this.locationType = locationType;
}
public ViewPort getViewPort() {
return viewPort;
}
public void setViewPort(ViewPort viewPort) {
this.viewPort = viewPort;
}
public ViewPort getBounds() {
return bounds;
}
public void setBounds(ViewPort bounds) {
this.bounds = bounds;
}
}
//class-okat innen vettem: http://stackoverflow.com/questions/19891455/java-how-to-parse-json-for-geolocation
package com.springjpa.google;
import java.util.Arrays;
import java.util.List;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.cloud.cloudfoundry.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import com.springjpa.io.Address;
@Service
public class GoogleMapClient {
private static final String REST_SERVICE_URL = "https://maps.googleapis.com/maps/api/geocode/json?address=";
private static final String KEY = "&key=AIzaSyDGgDthmnjFGGla6vWFTBF-BgU_O0_JXQk";
private RestTemplate restTemplate = new RestTemplate();
public LatLon getCoord(Address address) {
Address ret = _getCoordAndZip(address, false);
return ret != null ? ret.getGps() : null;
}
public Address getCoordAndZip(Address address) {
return _getCoordAndZip(address, true);
}
@JsonIgnoreProperties(ignoreUnknown = true)
public Address _getCoordAndZip(Address address, boolean zipToo) {
String city = address.getCity();
String county = address.getCounty();
Address ret = new Address();
// LatLon ret1 = null;
// String ret2 = null;
//ez a minta: http://maps.googleapis.com/maps/api/geocode/json?address=Cigánd,HU
//address a vesszőig, HU automatikusan bemegy
//http://maps... fix cím
try {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
HttpEntity<String> entity = new HttpEntity<String>(headers);
//System.out.println(REST_SERVICE_URL + city + "," + county + ", HU");
// "Cigánd" "Heves megye"
ResponseEntity<String> result = restTemplate.exchange(REST_SERVICE_URL + city + "," + county + ",HU" + KEY, HttpMethod.GET, entity, String.class);
//System.out.println(result);
ObjectMapper mapper = new ObjectMapper();
// System.out.println(result.getBody());
Root root = mapper.readValue(result.getBody(), Root.class);
for (Result res : root.getResults()) {
List<AddressComponent> comps = res. getAddressComponents();
if (zipToo) {
for (AddressComponent comp : comps) {
String zip = getPostalCode(comp);
if (zip != null) {
System.out.print(address.getFull() + "==>");
ret.setZip(zip);
System.out.println(zip);
break;
}
}
}
if (isGoodDistrict(comps, city /*address.getDistrict()*/)) {
// System.out.print(address.getFull() + "==>");
double lat = Double.parseDouble(res.getGeometry().getLocation().getLat());
double lon = Double.parseDouble(res.getGeometry().getLocation().getLng());
// System.out.print(" lat = " + lat);
// System.out.print(" lon = " + lon);
// System.out.println();
if (Math.abs(lat) > 0.001d && Math.abs(lon) > 0.001d)
ret.setGps(new LatLon(lat, lon));
}
}
} catch (Exception e) {
System.out.println(e);
ret = null;
System.out.println(address.getFull() + ", HU" + " ->hiba");
}
return ret;
}
private String getPostalCode(AddressComponent comp) {
for (String type : comp.getTypes()) {
if ("postal_code".equals(type)) return comp.getLongName();
}
return null;
}
private String getAddress(String zip, String street, String number) {
String ret = zip + " ";
ret += "Budapest" + " ";
ret += street + " ";
ret += number;
return ret;
}
private boolean isGoodDistrict(List<AddressComponent> comps, String name) {
boolean ret = false;
for (AddressComponent comp : comps) {
if (name.equals(comp.getLongName()))
return true;
}
return ret;
}
/*
public static void main(String[] args) {
String city = "Balaton";
String county = "Heves megye";
Address address = new Address();
address.setCity(city);
address.setCounty(county);
// address.setZip(zipcode);
GoogleMapClient client = new GoogleMapClient();
Address ok = client.getCoordAndZip(address);
System.out.println(address.getFull() + "-->" + ok.getFull());
}
*/
}
package com.springjpa.google;
public class LatLon {
private double lat;
private double lon;
public LatLon(){
}
public LatLon(double lat, double lon){
this.lat = lat;
this.lon = lon;
}
public double getLat() {
return lat;
}
public void setLat(double lat) {
this.lat = lat;
}
public double getLon() {
return lon;
}
public void setLon(double lon) {
this.lon = lon;
}
public String toString() {
String ret = "";
ret += " " + this.getLat();
ret += "/" + this.getLon();
return ret;
}
}
package com.springjpa.google;
class Location {
private String lat;
private String lng;
public String getLat() {
return lat;
}
public void setLat(String lat) {
this.lat = lat;
}
public String getLng() {
return lng;
}
public void setLng(String lng) {
this.lng = lng;
}
}
package com.springjpa.google;
import java.util.List;
import org.codehaus.jackson.annotate.JsonProperty;
class Result {
@JsonProperty("address_components")
private List<AddressComponent> addressComponents;
@JsonProperty("formatted_address")
private String formattedAddress;
private Geometry geometry;
private List<String> types;
private boolean partial_match;
private String place_id;
public boolean isPartial_match() {
return partial_match;
}
public void setPartial_match(boolean partial_match) {
this.partial_match = partial_match;
}
public String getPlace_id() {
return place_id;
}
public void setPlace_id(String place_id) {
this.place_id = place_id;
}
public List<AddressComponent> getAddressComponents() {
return addressComponents;
}
public void setAddressComponents(List<AddressComponent> addressComponents) {
this.addressComponents = addressComponents;
}
public String getFormattedAddress() {
return formattedAddress;
}
public void setFormattedAddress(String formattedAddress) {
this.formattedAddress = formattedAddress;
}
public Geometry getGeometry() {
return geometry;
}
public void setGeometry(Geometry geometry) {
this.geometry = geometry;
}
public List<String> getTypes() {
return types;
}
public void setTypes(List<String> types) {
this.types = types;
}
}
\ No newline at end of file
package com.springjpa.google;
import java.util.List;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown=true)
class Root {
private List<Result> results;
private String status;
public List<Result> getResults() {
return results;
}
public void setResults(List<Result> results) {
this.results = results;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}
package com.springjpa.google;
class ViewPort {
private Location northeast;
private Location southwest;
public Location getNortheast() {
return northeast;
}
public void setNortheast(Location northeast) {
this.northeast = northeast;
}
public Location getSouthwest() {
return southwest;
}
public void setSouthwest(Location southwest) {
this.southwest = southwest;
}
}
package com.springjpa.io;
import com.springjpa.google.LatLon;
public class Address extends AddressForm {
protected String zip = "";
protected LatLon gps;
public Address() {
}
public Address(String county, String city) {
this.city = city;
this.county = county;
}
public String getZip() {
return zip;
}
public void setZip(String zip) {
this.zip = zip;
}
public LatLon getGps() {
return gps;
}
public void setGps(LatLon gps) {
LatLon x = new LatLon();
if (gps != null) {
x.setLat(gps.getLat());
x.setLon(gps.getLon());
}
this.gps = x;
}
public void modGps(double dlat, double dlon) {
this.gps.setLat(this.gps.getLat() + dlat);
this.gps.setLon(this.gps.getLon() + dlon);
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getCounty() {
return county;
}
public void setCounty(String county) {
this.county = county;
}
/**
* @return "1134 Budapest XIII. BP" VAGY "2081 Budaörs Pest megye 18.343567/34.98765"
*/
public String getFull() {
String ret = "";
if (this.zip != "") ret += this.zip + " ";
ret += this.city + " ";
ret += this.county;
if (gps != null) {
// ret += " " + gps.getLat();
// ret += "/" + gps.getLon();
ret += " " + gps.toString();
}
return ret;
}
public String toString() {
return this.getFull();
}
}
package com.springjpa.io;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
public class AddressForm {
// @NotNull
//innen: http://forum.spring.io/forum/spring-projects/roo/65364-roo-jsr-303-validations-and-localization
// @Size(min=2, max=5, message="A beírás hossza minimum {min}, maximum {max} karakter, mint pl. XII vagy 1124")
protected String county;
@NotNull
@Size(min=3, max=30, message="A település nevét kell beírni, aminek hossza minimum {min}, maximum {max} karakter, mint pl. Mohács")
protected String city;
/** A beírtakról levágjuk a felesleges space-eket.
*
*/
public void normalize() {
if (city != null) city = city.trim();
}
public String getCounty() {
return county;
}
public void setCounty(String county) {
this.county = county;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String toString() {
return this.city + ", " + this.county;
}
}
\ No newline at end of file
package com.springjpa.json;
public class Key {
//{"name":"Baranyajeno"}
private String key; //de ez változhat: "name"
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
}
package com.springjpa.json;
public class KeyInt extends Key {
//{"id":"5"}
//stringként kell, bár számérték!!!
private String id; //ez lehet: "id", "ts_id", "county_id", stb.
public int getId() {
return Integer.parseInt(id);
}
public void setId(int id) {
this.id = String.valueOf(id);
}
}
package com.springjpa.json;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
public class Query {
//{"resource_id":"8a0c31ee-0c36-450f-96e7-8bbfe967ae22","q":{"name":"Nemeske"},"limit":1000,"sort":"name"}
private String resource_id;
private Key q;
private int limit; //string legyen!!!
private String sort; //vesszővel több is
private Boolean distinct;
private String fields; //,-vel több is
public String getResource_id() {
return resource_id;
}
public void setResource_id(String resource_id) {
this.resource_id = resource_id;
}
public Key getQ() {
return q;
}
public void setQ(Key q) {
this.q = q;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
public String getSort() {
return sort;
}
public void setSort(String sort) {
this.sort = sort;
}
}
package com.springjpa.json;
public class Rename {
//{"id": "...", "name": "..."}
private String id;
private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package com.springjpa.model;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
//@Table(name="megye2")
@Table(name="\"c63e6780-4f9b-494f-b456-8cf86251929c\"")
public class County implements java.io.Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(name="name", length=100, unique=true)
private String name;
@Column(name="cityname", length=100, unique=true)
private String cityname;
// @OneToMany(fetch=FetchType.EAGER) //(cascade = {CascadeType.PERSIST})
// @JoinTable(
// name="Megye_Jarasok",
// joinColumns = @JoinColumn( name="county_id"),
// inverseJoinColumns = @JoinColumn( name="ts_id")
// )
@OneToMany(cascade = CascadeType.ALL, mappedBy = "county", fetch=FetchType.LAZY)
private Set<TownShip> townships = new HashSet<>(0);
public County() {
}
public County(String name) {
this.name = name;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCityname() {
return cityname;
}
public void setCityname(String cityname) {
this.cityname = cityname;
}
public Set<TownShip> getTownShips() {
return townships;
}
public void setTownShips(Set<TownShip> tss) {
townships = tss;
}
public void setTownShips(List<TownShip> tss) {
townships = new HashSet(tss);
}
public void addTownShip(TownShip ts) {
townships.add(ts);
}
public String toString() {
return "MEGYE " + this.name + " " + (this.townships == null || this.townships.isEmpty() ? "null" : this.townships.size());
}
public String getNames() {
return this.getName() + "/" + this.getCityname();
}
}
package com.springjpa.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
//@Table(name="telepules2")
@Table(name="\"9419355b-4322-437e-8e5f-33bea21e3b00\"")
public class Town implements java.io.Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(name="name", length=100, unique=true)
private String name;
@ManyToOne
// @JoinColumn(name = "ts_id", nullable = false)
@JoinColumn(name="ts_id")
private TownShip township;
public Town() {
}
public Town(String name) {
this.name = name;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public TownShip getTownship() {
return township;
}
public void setTownship(TownShip township) {
this.township = township;
}
public String toString() {
return "TELEPÜLÉS " + this.name + "/" + (this.township == null ? "null" : this.township.getName());
}
}
package com.springjpa.model;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
//@Table(name="jaras2")
@Table(name="\"26bf4d5b-2b92-41cb-9b28-394aed57344f\"")
public class TownShip implements java.io.Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(name="name", length=100, unique=true)
private String name;
@Column(name="cityname", length=100, unique=true)
private String cityname;
// @OneToMany(fetch=FetchType.EAGER) //(cascade = {CascadeType.PERSIST})
// @JoinTable(
// name="Jaras_Telepulesek",
// joinColumns = @JoinColumn( name="ts_id"),
// inverseJoinColumns = @JoinColumn( name="town_id")
// )
@OneToMany(cascade = CascadeType.ALL, mappedBy = "township", fetch = FetchType.EAGER)
private Set<Town> towns = new HashSet<Town>(0);
@ManyToOne(fetch=FetchType.LAZY)
// @JoinColumn(name = "county_id", nullable = false)
@JoinColumn(name="county_id")
private County county;
public TownShip() {
}
public TownShip(String name) {
this.name = name;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<Town> getTowns() {
return towns;
}
public Set<String> getTownNames() {
Set<String> ret = new HashSet<>();
for (Town town : this.towns) {
ret.add(town.getName());
}
return ret;
}
public void setTowns(Set<Town> towns) {
this.towns = towns;
}
public void addTown(Town town) {
this.towns.add(town);
}
public County getCounty() {
return county;
}
public void setCounty(County county) {
this.county = county;
}
public String getCityname() {
return cityname;
}
public void setCityname(String cityname) {
this.cityname = cityname;
}
public String toString() {
return "JÁRÁS " + this.name + "/" + this.cityname + " " + (this.towns == null || this.towns.isEmpty() ? "null" : this.towns.size());
}
public String getNames() {
return this.getName() + "/" + this.getCityname();
}
}
package com.springjpa.persistence;
import java.util.List;
import com.springjpa.io.AddressForm;
import com.springjpa.model.Town;
import com.springjpa.model.TownShip;
public interface TableRepo {
/** Visszaadja az öszes megye nevét, de a lista végéhez hozzábiggyeszti a plus-t, ami ilyen "- összes megye -"
* @param plus
* @return
*/
List<String> getAllCountyNames(String plus);
/** Beállítja az aktuális megyét sorszáma alapján
* @param id
*/
void setCountyById(long id);
/** Beállítja az aktuális megyét név szerint
* @param district itt a megye neve
* @param plus az itteni szöveg ("- összes megye - ") is lehet a district értéke
*/
void setCountyByName(String district, String plus);
/** Az aktuáluis megyeszámot kitörli
*
*/
void deleteCounty();
/** Az aktuális megye össze települését adja vissza
* @return
*/
List<Town> getCityList();
/** Az aktuális megye össze települését adja vissza
* @return
*/
List<String> getCountyNames();
/** Település alapján keressük az járást a megyében
* @param address benne megye és településnév
* @param plus az itteni szöveg ("- összes megye - ") is lehet a megye értéke
* @return
*/
TownShip getTownShipOf(AddressForm address, String plus);
/** Ellenőrzi, h van-e azonos nevű település az országban (pl. ékezethiba miatt)
* @return
*/
boolean checkAllTowns();
/** Megnézi, h megvan-e mind a 3 tábla: megye, járás, település
* @return meglevő táblák száma; ha 3, akkor teljesen jó
*/
int checkTables();
}
package com.springjpa.persistence;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;
import com.springjpa.io.AddressForm;
import com.springjpa.model.County;
import com.springjpa.model.Town;
import com.springjpa.model.TownShip;
import com.springjpa.repo.CountyRepository;
import com.springjpa.repo.TownRepository;
import com.springjpa.repo.TownShipRepository;
@Component
@ComponentScan(value = "com.springjpa")
public class TableRepositoryImpl implements TableRepo {
@Autowired
private TownRepository townRepo;
@Autowired
private TownShipRepository tsRepo;
@Autowired
private CountyRepository countyRepo;
private String county;
private long countyId; //ha 0, akkor az összes település
private static List<String> countyNames;
private static List<Town> townAll;
private List<Town> cities;
@Override
/** Kibővítés a VÉGÉRE!!!
* @param plus pl. "összes megye"
* @return
*/
public List<String> getAllCountyNames(String plus) {
List<String> ret = this.getAllCountyNames();
ret.add(plus);
return ret;
}
private List<String> getAllCountyNames() {
countyNames = new ArrayList<>();
for(County county : countyRepo.findAll()) {
countyNames.add(county.getName());
}
return countyNames;
}
@Override
public void setCountyById(long id) {
if (id == 0){
System.out.println("megye = " + "mind");
this.countyId = 0;
cities = townAll;
System.out.println("országos település adatok KÉSZ!");
} else {
System.out.println("megye = " + id);
this.countyId = id;
cities = countyRepo.findAllForCounty(id); //getTownsOf(id);
System.out.println("megyei település adatok KÉSZ!");
}
}
@Override
/** Település alapján keressük az járást a megyében
* @param address benne megye és településnév
* @param plus az itteni szöveg ("- összes megye - ") is lehet a megye értéke
* @return
*/
public TownShip getTownShipOf(AddressForm address, String plus) {
TownShip ret = null;
// if (plus.equals(address.getCounty())) {
//"összes megye" van kijelölve --> keressük a megyét
for (String county : countyNames) {
ret = townRepo.findByTown(address.getCity());
if (ret != null) {
address.setCounty(ret.getCounty().getName());
break;
}
}
// } else {
// ret = townRepo.findByTown(address.getCity());
// }
return ret;
}
@Override
public List<Town> getCityList() {
return cities;
}
@Override
public List<String> getCountyNames() {
return countyNames;
}
@Override
public void setCountyByName(String name, String plus) {
if (plus.equals(name)) {
//System.out.println("megye = " + "mind");
// this.countyId = 0;
// cities = townAll; //getTownsOfAll();
//System.out.println("országos település adatok KÉSZ!");
setCountyById(0);
} else {
// County county = countyRepo.findByName(name);
// setCountyById(county.getId());
setCountyById(countyRepo.getIdByName(name));
}
}
@Override
public void deleteCounty() {
// TODO Auto-generated method stub
}
@Override
public boolean checkAllTowns() {
Set<String> set = new HashSet<>();
// townAll = townRepo.findAll();
// int i = 1;
// for (Town town : townAll) {
// set.add(town.getName());
// i++;
// if (i % 100 == 0) System.out.println(i + " ...");
// }
// return (townAll.size() != set.size());
townAll = new ArrayList<>();
List<County> counties = countyRepo.findAll();
for (County county : counties) {
System.out.println(county.getName() + " ...");
List<Town> towns = countyRepo.findAllForCounty(county.getId());
townAll.addAll(towns);
for (Town town : towns) {
set.add(town.getName());
}
}
return true;
}
@Override
public int checkTables() {
// TODO Auto-generated method stub
return 3;
}
}
package com.springjpa.repo;
import java.util.List;
import javax.persistence.QueryHint;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.QueryHints;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import com.springjpa.model.County;
import com.springjpa.model.Town;
public interface CountyRepository extends CrudRepository<County, Long>{
List<County> findByName(String name);
@Query("SELECT t FROM County t")
List<County> findAll();
@Query("SELECT t FROM County t WHERE t.id = :id")
County findOne(@Param("id") long id);
Long getIdByName(String name);
@Query("SELECT t FROM Town t INNER JOIN t.township ts WHERE ts.county.id = :id")
/** A megyéhez tartozó összes település
* @param id megye azonosító
* @return
*/
List<Town> findAllForCounty(@Param("id") long id);
}
package com.springjpa.repo;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import com.springjpa.model.Town;
import com.springjpa.model.TownShip;
public interface TownRepository extends CrudRepository<Town, Long>{
List<Town> findByName(String name);
List<Town> findAll();
@Query("SELECT t FROM Town t WHERE t.id = :id")
Town findOne(@Param("id") long id);
@Query("SELECT t FROM Town t WHERE t.township.id = :id")
/** A járáshoz tartozó összes település
* @param id járás azonosító
* @return
*/
List<Town> findAllForTS(@Param("id") long id);
@Query("SELECT t.township FROM Town t INNER JOIN t.township ts WHERE t.name = :name" )
// @Query("SELECT t.township FROM Town t INNER JOIN t.township ts WHERE ts.county.name = :county AND t.name = :name")
/** Keressük a településhez tartozó járást
* @param town "Magyarbóly"
* @return "Bólyi Járási Hivatal"
*/
TownShip findByTown(@Param("name") String name); //, @Param("county") String county);
}
package com.springjpa.repo;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import com.springjpa.model.TownShip;
public interface TownShipRepository extends CrudRepository<TownShip, Long>{
List<TownShip> findByName(String name);
public List<TownShip> findAll();
@Query("SELECT t FROM TownShip t WHERE t.id = :id")
public TownShip findOne(@Param("id") long id);
@Query("SELECT ts FROM TownShip ts WHERE ts.county.id = :id")
/** A megyéhez tartozó összes járás
* @param id
* @return
*/
List<TownShip> findAllForCounty(@Param("id") long id);
}
#HA h2-db van
#spring.datasource.url=jdbc:h2:tcp://localhost/~/CKAN
#spring.datasource.username=sa
#spring.datasource.password=
#spring.datasource.driverClassName=org.h2.Driver
#erdekes: drive, mint org.h2.Driver nem kell megadni :))
#HA ckan-jdbc
spring.datasource.url=jdbc:ckan:rest:vm.ik.bme.hu:4339/hu/api/3?apikey=485baae6-5394-4af9-a76a-cbd1b902bfb0
spring.datasource.driverClassName=hu.bme.ckan.jdbc.rest.CkanDriver
#INNEN kzs
#spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
spring.jpa.show-sql=false
#persistence.xml-t nem olvassa :((
#spring.h2.console.enabled=true
welcome.message: Hello CKAN!
spring.thymeleaf.check-template-location=true
spring.thymeleaf.prefix=classpath:templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false
server.port=8090
server.contextPath=/HU_OGD/telepulesek
logging.level.root=WARN
logging.level.org.springframework=WARN
logging.level.org.springframework.web=ERROR
#logging.level.com.springjpa=DEBUG
#logging.level.=DEBUG
logging.file=/etc/CKAN/log/log.txt
#logging.config=classpath:logback.xml
logging.level.org.hibernate.jdbc=trace
#logging.level.org.hibernate.type=trace
scan.packages=com.springjpa
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
# Root logger option
log4j.rootLogger=INFO, stdout
# Hibernate logging options (INFO only shows startup messages)
log4j.logger.org.hibernate=INFO
# Log JDBC bind parameter runtime arguments
log4j.logger.org.hibernate.jdbc=trace
log4j.logger.org.hibernate.type=trace
h1{
color:#0000FF;
}
h2{
color:#FF0000;
}
.select_width{
width: 172px;
padding: 5px;
color: #555;
margin-top: 5px;
height: 30px;
}
.error {
color: #D8000C;
/* background-color: #FFBABA; */
}
header {
padding: 10px 20px 5px;
}
.box {
background: #f4f4f4;
padding: 20px;
color: #555;
margin-top: 30px;
}
\ No newline at end of file
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<title>Település melyik járáshoz tartozik</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width initial-scale=1 maximum-scale=1 user-scalable=no" />
<!-- link rel="stylesheet" type="text/css" href="webjars/bootstrap/3.3.7/css/bootstrap.min.css" /-->
<link rel="stylesheet" th:href="@{/css/main.css}" href="../../css/main.css" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/>
<link rel="stylesheet" type="text/css" th:href="@{/css/bootstrap.css}" href="../../css/bootstrap.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<style type="text/css">
@media screen and (device-width: 240px) and (orientation: landscape){
/* CSS for screens that are 320 pixels or less will be put in this section */
/* Force table to not be like tables anymore */
table, thead, tbody, th, td, tr {
display: block;
}
/* Hide table headers (but not display: none;, for accessibility) */
thead tr {
position: absolute;
top: -9999px;
left: -9999px;
}
tr {
/*border: 1px solid #ccc;*/
}
td {
/* Behave like a "row" */
border: none;
/*border-bottom: 1px solid #eee; */
position: relative;
padding-left: 5%;
}
td:before {
/* Now like a table header */
position: absolute;
/* Top/left values mimic padding */
top: 6px;
left: 6px;
width: 5%;
padding-right: 10px;
white-space: nowrap;
}
input[type=text], input[type=url], input[type=email], input[type=password], input[type=tel], select {
margin: 0;
width: 172px; height: 30px;
}
button[type=submit] {
-webkit-appearance: none; -moz-appearance: none;
display: block;
margin: 1.5em 0;
font-size: 1em; line-height: 2.5em;
color: #333;
font-weight: bold;
height: 2.5em;
background: #fdfdfd; background: -moz-linear-gradient(top, #fdfdfd 0%, #bebebe 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#fdfdfd), color-stop(100%,#bebebe)); background: -webkit-linear-gradient(top, #fdfdfd 0%,#bebebe 100%); background: -o-linear-gradient(top, #fdfdfd 0%,#bebebe 100%); background: -ms-linear-gradient(top, #fdfdfd 0%,#bebebe 100%); background: linear-gradient(to bottom, #fdfdfd 0%,#bebebe 100%);
border: 1px solid #bbb;
-webkit-border-radius: 10px; -moz-border-radius: 10px; border-radius: 10px;
}
}
/* @media screen and (min-width: 241px) /*(min-width: 240px) and (max-width: 320)*/ { */
/* /* Generic Styling, for Desktops/Laptops */ */
/* input[type=text], select { */
/* margin: 0; */
/* width: 172px; height: 30px; */
/* } */
}
</style>
</head>
<body>
<!-- <div class="visible-xs">XS</div> -->
<!-- <div class="visible-sm">SM</div> -->
<!-- <div class="visible-md">MD</div> -->
<!-- <div class="visible-lg">LG</div> -->
<header class="container-fluid">
Település kiválasztása:
</header>
<form action="#" th:action="@{/}" th:object="${addressForm}" method="post">
<!-- <div class="container"> -->
<!-- <div class="row" > -->
<!-- <div class="col-md-1 "> -->
<!-- <label for="county">Megye:</label> -->
<!-- </div> -->
<!-- <div class="col-md-2 "> -->
<!-- <select name="county" class="select_width" th:field="*{county}" th:onchange="'updateDistrict(this);'" > -->
<!-- <option th:each="acounty : ${dropDownDistrict}" -->
<!-- th:value="${acounty}" -->
<!-- th:text="${acounty}" /> -->
<!-- </select> -->
<!-- </div> -->
<!-- <div class="col-md-9"> -->
<!-- <span th:if="${#fields.hasErrors('county')}" th:errors="*{county}">District Error</span> -->
<!-- </div> -->
<!-- </div> -->
<!-- </div> -->
<div class="container">
<div class="row" >
<div class="col-md-1 ">
<label for="city">Település:</label>
</div>
<div class="col-md-2 ">
<input class="select_width" name="city" type="text" th:field="*{city}" th:placeholder="#{telepules.help}" />
</div>
<div class="col-md-9 ">
<span th:if="${#fields.hasErrors('city')}" th:errors="*{city}" class="error" >City Error</span>
</div>
</div> <!-- row -->
</div> <!-- container -->
<div class="container">
<div class="row" >
<div class="col-md-1 ">
</div>
<div class="col-md-2 ">
<b><button class="select_width" type="submit">Megye/járás keresés</button></b>
</div>
</div>
</div>
</form>
<script>
//http://xdsoft.net/jqplugins/autocomplete/ innine a limit, visiblelimit, de nem megy :((
$(document).ready(function() {
$( "#city" ).autocomplete({
source: "/HU_OGD/telepulesek/json/city"
});
})
function updateDistrict(value) {
$.ajax({
url: "/HU_OGD/telepulesek/json/district",
type : "GET",
// cache : false,
dataType: 'text',
contentType: 'application/json',
mimeType: 'application/json',
data: {
term: value.value
},
success: function(response){
$('#city').val('');
// if (response == "failure" ) {
// $('#city').autocomplete({
// delay: 10,
// source: '',
// minLength: 1,
// close: function(el){
// el.target.value = "";
// }
// });
// }
},
error: function(e){
alert('error message ' + e);
}
});
}
</script>
</body>
</html>
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Település melyik megyében, járásban</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width initial-scale=1 maximum-scale=1 user-scalable=no" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<!-- <link rel="stylesheet" type="text/css" href="/webjars/bootstrap/3.3.7/css/bootstrap.min.css" /> -->
<link rel="stylesheet" th:href="@{/css/main.css}" href="../../css/main.css" />
<link rel="stylesheet" type="text/css" th:href="@{/css/bootstrap.css}" href="../../css/bootstrap.css" />
<style type="text/css">
div#map{
width:100%;
height:300px;
margin:0 auto 0 auto;
}
img.centered{
display:block;
margin-left:auto;
margin-right:auto;
}
</style>
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
<style>
table {
width: 100%;
border-collapse: collapse;
/* font-size: 150%;*/
}
td {
/* width: 200px;*/
/* height: 50px;*/
text-align: left;
vertical-align: middle;
padding: 2px;
}
</style>
<script th:inline="javascript">
var county = [[${target2}]]; //ez a megye székhely
var ts = [[${target}]]; //ez a járás székhely
var home = [[${home}]]; //ez a település
var hteq = [[${hometarget}]] //igaz, ha valójában csak 1 település van; ilyenkor 15-ös nagyítás kell
function initMap() {
var county_gps = {lat: Number(county.gps.lat), lng: Number(county.gps.lon)};
var ts_gps = {lat: Number(ts.gps.lat), lng: Number(ts.gps.lon)};
var home_gps;
// alert(school_gps.lat + " " + school_gps.lng + "/" + home_gps.lat + " " + home_gps.lng);
map = new google.maps.Map(document.getElementById('map'), {
center: new google.maps.LatLng(ts_gps), //{lat: -34.397, lng: 150.644},
// zoom: 15
});
// if (hteq) {
//azonos a település és a járási székhely
// ts_gps.lat += 0.0004;
// ts_gps.lng += 0.0003;
// }
var marker1 = new google.maps.Marker({
position: new google.maps.LatLng(ts_gps),
label: "J",
icon: pinSymbol('orange'),
map: map
});
var marker3 = new google.maps.Marker({
position: new google.maps.LatLng(county_gps),
label: "M",
icon: pinSymbol('red'),
map: map
});
var marker2; //lehet, h nincs. Pl. I.ker Anna utca
if (home.gps != null) {
home_gps = {lat: Number(home.gps.lat), lng: Number(home.gps.lon)};
marker2 = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(home_gps),
label: "t",
icon: pinSymbol('#00FF00')
});
}
//innen: http://stackoverflow.com/questions/10268033/google-maps-api-v3-method-fitbounds
if (hteq) {
map.setZoom(12);
} else {
var bounds = new google.maps.LatLngBounds();
bounds.extend(marker1.position);
bounds.extend(marker3.position);
bounds.extend(marker2.position);
map.fitBounds(bounds);
}
}
function pinSymbol(color) {
return {
path: 'M 0,0 C -2,-20 -10,-22 -10,-30 A 10,10 0 1,1 10,-30 C 10,-22 2,-20 0,0 z',
fillColor: color,
fillOpacity: 1,
strokeColor: '#000',
strokeWeight: 1,
scale: 1,
labelOrigin: new google.maps.Point(0, -29)
};
}
</script>
</head>
<body >
<!-- <div class="visible-xs">XS</div> -->
<!-- <div class="visible-sm">SM</div> -->
<!-- <div class="visible-md">MD</div> -->
<!-- <div class="visible-lg">LG</div> -->
<header class="container-fluid">
Megye és járás kikeresése:
</header>
<header class="container-fluid">
<div th:if="${error}" >
<b><span th:text="${address.city}"></span></b> <u>t</u>elepülés <span th:text="${result}"></span>
</div>
<div th:if="!${error}" >
<b><span th:text="${address.city}"></span></b> <u>t</u>elepülés a <span th:text="${address.county}"></span>i <b><span th:text="${result}"></span></b> körzetéhez tartozik. <br/>
(<u>M</u>egye székhely: <span th:text="${target2.city}"></span>. <u>J</u>árási székhely: <span th:text="${target.city}"></span>.)
</div>
</header>
<header class="container-fluid">
<div th:if="${home} != null" >
<div class="row">
<div class="container">
<div class="row">
<h1 class="col-sm-3 hidden-xs"></h1> <!-- bal -->
<nav class="col-sm-6">
<div id="map" >
<script class="img-responsive" src="https://maps.googleapis.com/maps/api/js?v=3&amp;key=AIzaSyCBaQeNLWjURn4XV1Am9DHeG-9DLDglzTI&amp;callback=initMap" ></script>
</div>
</nav>
<h1 class="col-sm-3 hidden-xs"></h1> <!-- jobb -->
</div>
</div>
</div>
</div>
</header>
<header class="container-fluid">
<div th:if="${home} != null" >
<b>A járásnak további <span th:text="${#lists.size(others)}"></span> települése van még</b> (a térképen jelölteken kívül):
</div>
<div th:if="${home} != null" >
<div class="table-responsive col-sm-12 visible-lg-block">
<table id="cities" class="table" >
<tr th:each="city : ${others}" th:if="${cityStat.index % 5 == 0}">
<td> &nbsp; &nbsp; </td>
<td th:each="index : ${#numbers.sequence(cityStat.index, cityStat.index + 5 - 1)}"
th:if="${index lt cityStat.size}"
th:text="${others[index]}">city</td>
</tr>
</table>
</div>
<div class="table-responsive col-sm-12 visible-sm-block visible-md-block">
<table id="cities" class="table" >
<tr th:each="city : ${others}" th:if="${cityStat.index % 4 == 0}">
<td> &nbsp; &nbsp; </td>
<td th:each="index : ${#numbers.sequence(cityStat.index, cityStat.index + 4 - 1)}"
th:if="${index lt cityStat.size}"
th:text="${others[index]}">city</td>
</tr>
</table>
</div>
<div class="table-responsive col-sm-12 visible-xs-block">
<table id="cities" class="table" >
<tr th:each="city : ${others}" th:if="${cityStat.index % 2 == 0}">
<td> &nbsp; &nbsp; </td>
<td th:each="index : ${#numbers.sequence(cityStat.index, cityStat.index + 2 - 1)}"
th:if="${index lt cityStat.size}"
th:text="${others[index]}">city</td>
</tr>
</table>
</div>
</div>
</header>
<header class="container-fluid">
<form action="#" th:action="@{/xxx}" th:object="${addressForm}" method="post">
<b><button type="submit">Új településnév beadás</button></b>
</form>
</header>
</body>
</html>
\ No newline at end of file
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Spring Boot Thymeleaf Hello World Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css"
href="webjars/bootstrap/3.3.7/css/bootstrap.min.css" />
<link rel="stylesheet" th:href="@{/css/main.css}"
href="../../css/main.css" />
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">Spring Boot</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="starter-template">
<h1>Spring Boot Web Thymeleaf Example</h1>
<h2>
<span th:text="'Message: ' + ${message}"></span>
</h2>
</div>
</div>
<!-- /.container -->
<form action="#" th:action="@{/}" th:object="${personForm}" method="post">
<table>
<tr>
<td>Name:</td>
<td><input type="text" th:field="*{street}" /></td>
<td th:if="${#fields.hasErrors('street')}" th:errors="*{street}">Name Error</td>
</tr>
<tr>
<td>Age:</td>
<td><input type="text" th:field="*{number}" /></td>
<td th:if="${#fields.hasErrors('number')}" th:errors="*{number}">Age Error</td>
</tr>
<tr>
<td><button type="submit">Submit</button></td>
</tr>
</table>
</form>
<script type="text/javascript"
src="webjars/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>
\ No newline at end of file
package com.springjpa;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import org.hibernate.Hibernate;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.springjpa.model.County;
import com.springjpa.model.Town;
import com.springjpa.repo.CountyRepository;
@RunWith(SpringRunner.class)
@SpringBootTest
public class telepules_CkanApplicationTests {
@Autowired
private CountyRepository countyRepo;
@Ignore @Test
public void contextLoads() {
}
@Ignore @Test
public void shouldGetCounties() {
List<County> list = countyRepo.findAll();
for (County county : list) {
System.out.println(county);
}
assertNotNull(list);
}
@Test
public void shouldGetTowns() {
List<Town> list = countyRepo.findAllForCounty(1);
for (Town town: list) {
System.out.println(town);
}
assertNotNull(list);
}
}
Manifest-Version: 1.0
Implementation-Title: SpringJPA-PostgreSQL
Implementation-Version: 0.0.1-SNAPSHOT
Built-By: eax
Implementation-Vendor-Id: com.springjpa
Build-Jdk: 1.8.0_101
Implementation-URL: http://projects.spring.io/spring-boot/springJPA-po
stgreSQL/
Created-By: Maven Integration for Eclipse
Implementation-Vendor: Pivotal Software, Inc.
#Generated by Maven Integration for Eclipse
#Fri Jul 13 10:46:49 CEST 2018
version=0.0.1-SNAPSHOT
groupId=com.springjpa
m2e.projectName=telepules_CKANApplication3_JPA_inRepo
m2e.projectLocation=C\:\\WSP\\eclipsedata_CKAN\\telepules_CKANApplication3_JPA_inRepo
artifactId=springJPA-postgreSQL
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.springjpa</groupId>
<artifactId>springJPA-postgreSQL</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>SpringJPA-PostgreSQL</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<hibernate.version>4.3.6.Final</hibernate.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.192</version>
</dependency>
<dependency>
<groupId>org.ckan.jdbc</groupId>
<artifactId>ckanjdbc</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- JPA -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
<!-- For connection pooling -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>${hibernate.version}</version>
</dependency>
<!-- ckan-jar miatt -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.1</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<!-- saját ckan-client -->
<dependency>
<groupId>org.ckan</groupId>
<artifactId>ckan</artifactId>
<version>2.1</version>
</dependency>
<!-- google elemeknek kell -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cloud-connectors</artifactId>
</dependency>
<!-- thymeleaf -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<description>1. Adott telepulesre megmondja, h melyik megye (megye-szekhellyel), melyik jaras (jaras-szekhellyel)
2. Terkepre teszi a telepulest, megye- ill. jaras-szekhelyet, ami adott esetben egy es uaz. is lehet :)
3. Kiirja a jaras tobbi telepulesenek nevet (valtozo oszlopszammal).
Mobile-friendly kialakitasu.
Technikailag CKAN-Datastore-t hasznal, mégpedig úgy, hogy van egy CkanJdbcDriver, amivel a JPA működik.</description>
</project>
#HA h2-db van
#spring.datasource.url=jdbc:h2:tcp://localhost/~/CKAN
#spring.datasource.username=sa
#spring.datasource.password=
#spring.datasource.driverClassName=org.h2.Driver
#erdekes: drive, mint org.h2.Driver nem kell megadni :))
#HA ckan-jdbc
spring.datasource.url=jdbc:ckan:rest:vm.ik.bme.hu:4339/hu/api/3?apikey=485baae6-5394-4af9-a76a-cbd1b902bfb0
spring.datasource.driverClassName=hu.bme.ckan.jdbc.rest.CkanDriver
#INNEN k�z�s
#spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
spring.jpa.show-sql=false
#persistence.xml-t nem olvassa :((
#spring.h2.console.enabled=true
welcome.message: Hello CKAN!
spring.thymeleaf.check-template-location=true
spring.thymeleaf.prefix=classpath:templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false
server.port=8090
server.contextPath=/HU_OGD/telepulesek
logging.level.root=WARN
logging.level.org.springframework=WARN
logging.level.org.springframework.web=ERROR
#logging.level.com.springjpa=DEBUG
#logging.level.=DEBUG
logging.file=/etc/CKAN/log/log.txt
#logging.config=classpath:logback.xml
logging.level.org.hibernate.jdbc=trace
#logging.level.org.hibernate.type=trace
scan.packages=com.springjpa
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
# Root logger option
log4j.rootLogger=INFO, stdout
# Hibernate logging options (INFO only shows startup messages)
log4j.logger.org.hibernate=INFO
# Log JDBC bind parameter runtime arguments
log4j.logger.org.hibernate.jdbc=trace
log4j.logger.org.hibernate.type=trace
h1{
color:#0000FF;
}
h2{
color:#FF0000;
}
.select_width{
width: 172px;
padding: 5px;
color: #555;
margin-top: 5px;
height: 30px;
}
.error {
color: #D8000C;
/* background-color: #FFBABA; */
}
header {
padding: 10px 20px 5px;
}
.box {
background: #f4f4f4;
padding: 20px;
color: #555;
margin-top: 30px;
}
\ No newline at end of file
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<title>Település melyik járáshoz tartozik</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width initial-scale=1 maximum-scale=1 user-scalable=no" />
<!-- link rel="stylesheet" type="text/css" href="webjars/bootstrap/3.3.7/css/bootstrap.min.css" /-->
<link rel="stylesheet" th:href="@{/css/main.css}" href="../../css/main.css" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/>
<link rel="stylesheet" type="text/css" th:href="@{/css/bootstrap.css}" href="../../css/bootstrap.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<style type="text/css">
@media screen and (device-width: 240px) and (orientation: landscape){
/* CSS for screens that are 320 pixels or less will be put in this section */
/* Force table to not be like tables anymore */
table, thead, tbody, th, td, tr {
display: block;
}
/* Hide table headers (but not display: none;, for accessibility) */
thead tr {
position: absolute;
top: -9999px;
left: -9999px;
}
tr {
/*border: 1px solid #ccc;*/
}
td {
/* Behave like a "row" */
border: none;
/*border-bottom: 1px solid #eee; */
position: relative;
padding-left: 5%;
}
td:before {
/* Now like a table header */
position: absolute;
/* Top/left values mimic padding */
top: 6px;
left: 6px;
width: 5%;
padding-right: 10px;
white-space: nowrap;
}
input[type=text], input[type=url], input[type=email], input[type=password], input[type=tel], select {
margin: 0;
width: 172px; height: 30px;
}
button[type=submit] {
-webkit-appearance: none; -moz-appearance: none;
display: block;
margin: 1.5em 0;
font-size: 1em; line-height: 2.5em;
color: #333;
font-weight: bold;
height: 2.5em;
background: #fdfdfd; background: -moz-linear-gradient(top, #fdfdfd 0%, #bebebe 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#fdfdfd), color-stop(100%,#bebebe)); background: -webkit-linear-gradient(top, #fdfdfd 0%,#bebebe 100%); background: -o-linear-gradient(top, #fdfdfd 0%,#bebebe 100%); background: -ms-linear-gradient(top, #fdfdfd 0%,#bebebe 100%); background: linear-gradient(to bottom, #fdfdfd 0%,#bebebe 100%);
border: 1px solid #bbb;
-webkit-border-radius: 10px; -moz-border-radius: 10px; border-radius: 10px;
}
}
/* @media screen and (min-width: 241px) /*(min-width: 240px) and (max-width: 320)*/ { */
/* /* Generic Styling, for Desktops/Laptops */ */
/* input[type=text], select { */
/* margin: 0; */
/* width: 172px; height: 30px; */
/* } */
}
</style>
</head>
<body>
<!-- <div class="visible-xs">XS</div> -->
<!-- <div class="visible-sm">SM</div> -->
<!-- <div class="visible-md">MD</div> -->
<!-- <div class="visible-lg">LG</div> -->
<header class="container-fluid">
Település kiválasztása:
</header>
<form action="#" th:action="@{/}" th:object="${addressForm}" method="post">
<!-- <div class="container"> -->
<!-- <div class="row" > -->
<!-- <div class="col-md-1 "> -->
<!-- <label for="county">Megye:</label> -->
<!-- </div> -->
<!-- <div class="col-md-2 "> -->
<!-- <select name="county" class="select_width" th:field="*{county}" th:onchange="'updateDistrict(this);'" > -->
<!-- <option th:each="acounty : ${dropDownDistrict}" -->
<!-- th:value="${acounty}" -->
<!-- th:text="${acounty}" /> -->
<!-- </select> -->
<!-- </div> -->
<!-- <div class="col-md-9"> -->
<!-- <span th:if="${#fields.hasErrors('county')}" th:errors="*{county}">District Error</span> -->
<!-- </div> -->
<!-- </div> -->
<!-- </div> -->
<div class="container">
<div class="row" >
<div class="col-md-1 ">
<label for="city">Település:</label>
</div>
<div class="col-md-2 ">
<input class="select_width" name="city" type="text" th:field="*{city}" th:placeholder="#{telepules.help}" />
</div>
<div class="col-md-9 ">
<span th:if="${#fields.hasErrors('city')}" th:errors="*{city}" class="error" >City Error</span>
</div>
</div> <!-- row -->
</div> <!-- container -->
<div class="container">
<div class="row" >
<div class="col-md-1 ">
</div>
<div class="col-md-2 ">
<b><button class="select_width" type="submit">Megye/járás keresés</button></b>
</div>
</div>
</div>
</form>
<script>
//http://xdsoft.net/jqplugins/autocomplete/ innine a limit, visiblelimit, de nem megy :((
$(document).ready(function() {
$( "#city" ).autocomplete({
source: "/HU_OGD/telepulesek/json/city"
});
})
function updateDistrict(value) {
$.ajax({
url: "/HU_OGD/telepulesek/json/district",
type : "GET",
// cache : false,
dataType: 'text',
contentType: 'application/json',
mimeType: 'application/json',
data: {
term: value.value
},
success: function(response){
$('#city').val('');
// if (response == "failure" ) {
// $('#city').autocomplete({
// delay: 10,
// source: '',
// minLength: 1,
// close: function(el){
// el.target.value = "";
// }
// });
// }
},
error: function(e){
alert('error message ' + e);
}
});
}
</script>
</body>
</html>
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Település melyik megyében, járásban</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width initial-scale=1 maximum-scale=1 user-scalable=no" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<!-- <link rel="stylesheet" type="text/css" href="/webjars/bootstrap/3.3.7/css/bootstrap.min.css" /> -->
<link rel="stylesheet" th:href="@{/css/main.css}" href="../../css/main.css" />
<link rel="stylesheet" type="text/css" th:href="@{/css/bootstrap.css}" href="../../css/bootstrap.css" />
<style type="text/css">
div#map{
width:100%;
height:300px;
margin:0 auto 0 auto;
}
img.centered{
display:block;
margin-left:auto;
margin-right:auto;
}
</style>
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
<style>
table {
width: 100%;
border-collapse: collapse;
/* font-size: 150%;*/
}
td {
/* width: 200px;*/
/* height: 50px;*/
text-align: left;
vertical-align: middle;
padding: 2px;
}
</style>
<script th:inline="javascript">
var county = [[${target2}]]; //ez a megye székhely
var ts = [[${target}]]; //ez a járás székhely
var home = [[${home}]]; //ez a település
var hteq = [[${hometarget}]] //igaz, ha valójában csak 1 település van; ilyenkor 15-ös nagyítás kell
function initMap() {
var county_gps = {lat: Number(county.gps.lat), lng: Number(county.gps.lon)};
var ts_gps = {lat: Number(ts.gps.lat), lng: Number(ts.gps.lon)};
var home_gps;
// alert(school_gps.lat + " " + school_gps.lng + "/" + home_gps.lat + " " + home_gps.lng);
map = new google.maps.Map(document.getElementById('map'), {
center: new google.maps.LatLng(ts_gps), //{lat: -34.397, lng: 150.644},
// zoom: 15
});
// if (hteq) {
//azonos a település és a járási székhely
// ts_gps.lat += 0.0004;
// ts_gps.lng += 0.0003;
// }
var marker1 = new google.maps.Marker({
position: new google.maps.LatLng(ts_gps),
label: "J",
icon: pinSymbol('orange'),
map: map
});
var marker3 = new google.maps.Marker({
position: new google.maps.LatLng(county_gps),
label: "M",
icon: pinSymbol('red'),
map: map
});
var marker2; //lehet, h nincs. Pl. I.ker Anna utca
if (home.gps != null) {
home_gps = {lat: Number(home.gps.lat), lng: Number(home.gps.lon)};
marker2 = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(home_gps),
label: "t",
icon: pinSymbol('#00FF00')
});
}
//innen: http://stackoverflow.com/questions/10268033/google-maps-api-v3-method-fitbounds
if (hteq) {
map.setZoom(12);
} else {
var bounds = new google.maps.LatLngBounds();
bounds.extend(marker1.position);
bounds.extend(marker3.position);
bounds.extend(marker2.position);
map.fitBounds(bounds);
}
}
function pinSymbol(color) {
return {
path: 'M 0,0 C -2,-20 -10,-22 -10,-30 A 10,10 0 1,1 10,-30 C 10,-22 2,-20 0,0 z',
fillColor: color,
fillOpacity: 1,
strokeColor: '#000',
strokeWeight: 1,
scale: 1,
labelOrigin: new google.maps.Point(0, -29)
};
}
</script>
</head>
<body >
<!-- <div class="visible-xs">XS</div> -->
<!-- <div class="visible-sm">SM</div> -->
<!-- <div class="visible-md">MD</div> -->
<!-- <div class="visible-lg">LG</div> -->
<header class="container-fluid">
Megye és járás kikeresése:
</header>
<header class="container-fluid">
<div th:if="${error}" >
<b><span th:text="${address.city}"></span></b> <u>t</u>elepülés <span th:text="${result}"></span>
</div>
<div th:if="!${error}" >
<b><span th:text="${address.city}"></span></b> <u>t</u>elepülés a <span th:text="${address.county}"></span>i <b><span th:text="${result}"></span></b> körzetéhez tartozik. <br/>
(<u>M</u>egye székhely: <span th:text="${target2.city}"></span>. <u>J</u>árási székhely: <span th:text="${target.city}"></span>.)
</div>
</header>
<header class="container-fluid">
<div th:if="${home} != null" >
<div class="row">
<div class="container">
<div class="row">
<h1 class="col-sm-3 hidden-xs"></h1> <!-- bal -->
<nav class="col-sm-6">
<div id="map" >
<script class="img-responsive" src="https://maps.googleapis.com/maps/api/js?v=3&amp;key=AIzaSyCBaQeNLWjURn4XV1Am9DHeG-9DLDglzTI&amp;callback=initMap" ></script>
</div>
</nav>
<h1 class="col-sm-3 hidden-xs"></h1> <!-- jobb -->
</div>
</div>
</div>
</div>
</header>
<header class="container-fluid">
<div th:if="${home} != null" >
<b>A járásnak további <span th:text="${#lists.size(others)}"></span> települése van még</b> (a térképen jelölteken kívül):
</div>
<div th:if="${home} != null" >
<div class="table-responsive col-sm-12 visible-lg-block">
<table id="cities" class="table" >
<tr th:each="city : ${others}" th:if="${cityStat.index % 5 == 0}">
<td> &nbsp; &nbsp; </td>
<td th:each="index : ${#numbers.sequence(cityStat.index, cityStat.index + 5 - 1)}"
th:if="${index lt cityStat.size}"
th:text="${others[index]}">city</td>
</tr>
</table>
</div>
<div class="table-responsive col-sm-12 visible-sm-block visible-md-block">
<table id="cities" class="table" >
<tr th:each="city : ${others}" th:if="${cityStat.index % 4 == 0}">
<td> &nbsp; &nbsp; </td>
<td th:each="index : ${#numbers.sequence(cityStat.index, cityStat.index + 4 - 1)}"
th:if="${index lt cityStat.size}"
th:text="${others[index]}">city</td>
</tr>
</table>
</div>
<div class="table-responsive col-sm-12 visible-xs-block">
<table id="cities" class="table" >
<tr th:each="city : ${others}" th:if="${cityStat.index % 2 == 0}">
<td> &nbsp; &nbsp; </td>
<td th:each="index : ${#numbers.sequence(cityStat.index, cityStat.index + 2 - 1)}"
th:if="${index lt cityStat.size}"
th:text="${others[index]}">city</td>
</tr>
</table>
</div>
</div>
</header>
<header class="container-fluid">
<form action="#" th:action="@{/xxx}" th:object="${addressForm}" method="post">
<b><button type="submit">Új településnév beadás</button></b>
</form>
</header>
</body>
</html>
\ No newline at end of file
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Spring Boot Thymeleaf Hello World Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css"
href="webjars/bootstrap/3.3.7/css/bootstrap.min.css" />
<link rel="stylesheet" th:href="@{/css/main.css}"
href="../../css/main.css" />
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">Spring Boot</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="starter-template">
<h1>Spring Boot Web Thymeleaf Example</h1>
<h2>
<span th:text="'Message: ' + ${message}"></span>
</h2>
</div>
</div>
<!-- /.container -->
<form action="#" th:action="@{/}" th:object="${personForm}" method="post">
<table>
<tr>
<td>Name:</td>
<td><input type="text" th:field="*{street}" /></td>
<td th:if="${#fields.hasErrors('street')}" th:errors="*{street}">Name Error</td>
</tr>
<tr>
<td>Age:</td>
<td><input type="text" th:field="*{number}" /></td>
<td th:if="${#fields.hasErrors('number')}" th:errors="*{number}">Age Error</td>
</tr>
<tr>
<td><button type="submit">Submit</button></td>
</tr>
</table>
</form>
<script type="text/javascript"
src="webjars/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>
\ No newline at end of file
#Generated by Apache Maven
#Mon Mar 26 09:44:20 CEST 2018
version=0.0.1-SNAPSHOT
groupId=com.springjpa
artifactId=springJPA-postgreSQL
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 sign in to comment