添加 USEmbassy 对象和工具类
This commit is contained in:
parent
a7d4671028
commit
7a26a3a6c5
@ -0,0 +1,36 @@
|
||||
package com.usvisatrack.core.dao.model;
|
||||
|
||||
import com.usvisatrack.core.common.DataObject;
|
||||
|
||||
/**
|
||||
* USEmbassy ORM
|
||||
*
|
||||
* @author YuCheng Hu
|
||||
*
|
||||
*/
|
||||
public class USEmbassy extends DataObject {
|
||||
|
||||
private String country;
|
||||
private String city;
|
||||
|
||||
public USEmbassy() {
|
||||
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
}
|
@ -3,6 +3,7 @@ package com.usvisatrack.core.dao.model;
|
||||
import java.util.Date;
|
||||
|
||||
import com.usvisatrack.core.common.DataObject;
|
||||
import com.usvisatrack.core.common.data.VisaEntry;
|
||||
import com.usvisatrack.core.common.data.VisaStatus;
|
||||
|
||||
/**
|
||||
@ -14,7 +15,9 @@ import com.usvisatrack.core.common.data.VisaStatus;
|
||||
public class Visa extends DataObject {
|
||||
|
||||
private String ds160Code;
|
||||
private USEmbassy usEmbassy;
|
||||
private VisaClass visaClass;
|
||||
private VisaEntry visaEntry;
|
||||
private VisaStatus visaStatus;
|
||||
private String major;
|
||||
private String description;
|
||||
@ -36,6 +39,14 @@ public class Visa extends DataObject {
|
||||
this.ds160Code = ds160Code;
|
||||
}
|
||||
|
||||
public USEmbassy getUsEmbassy() {
|
||||
return usEmbassy;
|
||||
}
|
||||
|
||||
public void setUsEmbassy(USEmbassy usEmbassy) {
|
||||
this.usEmbassy = usEmbassy;
|
||||
}
|
||||
|
||||
public VisaClass getVisaClass() {
|
||||
return visaClass;
|
||||
}
|
||||
@ -44,6 +55,14 @@ public class Visa extends DataObject {
|
||||
this.visaClass = visaClass;
|
||||
}
|
||||
|
||||
public VisaEntry getVisaEntry() {
|
||||
return visaEntry;
|
||||
}
|
||||
|
||||
public void setVisaEntry(VisaEntry visaEntry) {
|
||||
this.visaEntry = visaEntry;
|
||||
}
|
||||
|
||||
public VisaStatus getVisaStatus() {
|
||||
return visaStatus;
|
||||
}
|
||||
|
@ -0,0 +1,52 @@
|
||||
package com.usvisatrack.core.factories;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.usvisatrack.core.common.Factory;
|
||||
import com.usvisatrack.core.dao.model.USEmbassy;
|
||||
import com.usvisatrack.core.dao.model.Visa;
|
||||
import com.usvisatrack.core.dao.model.VisaClass;
|
||||
|
||||
/**
|
||||
* Item Data Factory
|
||||
*
|
||||
* @author YuCheng Hu
|
||||
*
|
||||
*/
|
||||
public class USFactory extends Factory {
|
||||
private static Logger logger = LoggerFactory.getLogger(USFactory.class);
|
||||
|
||||
private static final int LISTING_PAGE_SIZE = 20;
|
||||
public static final int DEFAULT_AUTH_EXPIRATION = 10;
|
||||
|
||||
/**
|
||||
* get USEmbassy
|
||||
*
|
||||
* @param country
|
||||
* @param city
|
||||
* @return
|
||||
*/
|
||||
public static USEmbassy searchUSEmbassy(String country, String city) {
|
||||
logger.debug("Search USEmbassy - [{}]/[{}]", country, city);
|
||||
try {
|
||||
Factory.beginTransaction();
|
||||
Criteria criteria = Factory.createCriteria(USEmbassy.class);
|
||||
criteria.add(Restrictions.ilike("country", "%" + country + "%"));
|
||||
criteria.add(Restrictions.ilike("city", "%" + city + "%"));
|
||||
criteria.setMaxResults(1);
|
||||
return (USEmbassy) criteria.uniqueResult();
|
||||
} catch (Exception ex) {
|
||||
logger.error("Search USEmbassy data error", ex);
|
||||
} finally {
|
||||
Factory.commitTransaction();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
21
core/src/main/resources/hbm/USEmbassy.hbm.xml
Normal file
21
core/src/main/resources/hbm/USEmbassy.hbm.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<hibernate-mapping package="com.usvisatrack.core.dao.model">
|
||||
<class name="USEmbassy" table="us_embassy" catalog="northtecom_usvisatrack">
|
||||
<id name="id" type="java.lang.Long">
|
||||
<column name="us_embassy_id" />
|
||||
<generator class="identity" />
|
||||
</id>
|
||||
|
||||
<property name="country" type="string">
|
||||
<column name="country" length="16" />
|
||||
</property>
|
||||
|
||||
<property name="city" type="string">
|
||||
<column name="city" length="128" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
@ -28,6 +28,7 @@
|
||||
<property name="hibernate.c3p0.validate">true</property>
|
||||
|
||||
<!-- HBMs -->
|
||||
<mapping resource="hbm/USEmbassy.hbm.xml" />
|
||||
<mapping resource="hbm/User.hbm.xml" />
|
||||
<mapping resource="hbm/Visa.hbm.xml" />
|
||||
<mapping resource="hbm/VisaClass.hbm.xml" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user