mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-07 18:25:23 +00:00
Property DAO support for date (yyyy-mm-dd)
- Avoided nasty timezone issues by using Epoch millisecond time git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@15665 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
ce6ea6eced
commit
aeef3a5af8
@ -239,7 +239,7 @@
|
|||||||
<value>org.alfresco.cache.immutableEntityTransactionalCache</value>
|
<value>org.alfresco.cache.immutableEntityTransactionalCache</value>
|
||||||
</property>
|
</property>
|
||||||
<property name="maxCacheSize">
|
<property name="maxCacheSize">
|
||||||
<value>100</value>
|
<value>1000</value>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
@ -51,6 +51,8 @@
|
|||||||
<property name="propertyClassCache" ref="immutableEntityCache"/>
|
<property name="propertyClassCache" ref="immutableEntityCache"/>
|
||||||
<property name="propertyStringValueCache" ref="immutableEntityCache"/>
|
<property name="propertyStringValueCache" ref="immutableEntityCache"/>
|
||||||
<property name="propertyDoubleValueCache" ref="immutableEntityCache"/>
|
<property name="propertyDoubleValueCache" ref="immutableEntityCache"/>
|
||||||
|
<property name="propertyDateValueCache" ref="immutableEntityCache"/>
|
||||||
|
<property name="propertyValueCache" ref="immutableEntityCache"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
@ -41,6 +41,42 @@ CREATE TABLE alf_prop_serializable_value
|
|||||||
PRIMARY KEY (id)
|
PRIMARY KEY (id)
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
CREATE TABLE alf_prop_date_value
|
||||||
|
(
|
||||||
|
date_value BIGINT NOT NULL,
|
||||||
|
full_year SMALLINT NOT NULL,
|
||||||
|
half_of_year TINYINT NOT NULL,
|
||||||
|
quarter_of_year TINYINT NOT NULL,
|
||||||
|
month_of_year TINYINT NOT NULL,
|
||||||
|
week_of_year TINYINT NOT NULL,
|
||||||
|
week_of_month TINYINT NOT NULL,
|
||||||
|
day_of_year SMALLINT NOT NULL,
|
||||||
|
day_of_month TINYINT NOT NULL,
|
||||||
|
day_of_week TINYINT NOT NULL,
|
||||||
|
INDEX idx_alf_prop_date_val (date_value),
|
||||||
|
INDEX idx_alf_prop_date_fy (full_year),
|
||||||
|
INDEX idx_alf_prop_date_moy (month_of_year),
|
||||||
|
INDEX idx_alf_prop_date_doy (day_of_year),
|
||||||
|
INDEX idx_alf_prop_date_dom (day_of_month),
|
||||||
|
INDEX idx_alf_prop_date_dow (day_of_week),
|
||||||
|
PRIMARY KEY (date_value)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
CREATE TABLE alf_prop_time_value
|
||||||
|
(
|
||||||
|
time_value BIGINT NOT NULL,
|
||||||
|
hour_of_day TINYINT NOT NULL,
|
||||||
|
minute_of_hour TINYINT NOT NULL,
|
||||||
|
second_of_minute TINYINT NOT NULL,
|
||||||
|
ms_of_second TINYINT NOT NULL,
|
||||||
|
INDEX idx_alf_prop_time_val (time_value),
|
||||||
|
INDEX idx_alf_prop_time_hod (hour_of_day),
|
||||||
|
INDEX idx_alf_prop_time_moh (minute_of_hour),
|
||||||
|
INDEX idx_alf_prop_time_som (second_of_minute),
|
||||||
|
INDEX idx_alf_prop_time_msos (ms_of_second),
|
||||||
|
PRIMARY KEY (time_value)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
CREATE TABLE alf_prop_value
|
CREATE TABLE alf_prop_value
|
||||||
(
|
(
|
||||||
id BIGINT NOT NULL AUTO_INCREMENT,
|
id BIGINT NOT NULL AUTO_INCREMENT,
|
||||||
@ -51,6 +87,7 @@ CREATE TABLE alf_prop_value
|
|||||||
INDEX idx_alf_prop_act (actual_type_id, long_value),
|
INDEX idx_alf_prop_act (actual_type_id, long_value),
|
||||||
PRIMARY KEY (id)
|
PRIMARY KEY (id)
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Record script finish
|
-- Record script finish
|
||||||
--
|
--
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
<typeAlias alias="PropertyClass" type="org.alfresco.repo.domain.propval.PropertyClassEntity"/>
|
<typeAlias alias="PropertyClass" type="org.alfresco.repo.domain.propval.PropertyClassEntity"/>
|
||||||
<typeAlias alias="PropertyStringValue" type="org.alfresco.repo.domain.propval.PropertyStringValueEntity"/>
|
<typeAlias alias="PropertyStringValue" type="org.alfresco.repo.domain.propval.PropertyStringValueEntity"/>
|
||||||
<typeAlias alias="PropertyDoubleValue" type="org.alfresco.repo.domain.propval.PropertyDoubleValueEntity"/>
|
<typeAlias alias="PropertyDoubleValue" type="org.alfresco.repo.domain.propval.PropertyDoubleValueEntity"/>
|
||||||
|
<typeAlias alias="PropertyDateValue" type="org.alfresco.repo.domain.propval.PropertyDateValueEntity"/>
|
||||||
<typeAlias alias="PropertyValue" type="org.alfresco.repo.domain.propval.PropertyValueEntity"/>
|
<typeAlias alias="PropertyValue" type="org.alfresco.repo.domain.propval.PropertyValueEntity"/>
|
||||||
|
|
||||||
<!-- -->
|
<!-- -->
|
||||||
@ -33,6 +34,19 @@
|
|||||||
<result property="id" column="id" jdbcType="BIGINT" javaType="java.lang.Long"/>
|
<result property="id" column="id" jdbcType="BIGINT" javaType="java.lang.Long"/>
|
||||||
<result property="doubleValue" column="double_value" jdbcType="DOUBLE" javaType="java.lang.Double"/>
|
<result property="doubleValue" column="double_value" jdbcType="DOUBLE" javaType="java.lang.Double"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
<resultMap id="result.PropertyDateValue" class="PropertyDateValue">
|
||||||
|
<!-- date_value is the PK as well -->
|
||||||
|
<result property="dateValue" column="date_value" jdbcType="BIGINT" javaType="long"/>
|
||||||
|
<result property="fullYear" column="full_year" jdbcType="TINYINT" javaType="short"/>
|
||||||
|
<result property="halfOfYear" column="half_of_year" jdbcType="TINYINT" javaType="short"/>
|
||||||
|
<result property="quarterOfYear" column="quarter_of_year" jdbcType="TINYINT" javaType="short"/>
|
||||||
|
<result property="monthOfYear" column="month_of_year" jdbcType="TINYINT" javaType="short"/>
|
||||||
|
<result property="weekOfYear" column="week_of_year" jdbcType="TINYINT" javaType="short"/>
|
||||||
|
<result property="weekOfMonth" column="week_of_month" jdbcType="TINYINT" javaType="short"/>
|
||||||
|
<result property="dayOfYear" column="day_of_year" jdbcType="TINYINT" javaType="short"/>
|
||||||
|
<result property="dayOfMonth" column="day_of_month" jdbcType="TINYINT" javaType="short"/>
|
||||||
|
<result property="dayOfWeek" column="day_of_week" jdbcType="TINYINT" javaType="short"/>
|
||||||
|
</resultMap>
|
||||||
<resultMap id="result.PropertyValue" class="PropertyValue">
|
<resultMap id="result.PropertyValue" class="PropertyValue">
|
||||||
<result property="id" column="id" jdbcType="BIGINT" javaType="java.lang.Long"/>
|
<result property="id" column="id" jdbcType="BIGINT" javaType="java.lang.Long"/>
|
||||||
<result property="actualTypeId" column="actual_type_id" jdbcType="BIGINT" javaType="java.lang.Long"/>
|
<result property="actualTypeId" column="actual_type_id" jdbcType="BIGINT" javaType="java.lang.Long"/>
|
||||||
@ -76,6 +90,25 @@
|
|||||||
values (#doubleValue#)
|
values (#doubleValue#)
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<sql id="insert.PropertyDateValue">
|
||||||
|
insert into alf_prop_date_value
|
||||||
|
(
|
||||||
|
date_value,
|
||||||
|
full_year, half_of_year, quarter_of_year,
|
||||||
|
month_of_year,
|
||||||
|
week_of_year, week_of_month,
|
||||||
|
day_of_year, day_of_month, day_of_week
|
||||||
|
)
|
||||||
|
values
|
||||||
|
(
|
||||||
|
#dateValue#,
|
||||||
|
#fullYear#, #halfOfYear#, #quarterOfYear#,
|
||||||
|
#monthOfYear#,
|
||||||
|
#weekOfYear#, #weekOfMonth#,
|
||||||
|
#dayOfYear#, #dayOfMonth#, #dayOfWeek#
|
||||||
|
)
|
||||||
|
</sql>
|
||||||
|
|
||||||
<sql id="insert.PropertyValue.AutoIncrement">
|
<sql id="insert.PropertyValue.AutoIncrement">
|
||||||
insert into alf_prop_value (actual_type_id, persisted_type, long_value)
|
insert into alf_prop_value (actual_type_id, persisted_type, long_value)
|
||||||
values (#actualTypeId#, #persistedType#, #longValue#)
|
values (#actualTypeId#, #persistedType#, #longValue#)
|
||||||
@ -146,6 +179,45 @@
|
|||||||
double_value = #doubleValue#
|
double_value = #doubleValue#
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<insert id="insert.PropertyDateValue" parameterClass="PropertyDateValue" >
|
||||||
|
insert into alf_prop_date_value
|
||||||
|
(
|
||||||
|
date_value,
|
||||||
|
full_year, half_of_year, quarter_of_year,
|
||||||
|
month_of_year,
|
||||||
|
week_of_year, week_of_month,
|
||||||
|
day_of_year, day_of_month, day_of_week
|
||||||
|
)
|
||||||
|
values
|
||||||
|
(
|
||||||
|
#dateValue#,
|
||||||
|
#fullYear#, #halfOfYear#, #quarterOfYear#,
|
||||||
|
#monthOfYear#,
|
||||||
|
#weekOfYear#, #weekOfMonth#,
|
||||||
|
#dayOfYear#, #dayOfMonth#, #dayOfWeek#
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- Get a property date value by ID -->
|
||||||
|
<select id="select.PropertyDateValueByID" parameterClass="java.lang.Long" resultMap="result.PropertyDateValue">
|
||||||
|
select
|
||||||
|
*
|
||||||
|
from
|
||||||
|
alf_prop_date_value
|
||||||
|
where
|
||||||
|
id = #dateValue#
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- Get the property date value by value -->
|
||||||
|
<select id="select.PropertyDateValueByValue" parameterClass="java.lang.Long" resultMap="result.PropertyDateValue">
|
||||||
|
select
|
||||||
|
*
|
||||||
|
from
|
||||||
|
alf_prop_date_value
|
||||||
|
where
|
||||||
|
date_value = #dateValue#
|
||||||
|
</select>
|
||||||
|
|
||||||
<!-- Get the property value by value in alf_prop_value -->
|
<!-- Get the property value by value in alf_prop_value -->
|
||||||
<select id="select.PropertyValueByLocalValue" parameterClass="PropertyValue" resultMap="result.PropertyValue">
|
<select id="select.PropertyValueByLocalValue" parameterClass="PropertyValue" resultMap="result.PropertyValue">
|
||||||
select
|
select
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
package org.alfresco.repo.domain.propval;
|
package org.alfresco.repo.domain.propval;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.cache.SimpleCache;
|
import org.alfresco.repo.cache.SimpleCache;
|
||||||
@ -48,6 +49,7 @@ public abstract class AbstractPropertyValueDAOImpl implements PropertyValueDAO
|
|||||||
private static final String CACHE_REGION_PROPERTY_CLASS = "PropertyClass";
|
private static final String CACHE_REGION_PROPERTY_CLASS = "PropertyClass";
|
||||||
private static final String CACHE_REGION_PROPERTY_STRING_VALUE = "PropertyStringValue";
|
private static final String CACHE_REGION_PROPERTY_STRING_VALUE = "PropertyStringValue";
|
||||||
private static final String CACHE_REGION_PROPERTY_DOUBLE_VALUE = "PropertyDoubleValue";
|
private static final String CACHE_REGION_PROPERTY_DOUBLE_VALUE = "PropertyDoubleValue";
|
||||||
|
private static final String CACHE_REGION_PROPERTY_DATE_VALUE = "PropertyDateValue";
|
||||||
private static final String CACHE_REGION_PROPERTY_VALUE = "PropertyValue";
|
private static final String CACHE_REGION_PROPERTY_VALUE = "PropertyValue";
|
||||||
|
|
||||||
protected PropertyTypeConverter converter;
|
protected PropertyTypeConverter converter;
|
||||||
@ -55,6 +57,7 @@ public abstract class AbstractPropertyValueDAOImpl implements PropertyValueDAO
|
|||||||
private final PropertyClassCallbackDAO propertyClassDaoCallback;
|
private final PropertyClassCallbackDAO propertyClassDaoCallback;
|
||||||
private final PropertyStringValueCallbackDAO propertyStringValueCallback;
|
private final PropertyStringValueCallbackDAO propertyStringValueCallback;
|
||||||
private final PropertyDoubleValueCallbackDAO propertyDoubleValueCallback;
|
private final PropertyDoubleValueCallbackDAO propertyDoubleValueCallback;
|
||||||
|
private final PropertyDateValueCallbackDAO propertyDateValueCallback;
|
||||||
private final PropertyValueCallbackDAO propertyValueCallback;
|
private final PropertyValueCallbackDAO propertyValueCallback;
|
||||||
/**
|
/**
|
||||||
* Cache for the property class:<br/>
|
* Cache for the property class:<br/>
|
||||||
@ -77,6 +80,13 @@ public abstract class AbstractPropertyValueDAOImpl implements PropertyValueDAO
|
|||||||
* VALUE KEY: The value itself<br/>
|
* VALUE KEY: The value itself<br/>
|
||||||
*/
|
*/
|
||||||
private EntityLookupCache<Long, Double, Double> propertyDoubleValueCache;
|
private EntityLookupCache<Long, Double, Double> propertyDoubleValueCache;
|
||||||
|
/**
|
||||||
|
* Cache for the property date value:<br/>
|
||||||
|
* KEY: ID<br/>
|
||||||
|
* VALUE: The Date instance<br/>
|
||||||
|
* VALUE KEY: The date-only date (i.e. everything below day is zeroed)<br/>
|
||||||
|
*/
|
||||||
|
private EntityLookupCache<Long, Date, Date> propertyDateValueCache;
|
||||||
/**
|
/**
|
||||||
* Cache for the property value:<br/>
|
* Cache for the property value:<br/>
|
||||||
* KEY: ID<br/>
|
* KEY: ID<br/>
|
||||||
@ -96,11 +106,13 @@ public abstract class AbstractPropertyValueDAOImpl implements PropertyValueDAO
|
|||||||
this.propertyClassDaoCallback = new PropertyClassCallbackDAO();
|
this.propertyClassDaoCallback = new PropertyClassCallbackDAO();
|
||||||
this.propertyStringValueCallback = new PropertyStringValueCallbackDAO();
|
this.propertyStringValueCallback = new PropertyStringValueCallbackDAO();
|
||||||
this.propertyDoubleValueCallback = new PropertyDoubleValueCallbackDAO();
|
this.propertyDoubleValueCallback = new PropertyDoubleValueCallbackDAO();
|
||||||
|
this.propertyDateValueCallback = new PropertyDateValueCallbackDAO();
|
||||||
this.propertyValueCallback = new PropertyValueCallbackDAO();
|
this.propertyValueCallback = new PropertyValueCallbackDAO();
|
||||||
|
|
||||||
this.propertyClassCache = new EntityLookupCache<Long, Class<?>, String>(propertyClassDaoCallback);
|
this.propertyClassCache = new EntityLookupCache<Long, Class<?>, String>(propertyClassDaoCallback);
|
||||||
this.propertyStringValueCache = new EntityLookupCache<Long, String, Pair<String, Long>>(propertyStringValueCallback);
|
this.propertyStringValueCache = new EntityLookupCache<Long, String, Pair<String, Long>>(propertyStringValueCallback);
|
||||||
this.propertyDoubleValueCache = new EntityLookupCache<Long, Double, Double>(propertyDoubleValueCallback);
|
this.propertyDoubleValueCache = new EntityLookupCache<Long, Double, Double>(propertyDoubleValueCallback);
|
||||||
|
this.propertyDateValueCache = new EntityLookupCache<Long, Date, Date>(propertyDateValueCallback);
|
||||||
this.propertyValueCache = new EntityLookupCache<Long, Serializable, Serializable>(propertyValueCallback);
|
this.propertyValueCache = new EntityLookupCache<Long, Serializable, Serializable>(propertyValueCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,6 +163,19 @@ public abstract class AbstractPropertyValueDAOImpl implements PropertyValueDAO
|
|||||||
propertyDoubleValueCallback);
|
propertyDoubleValueCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the cache to use for <b>alf_prop_date_value</b> lookups (optional).
|
||||||
|
*
|
||||||
|
* @param propertyDateValueCache the cache of IDs to property values
|
||||||
|
*/
|
||||||
|
public void setPropertyDateValueCache(SimpleCache<Serializable, Object> propertyDateValueCache)
|
||||||
|
{
|
||||||
|
this.propertyDateValueCache = new EntityLookupCache<Long, Date, Date>(
|
||||||
|
propertyDateValueCache,
|
||||||
|
CACHE_REGION_PROPERTY_DATE_VALUE,
|
||||||
|
propertyDateValueCallback);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the cache to use for <b>alf_prop_value</b> lookups (optional).
|
* Set the cache to use for <b>alf_prop_value</b> lookups (optional).
|
||||||
*
|
*
|
||||||
@ -368,6 +393,7 @@ public abstract class AbstractPropertyValueDAOImpl implements PropertyValueDAO
|
|||||||
return (Pair<Long, Double>) entityPair;
|
return (Pair<Long, Double>) entityPair;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback for <b>alf_prop_double_value</b> DAO.
|
* Callback for <b>alf_prop_double_value</b> DAO.
|
||||||
*/
|
*/
|
||||||
@ -413,6 +439,102 @@ public abstract class AbstractPropertyValueDAOImpl implements PropertyValueDAO
|
|||||||
protected abstract PropertyDoubleValueEntity findDoubleValueByValue(Double value);
|
protected abstract PropertyDoubleValueEntity findDoubleValueByValue(Double value);
|
||||||
protected abstract PropertyDoubleValueEntity createDoubleValue(Double value);
|
protected abstract PropertyDoubleValueEntity createDoubleValue(Double value);
|
||||||
|
|
||||||
|
//================================
|
||||||
|
// 'alf_prop_date_value' accessors
|
||||||
|
//================================
|
||||||
|
|
||||||
|
public Pair<Long, Date> getPropertyDateValueById(Long id)
|
||||||
|
{
|
||||||
|
if (id == null)
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Cannot look up entity by null ID.");
|
||||||
|
}
|
||||||
|
Pair<Long, Date> entityPair = propertyDateValueCache.getByKey(id);
|
||||||
|
if (entityPair == null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("No property date value exists for ID " + id);
|
||||||
|
}
|
||||||
|
return entityPair;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pair<Long, Date> getPropertyDateValue(Date value)
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Persisted date values cannot be null");
|
||||||
|
}
|
||||||
|
value = PropertyDateValueEntity.truncateDate(value);
|
||||||
|
Pair<Long, Date> entityPair = propertyDateValueCache.getByValue(value);
|
||||||
|
return entityPair;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pair<Long, Date> getOrCreatePropertyDateValue(Date value)
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Persisted double values cannot be null");
|
||||||
|
}
|
||||||
|
value = PropertyDateValueEntity.truncateDate(value);
|
||||||
|
Pair<Long, Date> entityPair = propertyDateValueCache.getOrCreateByValue(value);
|
||||||
|
return (Pair<Long, Date>) entityPair;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback for <b>alf_prop_date_value</b> DAO.
|
||||||
|
*/
|
||||||
|
private class PropertyDateValueCallbackDAO extends EntityLookupCallbackDAOAdaptor<Long, Date, Date>
|
||||||
|
{
|
||||||
|
private final Pair<Long, Date> convertEntityToPair(PropertyDateValueEntity entity)
|
||||||
|
{
|
||||||
|
if (entity == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return entity.getEntityPair();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* <p/>
|
||||||
|
* The value will already have been truncated to have day-accuracy.
|
||||||
|
*/
|
||||||
|
public Date getValueKey(Date value)
|
||||||
|
{
|
||||||
|
return PropertyDateValueEntity.truncateDate(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pair<Long, Date> createValue(Date value)
|
||||||
|
{
|
||||||
|
PropertyDateValueEntity entity = createDateValue(value);
|
||||||
|
return convertEntityToPair(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pair<Long, Date> findByKey(Long key)
|
||||||
|
{
|
||||||
|
PropertyDateValueEntity entity = findDateValueById(key);
|
||||||
|
return convertEntityToPair(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pair<Long, Date> findByValue(Date value)
|
||||||
|
{
|
||||||
|
PropertyDateValueEntity entity = findDateValueByValue(value);
|
||||||
|
return convertEntityToPair(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract PropertyDateValueEntity findDateValueById(Long id);
|
||||||
|
/**
|
||||||
|
* @param value a date with day-accuracy
|
||||||
|
*/
|
||||||
|
protected abstract PropertyDateValueEntity findDateValueByValue(Date value);
|
||||||
|
/**
|
||||||
|
* @param value a date with day-accuracy
|
||||||
|
*/
|
||||||
|
protected abstract PropertyDateValueEntity createDateValue(Date value);
|
||||||
|
|
||||||
//================================
|
//================================
|
||||||
// 'alf_prop_value' accessors
|
// 'alf_prop_value' accessors
|
||||||
//================================
|
//================================
|
||||||
|
@ -0,0 +1,244 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
* As a special exception to the terms and conditions of version 2.0 of
|
||||||
|
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||||
|
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||||
|
* FLOSS exception. You should have recieved a copy of the text describing
|
||||||
|
* the FLOSS exception, and it is also available here:
|
||||||
|
* http://www.alfresco.com/legal/licensing"
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.domain.propval;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
import org.alfresco.util.EqualsHelper;
|
||||||
|
import org.alfresco.util.ISO8601DateFormat;
|
||||||
|
import org.alfresco.util.Pair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entity bean for <b>alf_prop_date_value</b> table.
|
||||||
|
*
|
||||||
|
* @author Derek Hulley
|
||||||
|
* @since 3.3
|
||||||
|
*/
|
||||||
|
public class PropertyDateValueEntity
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Converts the given date (with arbitrary time values) to a date-only (no time or milliseconds)
|
||||||
|
*
|
||||||
|
* @param value the Java date, possibly containing hours, minutes, seconds and milliseconds
|
||||||
|
* @return the Java date truncated to day-accuracy in GMT
|
||||||
|
*/
|
||||||
|
public static Date truncateDate(java.util.Date value)
|
||||||
|
{
|
||||||
|
Calendar cal = GregorianCalendar.getInstance();
|
||||||
|
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||||
|
cal.setTimeInMillis(value.getTime());
|
||||||
|
cal.set(Calendar.MILLISECOND, 0);
|
||||||
|
cal.set(Calendar.SECOND, 0);
|
||||||
|
cal.set(Calendar.MINUTE, 0);
|
||||||
|
cal.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
|
||||||
|
Date dayOnlyDate = cal.getTime();
|
||||||
|
// Done
|
||||||
|
return dayOnlyDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long dateValue;
|
||||||
|
private short fullYear;
|
||||||
|
private short halfOfYear;
|
||||||
|
private short quarterOfYear;
|
||||||
|
private short monthOfYear;
|
||||||
|
private short weekOfYear;
|
||||||
|
private short weekOfMonth;
|
||||||
|
private short dayOfYear;
|
||||||
|
private short dayOfMonth;
|
||||||
|
private short dayOfWeek;
|
||||||
|
|
||||||
|
public PropertyDateValueEntity()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return (dateValue == null ? 0 : dateValue.hashCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj)
|
||||||
|
{
|
||||||
|
if (this == obj)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (obj != null && obj instanceof PropertyDateValueEntity)
|
||||||
|
{
|
||||||
|
PropertyDateValueEntity that = (PropertyDateValueEntity) obj;
|
||||||
|
return EqualsHelper.nullSafeEquals(this.dateValue, that.dateValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder(512);
|
||||||
|
sb.append("PropertyDateValueEntity")
|
||||||
|
.append("[ value=").append(dateValue)
|
||||||
|
.append(" (").append(ISO8601DateFormat.format(new Date(dateValue.longValue()))).append(")")
|
||||||
|
.append("]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the ID-value pair
|
||||||
|
*/
|
||||||
|
public Pair<Long, Date> getEntityPair()
|
||||||
|
{
|
||||||
|
return new Pair<Long, Date>(dateValue, new Date(dateValue.longValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(Date value)
|
||||||
|
{
|
||||||
|
long valueInMs = value.getTime();
|
||||||
|
this.dateValue = new Long(valueInMs);
|
||||||
|
|
||||||
|
Calendar cal = GregorianCalendar.getInstance();
|
||||||
|
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||||
|
cal.setTimeInMillis(valueInMs);
|
||||||
|
|
||||||
|
// We need month_of_year for further calculations
|
||||||
|
this.monthOfYear = (short) cal.get(Calendar.MONTH);
|
||||||
|
|
||||||
|
this.fullYear = (short) cal.get(Calendar.YEAR);
|
||||||
|
this.halfOfYear = (short) monthOfYear < Calendar.JUNE ? (short)0 : (short)1;
|
||||||
|
this.quarterOfYear = (short) (monthOfYear / (short)3);
|
||||||
|
this.weekOfYear = (short) cal.get(Calendar.WEEK_OF_YEAR);
|
||||||
|
this.weekOfMonth = (short) cal.get(Calendar.WEEK_OF_MONTH);
|
||||||
|
this.dayOfYear = (short) cal.get(Calendar.DAY_OF_YEAR);
|
||||||
|
this.dayOfMonth = (short) cal.get(Calendar.DAY_OF_MONTH);
|
||||||
|
this.dayOfWeek = (short) cal.get(Calendar.DAY_OF_MONTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getDateValue()
|
||||||
|
{
|
||||||
|
return dateValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDateValue(Long dateValue)
|
||||||
|
{
|
||||||
|
this.dateValue = dateValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getFullYear()
|
||||||
|
{
|
||||||
|
return fullYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFullYear(short fullYear)
|
||||||
|
{
|
||||||
|
this.fullYear = fullYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getHalfOfYear()
|
||||||
|
{
|
||||||
|
return halfOfYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHalfOfYear(short halfOfYear)
|
||||||
|
{
|
||||||
|
this.halfOfYear = halfOfYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getQuarterOfYear()
|
||||||
|
{
|
||||||
|
return quarterOfYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuarterOfYear(short quarterOfYear)
|
||||||
|
{
|
||||||
|
this.quarterOfYear = quarterOfYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getMonthOfYear()
|
||||||
|
{
|
||||||
|
return monthOfYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMonthOfYear(short monthOfYear)
|
||||||
|
{
|
||||||
|
this.monthOfYear = monthOfYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getWeekOfYear()
|
||||||
|
{
|
||||||
|
return weekOfYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWeekOfYear(short weekOfYear)
|
||||||
|
{
|
||||||
|
this.weekOfYear = weekOfYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getWeekOfMonth()
|
||||||
|
{
|
||||||
|
return weekOfMonth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWeekOfMonth(short weekOfMonth)
|
||||||
|
{
|
||||||
|
this.weekOfMonth = weekOfMonth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getDayOfYear()
|
||||||
|
{
|
||||||
|
return dayOfYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDayOfYear(short dayOfYear)
|
||||||
|
{
|
||||||
|
this.dayOfYear = dayOfYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getDayOfMonth()
|
||||||
|
{
|
||||||
|
return dayOfMonth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDayOfMonth(short dayOfMonth)
|
||||||
|
{
|
||||||
|
this.dayOfMonth = dayOfMonth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public short getDayOfWeek()
|
||||||
|
{
|
||||||
|
return dayOfWeek;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDayOfWeek(short dayOfWeek)
|
||||||
|
{
|
||||||
|
this.dayOfWeek = dayOfWeek;
|
||||||
|
}
|
||||||
|
}
|
@ -25,6 +25,7 @@
|
|||||||
package org.alfresco.repo.domain.propval;
|
package org.alfresco.repo.domain.propval;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
|
|
||||||
@ -93,6 +94,25 @@ public interface PropertyValueDAO
|
|||||||
*/
|
*/
|
||||||
Pair<Long, Double> getOrCreatePropertyDoubleValue(Double value);
|
Pair<Long, Double> getOrCreatePropertyDoubleValue(Double value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>alf_prop_date_value</b> accessor
|
||||||
|
*
|
||||||
|
* @param id the ID (may not be <tt>null</tt>)
|
||||||
|
*/
|
||||||
|
Pair<Long, Date> getPropertyDateValueById(Long id);
|
||||||
|
/**
|
||||||
|
* <b>alf_prop_date_value</b> accessor
|
||||||
|
*
|
||||||
|
* @param value the value to find the ID for (may not be <tt>null</tt>)
|
||||||
|
*/
|
||||||
|
Pair<Long, Date> getPropertyDateValue(Date value);
|
||||||
|
/**
|
||||||
|
* <b>alf_prop_date_value</b> accessor
|
||||||
|
*
|
||||||
|
* @param value the value to find the ID for (may not be <tt>null</tt>)
|
||||||
|
*/
|
||||||
|
Pair<Long, Date> getOrCreatePropertyDateValue(Date value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>alf_prop_value</b> accessor
|
* <b>alf_prop_value</b> accessor
|
||||||
*
|
*
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
package org.alfresco.repo.domain.propval;
|
package org.alfresco.repo.domain.propval;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
@ -33,6 +34,7 @@ import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransacti
|
|||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
|
import org.alfresco.util.ISO8601DateFormat;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
@ -171,34 +173,6 @@ public class PropertyValueDAOTest extends TestCase
|
|||||||
assertNotSame("String IDs were not different", stringEntityPair.getFirst(), stringUpperEntityPair.getFirst());
|
assertNotSame("String IDs were not different", stringEntityPair.getFirst(), stringUpperEntityPair.getFirst());
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void testPropertyNumericValue_Long() throws Exception
|
|
||||||
// {
|
|
||||||
// final Long longValue = Long.valueOf(Long.MAX_VALUE);
|
|
||||||
// RetryingTransactionCallback<Pair<Long, Long>> createValueCallback = new RetryingTransactionCallback<Pair<Long, Long>>()
|
|
||||||
// {
|
|
||||||
// public Pair<Long, Long> execute() throws Throwable
|
|
||||||
// {
|
|
||||||
// // Get the classes
|
|
||||||
// return propertyValueDAO.getOrCreatePropertyNumericValue(longValue);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// final Pair<Long, Long> entityPair = txnHelper.doInTransaction(createValueCallback, false);
|
|
||||||
// assertNotNull(entityPair);
|
|
||||||
// assertEquals(longValue, entityPair.getSecond());
|
|
||||||
//
|
|
||||||
// RetryingTransactionCallback<Pair<Long, Long>> getValueCallback = new RetryingTransactionCallback<Pair<Long, Long>>()
|
|
||||||
// {
|
|
||||||
// public Pair<Long, Long> execute() throws Throwable
|
|
||||||
// {
|
|
||||||
// // Get the classes
|
|
||||||
// return propertyValueDAO.getPropertyDoubleValue(longValue);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// final Pair<Long, Long> entityPairCheck = txnHelper.doInTransaction(getValueCallback, false);
|
|
||||||
// assertNotNull(entityPairCheck);
|
|
||||||
// assertEquals(entityPair, entityPairCheck);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void testPropertyDoubleValue() throws Exception
|
public void testPropertyDoubleValue() throws Exception
|
||||||
{
|
{
|
||||||
final Double doubleValue = Double.valueOf(1.7976931348623E+308);
|
final Double doubleValue = Double.valueOf(1.7976931348623E+308);
|
||||||
@ -227,6 +201,35 @@ public class PropertyValueDAOTest extends TestCase
|
|||||||
assertEquals(entityPair, entityPairCheck);
|
assertEquals(entityPair, entityPairCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testPropertyDateValue() throws Exception
|
||||||
|
{
|
||||||
|
final Date dateValue = ISO8601DateFormat.parse("1936-08-04T23:37:25.793Z");
|
||||||
|
final Date dateValueBack = ISO8601DateFormat.parse("1936-08-04T00:00:00.000Z");
|
||||||
|
RetryingTransactionCallback<Pair<Long, Date>> createValueCallback = new RetryingTransactionCallback<Pair<Long, Date>>()
|
||||||
|
{
|
||||||
|
public Pair<Long, Date> execute() throws Throwable
|
||||||
|
{
|
||||||
|
// Get the classes
|
||||||
|
return propertyValueDAO.getOrCreatePropertyDateValue(dateValue);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
final Pair<Long, Date> entityPair = txnHelper.doInTransaction(createValueCallback, false);
|
||||||
|
assertNotNull(entityPair);
|
||||||
|
assertEquals(dateValueBack, entityPair.getSecond());
|
||||||
|
|
||||||
|
RetryingTransactionCallback<Pair<Long, Date>> getValueCallback = new RetryingTransactionCallback<Pair<Long, Date>>()
|
||||||
|
{
|
||||||
|
public Pair<Long, Date> execute() throws Throwable
|
||||||
|
{
|
||||||
|
// Get the classes
|
||||||
|
return propertyValueDAO.getPropertyDateValue(dateValue);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
final Pair<Long, Date> entityPairCheck = txnHelper.doInTransaction(getValueCallback, false);
|
||||||
|
assertNotNull(entityPairCheck);
|
||||||
|
assertEquals(entityPair, entityPairCheck);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that the given value can be persisted and retrieved with the same resulting ID
|
* Tests that the given value can be persisted and retrieved with the same resulting ID
|
||||||
*/
|
*/
|
||||||
@ -285,7 +288,7 @@ public class PropertyValueDAOTest extends TestCase
|
|||||||
|
|
||||||
public void testPropertyValue_Short() throws Exception
|
public void testPropertyValue_Short() throws Exception
|
||||||
{
|
{
|
||||||
for (short i = 0; i < 1000; i++)
|
for (short i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
runPropertyValueTest(new Short(i));
|
runPropertyValueTest(new Short(i));
|
||||||
}
|
}
|
||||||
@ -293,7 +296,7 @@ public class PropertyValueDAOTest extends TestCase
|
|||||||
|
|
||||||
public void testPropertyValue_Integer() throws Exception
|
public void testPropertyValue_Integer() throws Exception
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 1000; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
runPropertyValueTest(new Integer(i));
|
runPropertyValueTest(new Integer(i));
|
||||||
}
|
}
|
||||||
@ -301,7 +304,7 @@ public class PropertyValueDAOTest extends TestCase
|
|||||||
|
|
||||||
public void testPropertyValue_Long() throws Exception
|
public void testPropertyValue_Long() throws Exception
|
||||||
{
|
{
|
||||||
for (long i = 0; i < 1000; i++)
|
for (long i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
runPropertyValueTest(new Long(i));
|
runPropertyValueTest(new Long(i));
|
||||||
}
|
}
|
||||||
@ -309,7 +312,7 @@ public class PropertyValueDAOTest extends TestCase
|
|||||||
|
|
||||||
public void testPropertyValue_Float() throws Exception
|
public void testPropertyValue_Float() throws Exception
|
||||||
{
|
{
|
||||||
for (long i = 0; i < 1000; i++)
|
for (long i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
runPropertyValueTest(new Float((float)i + 0.01F));
|
runPropertyValueTest(new Float((float)i + 0.01F));
|
||||||
}
|
}
|
||||||
@ -317,15 +320,24 @@ public class PropertyValueDAOTest extends TestCase
|
|||||||
|
|
||||||
public void testPropertyValue_Double() throws Exception
|
public void testPropertyValue_Double() throws Exception
|
||||||
{
|
{
|
||||||
for (long i = 0; i < 1000; i++)
|
for (long i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
runPropertyValueTest(new Double((double)i + 0.01D));
|
runPropertyValueTest(new Double((double)i + 0.01D));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testPropertyValue_Date() throws Exception
|
||||||
|
{
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
for (long i = 0; i < 100; i++)
|
||||||
|
{
|
||||||
|
runPropertyValueTest(new Date(now + i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void testPropertyValue_String() throws Exception
|
public void testPropertyValue_String() throws Exception
|
||||||
{
|
{
|
||||||
for (long i = 0; i < 1000; i++)
|
for (long i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
runPropertyValueTest(new String("Value-" + i + ".xyz"));
|
runPropertyValueTest(new String("Value-" + i + ".xyz"));
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,12 @@
|
|||||||
package org.alfresco.repo.domain.propval.ibatis;
|
package org.alfresco.repo.domain.propval.ibatis;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.repo.domain.propval.AbstractPropertyValueDAOImpl;
|
import org.alfresco.repo.domain.propval.AbstractPropertyValueDAOImpl;
|
||||||
import org.alfresco.repo.domain.propval.PropertyClassEntity;
|
import org.alfresco.repo.domain.propval.PropertyClassEntity;
|
||||||
|
import org.alfresco.repo.domain.propval.PropertyDateValueEntity;
|
||||||
import org.alfresco.repo.domain.propval.PropertyDoubleValueEntity;
|
import org.alfresco.repo.domain.propval.PropertyDoubleValueEntity;
|
||||||
import org.alfresco.repo.domain.propval.PropertyStringValueEntity;
|
import org.alfresco.repo.domain.propval.PropertyStringValueEntity;
|
||||||
import org.alfresco.repo.domain.propval.PropertyValueEntity;
|
import org.alfresco.repo.domain.propval.PropertyValueEntity;
|
||||||
@ -56,6 +58,10 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl
|
|||||||
private static final String SELECT_PROPERTY_DOUBLE_VALUE_BY_VALUE = "select.PropertyDoubleValueByValue";
|
private static final String SELECT_PROPERTY_DOUBLE_VALUE_BY_VALUE = "select.PropertyDoubleValueByValue";
|
||||||
private static final String INSERT_PROPERTY_DOUBLE_VALUE = "insert.PropertyDoubleValue";
|
private static final String INSERT_PROPERTY_DOUBLE_VALUE = "insert.PropertyDoubleValue";
|
||||||
|
|
||||||
|
private static final String SELECT_PROPERTY_DATE_VALUE_BY_ID = "select.PropertyDateValueByID";
|
||||||
|
private static final String SELECT_PROPERTY_DATE_VALUE_BY_VALUE = "select.PropertyDateValueByValue";
|
||||||
|
private static final String INSERT_PROPERTY_DATE_VALUE = "insert.PropertyDateValue";
|
||||||
|
|
||||||
private static final String SELECT_PROPERTY_VALUE_BY_ID = "select.PropertyValueById";
|
private static final String SELECT_PROPERTY_VALUE_BY_ID = "select.PropertyValueById";
|
||||||
private static final String SELECT_PROPERTY_VALUE_BY_LOCAL_VALUE = "select.PropertyValueByLocalValue";
|
private static final String SELECT_PROPERTY_VALUE_BY_LOCAL_VALUE = "select.PropertyValueByLocalValue";
|
||||||
private static final String SELECT_PROPERTY_VALUE_BY_DOUBLE_VALUE = "select.PropertyValueByDoubleValue";
|
private static final String SELECT_PROPERTY_VALUE_BY_DOUBLE_VALUE = "select.PropertyValueByDoubleValue";
|
||||||
@ -206,6 +212,40 @@ public class PropertyValueDAOImpl extends AbstractPropertyValueDAOImpl
|
|||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//================================
|
||||||
|
// 'alf_prop_date_value' accessors
|
||||||
|
//================================
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PropertyDateValueEntity findDateValueById(Long id)
|
||||||
|
{
|
||||||
|
PropertyDateValueEntity entity = (PropertyDateValueEntity) template.queryForObject(
|
||||||
|
SELECT_PROPERTY_DATE_VALUE_BY_ID,
|
||||||
|
id);
|
||||||
|
// Done
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PropertyDateValueEntity findDateValueByValue(Date value)
|
||||||
|
{
|
||||||
|
PropertyDateValueEntity result = (PropertyDateValueEntity) template.queryForObject(
|
||||||
|
SELECT_PROPERTY_DATE_VALUE_BY_VALUE,
|
||||||
|
new Long(value.getTime()));
|
||||||
|
// The ID is the actual time in ms (GMT)
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PropertyDateValueEntity createDateValue(Date value)
|
||||||
|
{
|
||||||
|
PropertyDateValueEntity entity = new PropertyDateValueEntity();
|
||||||
|
entity.setValue(value);
|
||||||
|
template.insert(INSERT_PROPERTY_DATE_VALUE, entity);
|
||||||
|
// Done
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
//================================
|
//================================
|
||||||
// 'alf_prop_value' accessors
|
// 'alf_prop_value' accessors
|
||||||
//================================
|
//================================
|
||||||
|
Loading…
x
Reference in New Issue
Block a user