tim-connector: Rename connectorId to connectorName in OrderSyncInfo
FEA: ItEr77S16JiraAndTimConnectorContributionIntegration
This commit is contained in:
parent
3e29b3023e
commit
c7508fbfa3
8 changed files with 55 additions and 51 deletions
|
|
@ -34,50 +34,52 @@ public interface IOrderSyncInfoDAO extends IGenericDAO<OrderSyncInfo, Long> {
|
|||
|
||||
/**
|
||||
* Search last synchronized info for the specified
|
||||
* <code>{@link Order}</code> and <code>connectorId</code>
|
||||
* <code>{@link Order}</code> and <code>connectorName</code>
|
||||
*
|
||||
* @param order
|
||||
* the order to search for
|
||||
* @param connectorId
|
||||
* the connector-id
|
||||
* @param connectorName
|
||||
* the connector name
|
||||
*
|
||||
* @return Last synchronized info
|
||||
*/
|
||||
OrderSyncInfo findLastSynchronizedInfoByOrderAndConnectorId(Order order,
|
||||
String connectorId);
|
||||
OrderSyncInfo findLastSynchronizedInfoByOrderAndConnectorName(Order order,
|
||||
String connectorName);
|
||||
|
||||
/**
|
||||
* Search last synchronized infos for the specified
|
||||
* <code>{@link Order}</code> and <code>connectorId</code>
|
||||
* <code>{@link Order}</code> and <code>connectorName</code>
|
||||
*
|
||||
* @param order
|
||||
* the order to search for
|
||||
* @param connectorId
|
||||
* the connector-id
|
||||
* @param connectorName
|
||||
* the connector name
|
||||
* @return list of last synchronized infos
|
||||
*/
|
||||
List<OrderSyncInfo> findLastSynchronizedInfosByOrderAndConnectorId(
|
||||
Order order, String connectorId);
|
||||
List<OrderSyncInfo> findLastSynchronizedInfosByOrderAndConnectorName(
|
||||
Order order, String connectorName);
|
||||
|
||||
/**
|
||||
* Searches and returns <code>{@link OrderSyncInfo}</code> for the specified
|
||||
* <code>key</code> and <code>connectorId</code>
|
||||
* <code>key</code> and <code>connectorName</code>
|
||||
*
|
||||
* @param key
|
||||
* the unique key with in connector id
|
||||
* @param order the order
|
||||
* @param connectorId
|
||||
* the connector id
|
||||
* @param order
|
||||
* the order
|
||||
* @param connectorName
|
||||
* the connector name
|
||||
*/
|
||||
OrderSyncInfo findByKeyOrderAndConnectorId(String key, Order order, String connectorId);
|
||||
OrderSyncInfo findByKeyOrderAndConnectorName(String key, Order order,
|
||||
String connectorName);
|
||||
|
||||
/**
|
||||
* Finds the {@link OrderSyncInfo}s for the specified
|
||||
* <code>connectorId</code>
|
||||
* <code>connectorName</code>
|
||||
*
|
||||
* @param connectorId
|
||||
* the connectorId
|
||||
* @param connectorName
|
||||
* the connector name
|
||||
* @return a list of OrderSyncInfo if found and null if not
|
||||
*/
|
||||
List<OrderSyncInfo> findByConnectorId(String connectorId);
|
||||
List<OrderSyncInfo> findByConnectorName(String connectorName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,10 +41,10 @@ public class OrderSyncInfoDAO extends GenericDAOHibernate<OrderSyncInfo, Long>
|
|||
implements IOrderSyncInfoDAO {
|
||||
|
||||
@Override
|
||||
public OrderSyncInfo findLastSynchronizedInfoByOrderAndConnectorId(
|
||||
Order order, String connectorId) {
|
||||
List<OrderSyncInfo> orderSyncInfoList = findLastSynchronizedInfosByOrderAndConnectorId(
|
||||
order, connectorId);
|
||||
public OrderSyncInfo findLastSynchronizedInfoByOrderAndConnectorName(
|
||||
Order order, String connectorName) {
|
||||
List<OrderSyncInfo> orderSyncInfoList = findLastSynchronizedInfosByOrderAndConnectorName(
|
||||
order, connectorName);
|
||||
if (orderSyncInfoList == null || orderSyncInfoList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -53,28 +53,29 @@ public class OrderSyncInfoDAO extends GenericDAOHibernate<OrderSyncInfo, Long>
|
|||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<OrderSyncInfo> findLastSynchronizedInfosByOrderAndConnectorId(
|
||||
Order order, String connectorId) {
|
||||
public List<OrderSyncInfo> findLastSynchronizedInfosByOrderAndConnectorName(
|
||||
Order order, String connectorName) {
|
||||
Criteria criteria = getSession().createCriteria(OrderSyncInfo.class);
|
||||
criteria.add(Restrictions.eq("order", order));
|
||||
criteria.add(Restrictions.eq("connectorId", connectorId));
|
||||
criteria.add(Restrictions.eq("connectorName", connectorName));
|
||||
criteria.addOrder(org.hibernate.criterion.Order.desc("lastSyncDate"));
|
||||
return criteria.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderSyncInfo findByKeyOrderAndConnectorId(String key, Order order, String connectorId) {
|
||||
public OrderSyncInfo findByKeyOrderAndConnectorName(String key,
|
||||
Order order, String connectorName) {
|
||||
Criteria criteria = getSession().createCriteria(OrderSyncInfo.class);
|
||||
criteria.add(Restrictions.eq("key", key));
|
||||
criteria.add(Restrictions.eq("order", order));
|
||||
criteria.add(Restrictions.eq("connectorId", connectorId));
|
||||
criteria.add(Restrictions.eq("connectorName", connectorName));
|
||||
return (OrderSyncInfo) criteria.uniqueResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderSyncInfo> findByConnectorId(String connectorId) {
|
||||
public List<OrderSyncInfo> findByConnectorName(String connectorName) {
|
||||
Criteria criteria = getSession().createCriteria(OrderSyncInfo.class);
|
||||
criteria.add(Restrictions.eq("connectorId", connectorId));
|
||||
criteria.add(Restrictions.eq("connectorName", connectorName));
|
||||
return criteria.list();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.util.Date;
|
|||
import org.apache.commons.lang.Validate;
|
||||
import org.hibernate.validator.NotNull;
|
||||
import org.libreplan.business.common.BaseEntity;
|
||||
import org.libreplan.business.common.entities.Connector;
|
||||
|
||||
/**
|
||||
* OrderSyncInfo entity. This entity holds order synchronization info. Each time
|
||||
|
|
@ -35,7 +36,7 @@ import org.libreplan.business.common.BaseEntity;
|
|||
* <ul>
|
||||
* <li>lastSyncDate: last date where synchronization took place</li>
|
||||
* <li>key: an identifier, which connector's key is last synchronized</li>
|
||||
* <li>connectorId: an identifier to distinguish which connector has running the
|
||||
* <li>connectorName: the name of the {@link Connector} that has running the
|
||||
* synchronization</li>
|
||||
* <li>order: order that is synchronized</li>
|
||||
* </ul>
|
||||
|
|
@ -46,15 +47,15 @@ public class OrderSyncInfo extends BaseEntity {
|
|||
|
||||
private Date lastSyncDate;
|
||||
private String key;
|
||||
private String connectorId;
|
||||
private String connectorName;
|
||||
private Order order;
|
||||
|
||||
public static OrderSyncInfo create(String key, Order order,
|
||||
String connectorId) {
|
||||
String connectorName) {
|
||||
Validate.notEmpty(key);
|
||||
Validate.notNull(order);
|
||||
Validate.notEmpty(connectorId);
|
||||
return create(new OrderSyncInfo(key, order, connectorId));
|
||||
Validate.notEmpty(connectorName);
|
||||
return create(new OrderSyncInfo(key, order, connectorName));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -63,11 +64,11 @@ public class OrderSyncInfo extends BaseEntity {
|
|||
protected OrderSyncInfo() {
|
||||
}
|
||||
|
||||
private OrderSyncInfo(String key, Order order, String connectorId) {
|
||||
private OrderSyncInfo(String key, Order order, String connectorName) {
|
||||
this.lastSyncDate = new Date();
|
||||
this.key = key;
|
||||
this.order = order;
|
||||
this.connectorId = connectorId;
|
||||
this.connectorName = connectorName;
|
||||
}
|
||||
|
||||
@NotNull(message = "last synchronized date not specified")
|
||||
|
|
@ -88,13 +89,13 @@ public class OrderSyncInfo extends BaseEntity {
|
|||
this.key = key;
|
||||
}
|
||||
|
||||
@NotNull(message = "connector id not specified")
|
||||
public String getConnectorId() {
|
||||
return connectorId;
|
||||
@NotNull(message = "connector name not specified")
|
||||
public String getConnectorName() {
|
||||
return connectorName;
|
||||
}
|
||||
|
||||
public void setConnectorId(String connectorId) {
|
||||
this.connectorId = connectorId;
|
||||
public void setConnectorName(String connectorName) {
|
||||
this.connectorName = connectorName;
|
||||
}
|
||||
|
||||
public Order getOrder() {
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@
|
|||
<column name="key" type="VARCHAR(255)" >
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="connector_id" type="VARCHAR(255)" >
|
||||
<column name="connector_name" type="VARCHAR(255)" >
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="order_element_id" type="BIGINT" />
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@
|
|||
<version name="version" access="property" type="long" />
|
||||
<property name="lastSyncDate" column="last_sync_date" access="field" not-null="true"/>
|
||||
<property name="key" access="field" not-null="true"/>
|
||||
<property name="connectorId" column="connector_id" access="field" not-null="true"/>
|
||||
<property name="connectorName" column="connector_name" access="field" not-null="true"/>
|
||||
|
||||
<many-to-one name="order" class="Order">
|
||||
<column name="order_element_id" not-null="true"/>
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ public class ExportTimesheetsToTim implements IExportTimesheetsToTim {
|
|||
|
||||
List<SynchronizationInfo> syncInfos = new ArrayList<SynchronizationInfo>();
|
||||
|
||||
List<OrderSyncInfo> orderSyncInfos = orderSyncInfoDAO.findByConnectorId(PredefinedConnectors.TIM.getName());
|
||||
List<OrderSyncInfo> orderSyncInfos = orderSyncInfoDAO.findByConnectorName(PredefinedConnectors.TIM.getName());
|
||||
if (orderSyncInfos == null || orderSyncInfos.isEmpty()) {
|
||||
LOG.warn("No items found in 'OrderSyncInfo' to export to Tim");
|
||||
synchronizationInfo.addFailedReason(_("No items found in 'OrderSyncInfo' to export to Tim"));
|
||||
|
|
@ -257,7 +257,7 @@ public class ExportTimesheetsToTim implements IExportTimesheetsToTim {
|
|||
@Override
|
||||
public Void execute() {
|
||||
OrderSyncInfo orderSyncInfo = orderSyncInfoDAO
|
||||
.findByKeyOrderAndConnectorId(productCode,
|
||||
.findByKeyOrderAndConnectorName(productCode,
|
||||
order,
|
||||
PredefinedConnectors.TIM.getName());
|
||||
if (orderSyncInfo == null) {
|
||||
|
|
@ -321,7 +321,7 @@ public class ExportTimesheetsToTim implements IExportTimesheetsToTim {
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public OrderSyncInfo getOrderLastSyncInfo(Order order) {
|
||||
return orderSyncInfoDAO.findLastSynchronizedInfoByOrderAndConnectorId(
|
||||
return orderSyncInfoDAO.findLastSynchronizedInfoByOrderAndConnectorName(
|
||||
order, PredefinedConnectors.TIM.getName());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -477,7 +477,7 @@ public class JiraOrderElementSynchronizer implements IJiraOrderElementSynchroniz
|
|||
@Override
|
||||
public Void execute() {
|
||||
OrderSyncInfo orderSyncInfo = orderSyncInfoDAO
|
||||
.findByKeyOrderAndConnectorId(key, order,
|
||||
.findByKeyOrderAndConnectorName(key, order,
|
||||
PredefinedConnectors.JIRA.getName());
|
||||
if (orderSyncInfo == null) {
|
||||
orderSyncInfo = OrderSyncInfo.create(key, order,
|
||||
|
|
@ -494,7 +494,7 @@ public class JiraOrderElementSynchronizer implements IJiraOrderElementSynchroniz
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public OrderSyncInfo getOrderLastSyncInfo(Order order) {
|
||||
return orderSyncInfoDAO.findLastSynchronizedInfoByOrderAndConnectorId(
|
||||
return orderSyncInfoDAO.findLastSynchronizedInfoByOrderAndConnectorName(
|
||||
order, PredefinedConnectors.JIRA.getName());
|
||||
|
||||
}
|
||||
|
|
@ -512,7 +512,7 @@ public class JiraOrderElementSynchronizer implements IJiraOrderElementSynchroniz
|
|||
}
|
||||
|
||||
List<OrderSyncInfo> orderSyncInfos = orderSyncInfoDAO
|
||||
.findByConnectorId(PredefinedConnectors.JIRA.getName());
|
||||
.findByConnectorName(PredefinedConnectors.JIRA.getName());
|
||||
|
||||
synchronizationInfo = new SynchronizationInfo(_("Synchronization"));
|
||||
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ public class JiraTimesheetSynchronizer implements IJiraTimesheetSynchronizer {
|
|||
}
|
||||
|
||||
OrderSyncInfo orderSyncInfo = orderSyncInfoDAO
|
||||
.findLastSynchronizedInfoByOrderAndConnectorId(order,
|
||||
.findLastSynchronizedInfoByOrderAndConnectorName(order,
|
||||
PredefinedConnectors.JIRA.getName());
|
||||
if (orderSyncInfo == null) {
|
||||
synchronizationInfo.addFailedReason(_(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue