Issue #1543 Serialize DODS response rather than plugin data objects directly
- Remove proxy classes for Spring transactions, use interfaces as Spring recommends. Amend: Peer review comments. Set retrieval status to failed when payload is null. Change-Id: I458b13856302c8faceeef985c1c41115644520b7 Former-commit-id:0bdaf0babe
[formerly25faaa2af0
] [formerlydd8ca33fc4
] [formerly0bdaf0babe
[formerly25faaa2af0
] [formerlydd8ca33fc4
] [formerlyd143735ea8
[formerlydd8ca33fc4
[formerly 69f294183da4bbeb535b11c81550b1e9b4124ac6]]]] Former-commit-id:d143735ea8
Former-commit-id:018faeb591
[formerly6f821ed8c9
] [formerly ba20e1bd90048ad833da2d88ebbec80e0486dca1 [formerly9783dc4d9f
]] Former-commit-id: c8bed06596d9d427b321f153a9723a4d98817a9a [formerly922da948eb
] Former-commit-id:1d80262cf9
This commit is contained in:
parent
af4a42dffe
commit
cca5e664c4
56 changed files with 2046 additions and 646 deletions
|
@ -19,14 +19,14 @@
|
|||
**/
|
||||
package com.raytheon.uf.common.util;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* Utility class for collection types.
|
||||
* Utility class for collection types.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -35,6 +35,7 @@ import java.util.Set;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 13, 2012 740 djohnson Initial creation
|
||||
* Feb 12, 2013 1543 djohnson Add combining of arrays.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -81,4 +82,33 @@ public final class CollectionUtil {
|
|||
public static <T> Set<T> asSet(T... items) {
|
||||
return new HashSet<T>(Arrays.asList(items));
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine two arrays into a single array.
|
||||
*
|
||||
* @param objArray1
|
||||
* the first array
|
||||
* @param objArray2
|
||||
* the second array
|
||||
* @return the combined array, or null if both array references are null
|
||||
*/
|
||||
public static <T> T[] combine(Class<T> elementClass, T[] objArray1,
|
||||
T[] objArray2) {
|
||||
if (objArray1 == null && objArray2 != null) {
|
||||
return objArray2;
|
||||
} else if (objArray2 == null && objArray1 != null) {
|
||||
return objArray1;
|
||||
} else if (objArray1 == null && objArray2 == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
T[] array = (T[]) Array.newInstance(elementClass, objArray1.length
|
||||
+ objArray2.length);
|
||||
|
||||
System.arraycopy(objArray1, 0, array, 0, objArray1.length);
|
||||
System.arraycopy(objArray2, 0, array, objArray1.length,
|
||||
objArray2.length);
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,11 @@
|
|||
**/
|
||||
package com.raytheon.uf.common.util;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.hamcrest.Matchers.sameInstance;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -39,6 +43,7 @@ import org.junit.Test;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 13, 2012 740 djohnson Initial creation
|
||||
* Jul 26, 2012 955 djohnson Add isNullOrEmpty for {@link Collection}s.
|
||||
* Feb 12, 2013 1543 djohnson Test combining of arrays.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -80,4 +85,71 @@ public class CollectionUtilTest {
|
|||
public void testIsNullOrEmptyReturnsFalseForNonEmptyCollection() {
|
||||
assertFalse(CollectionUtil.isNullOrEmpty(Arrays.asList("not empty")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void twoAndThreeElementArraysCanBeCombinedIntoFiveElementArray() {
|
||||
Object[] objArray1 = new Object[] { new Object(), new Object(),
|
||||
new Object() };
|
||||
Object[] objArray2 = new Object[] { new Object(), new Object() };
|
||||
|
||||
Object[] combined = CollectionUtil.combine(Object.class, objArray1,
|
||||
objArray2);
|
||||
assertThat(combined.length, is(5));
|
||||
|
||||
for (int i = 0; i < objArray1.length; i++) {
|
||||
assertThat(combined[i], is(sameInstance(objArray1[i])));
|
||||
}
|
||||
|
||||
for (int i = 0; i < objArray2.length; i++) {
|
||||
assertThat(combined[i + 3], is(sameInstance(objArray2[i])));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void twoEmptyArraysCanBeCombinedIntoEmptyArray() {
|
||||
Object[] objArray1 = new Object[0];
|
||||
Object[] objArray2 = new Object[0];
|
||||
|
||||
Object[] combined = CollectionUtil.combine(Object.class, objArray1,
|
||||
objArray2);
|
||||
assertThat(combined.length, is(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullFirstArrayCanBeCombinedWithValidArray() {
|
||||
Object[] objArray1 = null;
|
||||
Object[] objArray2 = new Object[] { new Object(), new Object() };
|
||||
|
||||
Object[] combined = CollectionUtil.combine(Object.class, objArray1,
|
||||
objArray2);
|
||||
assertThat(combined.length, is(2));
|
||||
|
||||
for (int i = 0; i < objArray2.length; i++) {
|
||||
assertThat(combined[i], is(sameInstance(objArray2[i])));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullSecondArrayCanBeCombinedWithValidArray() {
|
||||
Object[] objArray1 = new Object[] { new Object(), new Object() };
|
||||
Object[] objArray2 = null;
|
||||
|
||||
Object[] combined = CollectionUtil.combine(Object.class, objArray1,
|
||||
objArray2);
|
||||
assertThat(combined.length, is(2));
|
||||
|
||||
for (int i = 0; i < objArray1.length; i++) {
|
||||
assertThat(combined[i], is(sameInstance(objArray1[i])));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void twoNullArraysCanBeCombinedToReturnNull() {
|
||||
Object[] objArray1 = null;
|
||||
Object[] objArray2 = null;
|
||||
|
||||
Object[] combined = CollectionUtil.combine(Object.class, objArray1,
|
||||
objArray2);
|
||||
assertThat(combined, is(nullValue()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.database.dao;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.persist.IPersistableDataObject;
|
||||
|
||||
/**
|
||||
* Interface defining a session managed dao.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 13, 2013 1543 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
* @param <IDENTIFIER>
|
||||
* the entity identifier type
|
||||
* @param <ENTITY>
|
||||
* the entity type
|
||||
*/
|
||||
public interface ISessionManagedDao<IDENTIFIER extends Serializable, ENTITY extends IPersistableDataObject<IDENTIFIER>> {
|
||||
|
||||
/**
|
||||
* Sets Hibernate session factory.
|
||||
*/
|
||||
void setSessionFactory(SessionFactory sessionFactory);
|
||||
|
||||
/**
|
||||
* Creates the object entry in the database
|
||||
*
|
||||
* @param obj
|
||||
* The object to be created in the database
|
||||
*/
|
||||
void create(final ENTITY obj);
|
||||
|
||||
/**
|
||||
* Updates the object entry in the database
|
||||
*
|
||||
* @param obj
|
||||
* The object to be created in the database
|
||||
*/
|
||||
void update(final ENTITY obj);
|
||||
|
||||
/**
|
||||
* Creates the object entry in the database
|
||||
*
|
||||
* @param obj
|
||||
* The object to be created in the database
|
||||
*/
|
||||
void createOrUpdate(final ENTITY obj);
|
||||
|
||||
/**
|
||||
* Persists all objects in the collection.
|
||||
*
|
||||
* @param objs
|
||||
* The objects to be persisted to the database
|
||||
*/
|
||||
void persistAll(final Collection<ENTITY> objs);
|
||||
|
||||
/**
|
||||
* Deletes the object entry in the database
|
||||
*
|
||||
* @param obj
|
||||
* The object to be created in the database
|
||||
*/
|
||||
void delete(final ENTITY obj);
|
||||
|
||||
/**
|
||||
* Delete all of the entities.
|
||||
*
|
||||
* @param objs
|
||||
*/
|
||||
void deleteAll(final Collection<ENTITY> objs);
|
||||
|
||||
/**
|
||||
* Get an entity by its id.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
* @return the entity
|
||||
*/
|
||||
ENTITY getById(IDENTIFIER id);
|
||||
|
||||
/**
|
||||
* Get all of the entities of this type.
|
||||
*
|
||||
* @return the entities
|
||||
*/
|
||||
List<ENTITY> getAll();
|
||||
}
|
|
@ -20,18 +20,22 @@
|
|||
|
||||
package com.raytheon.uf.edex.database.dao;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.impl.SessionFactoryImpl;
|
||||
import org.springframework.orm.hibernate3.HibernateTemplate;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.persist.IPersistableDataObject;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
||||
|
@ -56,7 +60,7 @@ import com.raytheon.uf.common.status.UFStatus;
|
|||
*/
|
||||
@Repository
|
||||
@Transactional
|
||||
public class SessionManagedDao {
|
||||
public abstract class SessionManagedDao<IDENTIFIER extends Serializable, ENTITY extends IPersistableDataObject<IDENTIFIER>> implements ISessionManagedDao<IDENTIFIER, ENTITY> {
|
||||
|
||||
protected static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(SessionManagedDao.class);
|
||||
|
@ -64,87 +68,93 @@ public class SessionManagedDao {
|
|||
protected HibernateTemplate template;
|
||||
|
||||
/**
|
||||
* Sets Hibernate session factory.
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Autowired
|
||||
@Override
|
||||
public void setSessionFactory(SessionFactory sessionFactory) {
|
||||
template = new HibernateTemplate(sessionFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the object entry in the database
|
||||
*
|
||||
* @param obj
|
||||
* The object to be created in the database
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void create(final Object obj) {
|
||||
@Override
|
||||
public void create(final ENTITY obj) {
|
||||
template.save(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the object entry in the database
|
||||
*
|
||||
* @param obj
|
||||
* The object to be created in the database
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void update(final Object obj) {
|
||||
@Override
|
||||
public void update(final ENTITY obj) {
|
||||
template.update(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the object entry in the database
|
||||
*
|
||||
* @param obj
|
||||
* The object to be created in the database
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void createOrUpdate(final Object obj) {
|
||||
@Override
|
||||
public void createOrUpdate(final ENTITY obj) {
|
||||
template.saveOrUpdate(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Persists all objects in the collection.
|
||||
*
|
||||
* @param objs
|
||||
* The objects to be persisted to the database
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void persistAll(final Collection<?> objs) {
|
||||
for (Object obj : objs) {
|
||||
@Override
|
||||
public void persistAll(final Collection<ENTITY> objs) {
|
||||
for (ENTITY obj : objs) {
|
||||
createOrUpdate(obj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the object entry in the database
|
||||
*
|
||||
* @param obj
|
||||
* The object to be created in the database
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void delete(final Object obj) {
|
||||
@Override
|
||||
public void delete(final ENTITY obj) {
|
||||
Object toDelete = template.merge(obj);
|
||||
template.delete(toDelete);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all of the entities.
|
||||
*
|
||||
* @param objs
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void deleteAll(final Collection<?> objs) {
|
||||
for (Object obj : objs) {
|
||||
@Override
|
||||
public void deleteAll(final Collection<ENTITY> objs) {
|
||||
for (ENTITY obj : objs) {
|
||||
delete(obj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ENTITY getById(IDENTIFIER id) {
|
||||
final Class<ENTITY> entityClass = getEntityClass();
|
||||
return entityClass.cast(template.get(entityClass, id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<ENTITY> getAll() {
|
||||
return query("from " + getEntityClass().getSimpleName(),
|
||||
Collections.<String, Object> emptyMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal convenience method for querying.
|
||||
*
|
||||
* @param <T>
|
||||
* @param queryString
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T extends Object> List<T> query(String queryString,
|
||||
protected List<ENTITY> query(String queryString,
|
||||
Map<String, Object> params) {
|
||||
final int numberOfParams = params.size();
|
||||
String[] paramNames = new String[numberOfParams];
|
||||
|
@ -162,21 +172,36 @@ public class SessionManagedDao {
|
|||
/**
|
||||
* Internal convenience method for returning a single result.
|
||||
*
|
||||
* @param <T>
|
||||
* @param queryString
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T extends Object> T uniqueResult(String queryString,
|
||||
protected ENTITY uniqueResult(String queryString,
|
||||
Map<String, Object> params) {
|
||||
final List<Object> results = query(queryString, params);
|
||||
final List<ENTITY> results = query(queryString, params);
|
||||
if (results.isEmpty()) {
|
||||
return null;
|
||||
} else if (results.size() > 1) {
|
||||
statusHandler.warn("More than one result returned for query ["
|
||||
+ queryString + "], only returning the first!");
|
||||
}
|
||||
return (T) results.get(0);
|
||||
return results.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hibernate dialect.
|
||||
*
|
||||
* @return the dialect.
|
||||
*/
|
||||
// TODO: Remove the requirement of this method
|
||||
public Dialect getDialect() {
|
||||
return ((SessionFactoryImpl) template.getSessionFactory()).getDialect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the entity class type.
|
||||
*
|
||||
* @return the entity class type
|
||||
*/
|
||||
protected abstract Class<ENTITY> getEntityClass();
|
||||
}
|
||||
|
|
|
@ -14,12 +14,23 @@
|
|||
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.BandwidthSubscriptionDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="subscriptionRetrievalDao"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.SubscriptionRetrievalDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="bandwidthDataSetUpdateDao"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.BandwidthDataSetUpdateDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="hibernateBandwidthDao"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
<property name="bandwidthAllocationDao" ref="bandwidthAllocationDao" />
|
||||
<property name="bandwidthSubscriptionDao" ref="bandwidthSubscriptionDao" />
|
||||
<property name="subscriptionRetrievalDao" ref="subscriptionRetrievalDao" />
|
||||
<property name="bandwidthDataSetUpdateDao" ref="bandwidthDataSetUpdateDao" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
|
@ -103,6 +103,7 @@
|
|||
<constructor-arg value="${bandwidth.default.retrieval.priority}" />
|
||||
<constructor-arg ref="retrievalManager" />
|
||||
<constructor-arg ref="bandwidthDao" />
|
||||
<constructor-arg ref="retrievalDao" />
|
||||
</bean>
|
||||
|
||||
<bean id="retrievalAgentManager"
|
||||
|
@ -110,6 +111,7 @@
|
|||
init-method="start">
|
||||
<constructor-arg ref="retrievalAgentNotifier" />
|
||||
<constructor-arg ref="retrievalAgents" />
|
||||
<constructor-arg ref="retrievalDao" />
|
||||
</bean>
|
||||
|
||||
<bean id="retrievalManager"
|
||||
|
@ -129,7 +131,9 @@
|
|||
<bean id="BandwidthManagerProcessor"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.processing.Processor" />
|
||||
<bean id="BandwidthManagerRetrieval"
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.RetrievalGenerationHandler" />
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.RetrievalGenerationHandler">
|
||||
<constructor-arg ref="retrievalDao" />
|
||||
</bean>
|
||||
<bean id="SubscriptionBundleSeparator"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.separator.SubscriptionBundleSeparator" />
|
||||
</beans>
|
||||
|
|
|
@ -522,7 +522,7 @@ abstract class BandwidthManager extends
|
|||
if (z.size() > 0) {
|
||||
retrieval.setStatus(RetrievalStatus.READY);
|
||||
}
|
||||
bandwidthDao.update(retrieval);
|
||||
bandwidthDao.store(retrieval);
|
||||
|
||||
// Add SubscriptionRetrieval to the list to schedule..
|
||||
reservations.add(retrieval);
|
||||
|
@ -652,7 +652,7 @@ abstract class BandwidthManager extends
|
|||
retrieval.setEndTime(endTime);
|
||||
// Store the SubscriptionRetrieval - retrievalManager expects
|
||||
// the BandwidthAllocations to already be stored.
|
||||
bandwidthDao.update(retrieval);
|
||||
bandwidthDao.store(retrieval);
|
||||
reservations.add(retrieval);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,8 +37,8 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
import com.raytheon.uf.common.util.ReflectionUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthDataSetUpdate;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
||||
|
@ -493,7 +493,7 @@ class InMemoryBandwidthDao implements IBandwidthDao {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void update(BandwidthAllocation allocation) {
|
||||
public void createOrUpdate(BandwidthAllocation allocation) {
|
||||
replaceOldOrAddToCollection(bandwidthAllocations, allocation);
|
||||
}
|
||||
|
||||
|
@ -509,9 +509,8 @@ class InMemoryBandwidthDao implements IBandwidthDao {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void update(SubscriptionRetrieval subscriptionRetrieval) {
|
||||
replaceOldOrAddToCollection(bandwidthAllocations,
|
||||
subscriptionRetrieval);
|
||||
public void update(BandwidthAllocation allocation) {
|
||||
replaceOldOrAddToCollection(bandwidthAllocations, allocation);
|
||||
}
|
||||
|
||||
private <T extends IPersistableDataObject<Long>> void replaceOldOrAddToCollection(
|
||||
|
|
|
@ -328,7 +328,7 @@ public interface IBandwidthDao {
|
|||
* @param allocation
|
||||
* The BandwidthAllocation to store.
|
||||
*/
|
||||
void update(BandwidthAllocation allocation);
|
||||
void createOrUpdate(BandwidthAllocation allocation);
|
||||
|
||||
/**
|
||||
* Update a BandwidthSubscription in the database.
|
||||
|
@ -339,12 +339,12 @@ public interface IBandwidthDao {
|
|||
void update(BandwidthSubscription dao);
|
||||
|
||||
/**
|
||||
* Update a SubscriptionRetrieval in the database.
|
||||
* Update a BandwidthAllocation in the database.
|
||||
*
|
||||
* @param subscriptionRetrieval
|
||||
* The SubscriptionRetrieval to store.
|
||||
* @param bandwidthAllocation
|
||||
* The bandwidthAllocation to update.
|
||||
*/
|
||||
void update(SubscriptionRetrieval subscriptionRetrieval);
|
||||
void update(BandwidthAllocation allocation);
|
||||
|
||||
/**
|
||||
* Find all bandwidth allocations in the specified state.
|
||||
|
|
|
@ -19,11 +19,12 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.hibernate;
|
||||
|
||||
import com.raytheon.uf.edex.database.dao.SessionManagedDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
|
||||
|
||||
/**
|
||||
* {@link SessionManagedDao} for {@link BandwidthAllocation}s.
|
||||
* DAO that handles {@link BandwidthAllocation} instances. Intentionally
|
||||
* package-private as Spring reflectively creates it, and application code must
|
||||
* rely on the interface.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -31,20 +32,22 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 07, 2013 1543 djohnson Initial creation
|
||||
* Feb 13, 2013 1543 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class BandwidthAllocationDao extends SessionManagedDao {
|
||||
class BandwidthAllocationDao extends
|
||||
BaseBandwidthAllocationDao<BandwidthAllocation> implements IBandwidthAllocationDao {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public BandwidthAllocationDao() {
|
||||
super();
|
||||
@Override
|
||||
protected Class<BandwidthAllocation> getEntityClass() {
|
||||
return BandwidthAllocation.class;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.hibernate;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.edex.database.dao.SessionManagedDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthDataSetUpdate;
|
||||
|
||||
/**
|
||||
* DAO that handles {@link BandwidthDataSetUpdate} instances. Intentionally
|
||||
* package-private as Spring reflectively creates it, and application code must
|
||||
* rely on the interface.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 13, 2013 1543 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
class BandwidthDataSetUpdateDao extends
|
||||
SessionManagedDao<Long, BandwidthDataSetUpdate> implements IBandwidthDataSetUpdateDao {
|
||||
|
||||
private static final String GET_DATASETMETADATA_BY_PROVIDER_AND_DATASET = "from BandwidthDataSetUpdate d where "
|
||||
+ "d.providerName = :providerName and "
|
||||
+ "d.dataSetName = :dataSetName order by dataSetBaseTime desc";
|
||||
|
||||
private static final String GET_DATASETMETADATA_BY_PROVIDER_AND_DATASET_AND_BASEREFERENCETIME = "from BandwidthDataSetUpdate d where "
|
||||
+ "d.providerName = :providerName and "
|
||||
+ "d.dataSetName = :dataSetName and "
|
||||
+ "d.dataSetBaseTime = :dataSetBaseTime "
|
||||
+ "order by dataSetBaseTime desc";
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<BandwidthDataSetUpdate> getEntityClass() {
|
||||
return BandwidthDataSetUpdate.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<BandwidthDataSetUpdate> getByProviderDataSet(
|
||||
String providerName, String dataSetName) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("providerName", providerName);
|
||||
params.put("dataSetName", dataSetName);
|
||||
return query(GET_DATASETMETADATA_BY_PROVIDER_AND_DATASET, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<BandwidthDataSetUpdate> getByProviderDataSetReferenceTime(
|
||||
String providerName, String dataSetName, Calendar baseReferenceTime) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("providerName", providerName);
|
||||
params.put("dataSetName", dataSetName);
|
||||
params.put("dataSetBaseTime", baseReferenceTime);
|
||||
return query(
|
||||
GET_DATASETMETADATA_BY_PROVIDER_AND_DATASET_AND_BASEREFERENCETIME,
|
||||
params);
|
||||
}
|
||||
|
||||
}
|
|
@ -19,11 +19,19 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.hibernate;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.edex.database.dao.SessionManagedDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
|
||||
|
||||
/**
|
||||
* Data access object for {@link BandwidthSubscription} instances.
|
||||
* Data access object for {@link BandwidthSubscription} instances. Intentionally
|
||||
* package-private as Spring reflectively creates it, and application code must
|
||||
* rely on the interface.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -38,7 +46,26 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
|
|||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class BandwidthSubscriptionDao extends SessionManagedDao {
|
||||
class BandwidthSubscriptionDao extends
|
||||
SessionManagedDao<Long, BandwidthSubscription> implements
|
||||
IBandwidthSubscriptionDao {
|
||||
|
||||
private static final String GET_SUBSCRIPTIONDAO_BY_PROVIDER_AND_DATASET_AND_BASEREFERENCETIME = "from BandwidthSubscription sub where "
|
||||
+ " sub.provider = :provider and "
|
||||
+ " sub.dataSetName = :dataSetName and "
|
||||
+ " sub.baseReferenceTime = :baseReferenceTime";
|
||||
|
||||
private static final String GET_SUBSCRIPTIONDAO_BY_REGISTRY_ID_AND_BASEREFERENCETIME = "from BandwidthSubscription sub where "
|
||||
+ "sub.registryId = :registryId and "
|
||||
+ "sub.baseReferenceTime = :baseReferenceTime";
|
||||
|
||||
private static final String GET_SUBSCRIPTIONDAO_BY_REGISTRYID = "from BandwidthSubscription sub where "
|
||||
+ "sub.registryId = :registryId";
|
||||
|
||||
private static final String GET_SUBSCRIPTIONDAO_BY_SUBSCRIPTION = "from BandwidthSubscription sub where "
|
||||
+ "sub.owner = :owner and "
|
||||
+ "sub.provider = :provider and "
|
||||
+ "sub.name = :name and " + "sub.dataSetName = :dataSetName";
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -46,4 +73,65 @@ public class BandwidthSubscriptionDao extends SessionManagedDao {
|
|||
public BandwidthSubscriptionDao() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<BandwidthSubscription> getEntityClass() {
|
||||
return BandwidthSubscription.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public BandwidthSubscription getByRegistryIdReferenceTime(
|
||||
String registryId, Calendar baseReferenceTime) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("registryId", registryId);
|
||||
params.put("baseReferenceTime", baseReferenceTime);
|
||||
return uniqueResult(
|
||||
GET_SUBSCRIPTIONDAO_BY_REGISTRY_ID_AND_BASEREFERENCETIME,
|
||||
params);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<BandwidthSubscription> getBySubscription(
|
||||
Subscription subscription) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("owner", subscription.getOwner());
|
||||
params.put("provider", subscription.getProvider());
|
||||
params.put("name", subscription.getName());
|
||||
params.put("dataSetName", subscription.getDataSetName());
|
||||
return query(GET_SUBSCRIPTIONDAO_BY_SUBSCRIPTION, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<BandwidthSubscription> getByRegistryId(String registryId) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("registryId", registryId);
|
||||
return query(GET_SUBSCRIPTIONDAO_BY_REGISTRYID, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<BandwidthSubscription> getByProviderDataSetReferenceTime(
|
||||
String provider, String dataSetName, Calendar baseReferenceTime) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("provider", provider);
|
||||
params.put("dataSetName", dataSetName);
|
||||
params.put("baseReferenceTime", baseReferenceTime);
|
||||
return query(
|
||||
GET_SUBSCRIPTIONDAO_BY_PROVIDER_AND_DATASET_AND_BASEREFERENCETIME,
|
||||
params);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.hibernate;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.edex.database.dao.SessionManagedDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
|
||||
|
||||
/**
|
||||
* Abstract DAO instance providing common queries among
|
||||
* {@link BandwidthAllocation} DAOs.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 13, 2013 1543 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
abstract class BaseBandwidthAllocationDao<ENTITY extends BandwidthAllocation>
|
||||
extends SessionManagedDao<Long, ENTITY> implements IBaseBandwidthAllocationDao<ENTITY> {
|
||||
|
||||
private static final String GET_BANDWIDTH_ALLOCATIONS_BY_SUBSCRIPTION_ID = "from %s res where res.bandwidthSubscription.id = :subscriptionId";
|
||||
|
||||
private static final String GET_BANDWIDTH_ALLOCATIONS_BY_NETWORK = "from %s res where res.network = :network";
|
||||
|
||||
private static final String GET_BANDWIDTH_ALLOCATIONS_BY_STATE = "from %s res where res.status = :state";
|
||||
|
||||
private static final String GET_DEFERRED = "from %s alloc where "
|
||||
+ "alloc.status = :status and "
|
||||
+ "alloc.network = :network and "
|
||||
+ "alloc.endTime <= :endTime";
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<ENTITY> getBySubscriptionId(Long subscriptionId) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("subscriptionId", subscriptionId);
|
||||
return query(String.format(
|
||||
GET_BANDWIDTH_ALLOCATIONS_BY_SUBSCRIPTION_ID, getEntityClass()
|
||||
.getSimpleName()), params);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<ENTITY> getByNetwork(Network network) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("network", network);
|
||||
return query(String.format(GET_BANDWIDTH_ALLOCATIONS_BY_NETWORK,
|
||||
getEntityClass().getSimpleName()), params);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<ENTITY> getByState(RetrievalStatus state) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("state", state);
|
||||
return query(String.format(GET_BANDWIDTH_ALLOCATIONS_BY_STATE,
|
||||
getEntityClass().getSimpleName()), params);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<ENTITY> getDeferred(Network network,
|
||||
Calendar endTime) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("status", RetrievalStatus.DEFERRED);
|
||||
params.put("network", network);
|
||||
params.put("endTime", endTime);
|
||||
return query(
|
||||
String.format(GET_DEFERRED, getEntityClass().getSimpleName()),
|
||||
params);
|
||||
}
|
||||
}
|
|
@ -20,21 +20,17 @@
|
|||
package com.raytheon.uf.edex.datadelivery.bandwidth.hibernate;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.impl.SessionFactoryImpl;
|
||||
import org.hibernate.jdbc.Work;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataSetMetaData;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.edex.database.dao.SessionManagedDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthDataSetUpdate;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
|
||||
|
@ -55,6 +51,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
* Oct 23, 2012 1286 djohnson Extracted from BandwidthContextFactory.
|
||||
* Feb 07, 2013 1543 djohnson Moved session management context to CoreDao.
|
||||
* Feb 11, 2013 1543 djohnson Use Spring transactions.
|
||||
* Feb 13, 2013 1543 djohnson Converted into a service, created new DAOs as required.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -62,88 +59,21 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
* @version 1.0
|
||||
*/
|
||||
@Transactional
|
||||
@Repository
|
||||
// TODO: Split service functionality from DAO functionality
|
||||
public class HibernateBandwidthDao extends SessionManagedDao implements
|
||||
IBandwidthDao {
|
||||
@Service
|
||||
public class HibernateBandwidthDao implements IBandwidthDao {
|
||||
|
||||
private BandwidthAllocationDao bandwidthAllocationDao;
|
||||
private IBandwidthAllocationDao bandwidthAllocationDao;
|
||||
|
||||
private BandwidthSubscriptionDao bandwidthSubscriptionDao;
|
||||
private ISubscriptionRetrievalDao subscriptionRetrievalDao;
|
||||
|
||||
private static final String GET_BANDWIDTH_ALLOCATIONS_BY_NETWORK = "from BandwidthAllocation res where res.network = :network";
|
||||
private IBandwidthSubscriptionDao bandwidthSubscriptionDao;
|
||||
|
||||
private static final String GET_BANDWIDTH_ALLOCATIONS_BY_STATE = "from BandwidthAllocation res where res.status = :state";
|
||||
|
||||
private static final String GET_BANDWIDTH_ALLOCATIONS_BY_SUBSCRIPTION_ID = "from BandwidthAllocation res where res.bandwidthSubscription.id = :subscriptionId";
|
||||
|
||||
private static final String GET_DATASETMETADATA_BY_PROVIDER_AND_DATASET = "from BandwidthDataSetUpdate d where "
|
||||
+ "d.providerName = :providerName and "
|
||||
+ "d.dataSetName = :dataSetName order by dataSetBaseTime desc";
|
||||
|
||||
private static final String GET_DATASETMETADATA_BY_PROVIDER_AND_DATASET_AND_BASEREFERENCETIME = "from BandwidthDataSetUpdate d where "
|
||||
+ "d.providerName = :providerName and "
|
||||
+ "d.dataSetName = :dataSetName and "
|
||||
+ "d.dataSetBaseTime = :dataSetBaseTime "
|
||||
+ "order by dataSetBaseTime desc";
|
||||
|
||||
private static final String GET_DEFERRED = "from BandwidthAllocation alloc where "
|
||||
+ "alloc.status = :status and "
|
||||
+ "alloc.network = :network and "
|
||||
+ "alloc.endTime <= :endTime";
|
||||
|
||||
private static final String GET_SUBSCRIPTIONDAO = "from BandwidthSubscription sub order by sub.baseReferenceTime asc";
|
||||
|
||||
private static final String GET_SUBSCRIPTIONDAO_BY_PROVIDER_AND_DATASET_AND_BASEREFERENCETIME = "from BandwidthSubscription sub where "
|
||||
+ " sub.provider = :provider and "
|
||||
+ " sub.dataSetName = :dataSetName and "
|
||||
+ " sub.baseReferenceTime = :baseReferenceTime";
|
||||
|
||||
private static final String GET_SUBSCRIPTIONDAO_BY_REGISTRY_ID_AND_BASEREFERENCETIME = "from BandwidthSubscription sub where "
|
||||
+ "sub.registryId = :registryId and "
|
||||
+ "sub.baseReferenceTime = :baseReferenceTime";
|
||||
|
||||
private static final String GET_SUBSCRIPTIONDAO_BY_REGISTRYID = "from BandwidthSubscription sub where "
|
||||
+ "sub.registryId = :registryId";
|
||||
|
||||
private static final String GET_SUBSCRIPTIONDAO_BY_SUBSCRIPTION = "from BandwidthSubscription sub where "
|
||||
+ "sub.owner = :owner and "
|
||||
+ "sub.provider = :provider and "
|
||||
+ "sub.name = :name and " + "sub.dataSetName = :dataSetName";
|
||||
|
||||
private static final String GET_SUBSCRIPTIONRETRIEVAL_BY_IDENTIFIER = "from SubscriptionRetrieval sr where "
|
||||
+ "sr.id = :identifier";
|
||||
|
||||
private static final String GET_SUBSCRIPTIONRETRIEVAL_BY_PROVIDER_AND_DATASET_BASE = "from SubscriptionRetrieval sr where "
|
||||
+ " sr.bandwidthSubscription.id in ("
|
||||
+ " select sub.id from BandwidthSubscription sub where "
|
||||
+ " sub.provider = :provider and "
|
||||
+ " sub.dataSetName = :dataSetName";
|
||||
|
||||
private static final String GET_SUBSCRIPTIONRETRIEVAL_BY_PROVIDER_AND_DATASET = GET_SUBSCRIPTIONRETRIEVAL_BY_PROVIDER_AND_DATASET_BASE
|
||||
+ ")";
|
||||
|
||||
private static final String GET_SUBSCRIPTIONRETRIEVAL_BY_PROVIDER_AND_DATASET_AND_BASEREFERENCETIME = GET_SUBSCRIPTIONRETRIEVAL_BY_PROVIDER_AND_DATASET_BASE
|
||||
+ " and sub.baseReferenceTime = :baseReferenceTime)";
|
||||
|
||||
private static final String GET_SUBSCRIPTIONRETRIEVAL_BY_SUBSCRIPTIONID = "from SubscriptionRetrieval sr where "
|
||||
+ "sr.bandwidthSubscription.id = :subscriptionId";
|
||||
|
||||
private static HibernateBandwidthDao instance;
|
||||
|
||||
/**
|
||||
* @return the instance
|
||||
*/
|
||||
public static HibernateBandwidthDao getInstance() {
|
||||
return instance;
|
||||
}
|
||||
private IBandwidthDataSetUpdateDao bandwidthDataSetUpdateDao;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public HibernateBandwidthDao() {
|
||||
// TODO: Don't use a static instance
|
||||
HibernateBandwidthDao.instance = this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -151,9 +81,7 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
*/
|
||||
@Override
|
||||
public List<BandwidthAllocation> getBandwidthAllocations(Long subscriptionId) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("subscriptionId", subscriptionId);
|
||||
return query(GET_BANDWIDTH_ALLOCATIONS_BY_SUBSCRIPTION_ID, params);
|
||||
return bandwidthAllocationDao.getBySubscriptionId(subscriptionId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -161,9 +89,7 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
*/
|
||||
@Override
|
||||
public List<BandwidthAllocation> getBandwidthAllocations(Network network) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("network", network);
|
||||
return query(GET_BANDWIDTH_ALLOCATIONS_BY_NETWORK, params);
|
||||
return bandwidthAllocationDao.getByNetwork(network);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -172,9 +98,7 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
@Override
|
||||
public List<BandwidthAllocation> getBandwidthAllocationsInState(
|
||||
RetrievalStatus state) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("state", state);
|
||||
return query(GET_BANDWIDTH_ALLOCATIONS_BY_STATE, params);
|
||||
return bandwidthAllocationDao.getByState(state);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -183,10 +107,8 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
@Override
|
||||
public List<BandwidthDataSetUpdate> getBandwidthDataSetUpdate(
|
||||
String providerName, String dataSetName) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("providerName", providerName);
|
||||
params.put("dataSetName", dataSetName);
|
||||
return query(GET_DATASETMETADATA_BY_PROVIDER_AND_DATASET, params);
|
||||
return bandwidthDataSetUpdateDao.getByProviderDataSet(providerName,
|
||||
dataSetName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -195,13 +117,8 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
@Override
|
||||
public List<BandwidthDataSetUpdate> getBandwidthDataSetUpdate(
|
||||
String providerName, String dataSetName, Calendar baseReferenceTime) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("providerName", providerName);
|
||||
params.put("dataSetName", dataSetName);
|
||||
params.put("dataSetBaseTime", baseReferenceTime);
|
||||
return query(
|
||||
GET_DATASETMETADATA_BY_PROVIDER_AND_DATASET_AND_BASEREFERENCETIME,
|
||||
params);
|
||||
return bandwidthDataSetUpdateDao.getByProviderDataSetReferenceTime(
|
||||
providerName, dataSetName, baseReferenceTime);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -210,11 +127,7 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
@Override
|
||||
public List<BandwidthAllocation> getDeferred(Network network,
|
||||
Calendar endTime) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("status", RetrievalStatus.DEFERRED);
|
||||
params.put("network", network);
|
||||
params.put("endTime", endTime);
|
||||
return query(GET_DEFERRED, params);
|
||||
return bandwidthAllocationDao.getDeferred(network, endTime);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -224,7 +137,7 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
* @return The Dialect.
|
||||
*/
|
||||
public Dialect getDialect() {
|
||||
return ((SessionFactoryImpl) template.getSessionFactory()).getDialect();
|
||||
return subscriptionRetrievalDao.getDialect();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -232,8 +145,7 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
*/
|
||||
@Override
|
||||
public BandwidthSubscription getBandwidthSubscription(long identifier) {
|
||||
return BandwidthSubscription.class.cast(template.get(
|
||||
BandwidthSubscription.class, Long.valueOf(identifier)));
|
||||
return bandwidthSubscriptionDao.getById(identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -242,12 +154,8 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
@Override
|
||||
public BandwidthSubscription getBandwidthSubscription(String registryId,
|
||||
Calendar baseReferenceTime) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("registryId", registryId);
|
||||
params.put("baseReferenceTime", baseReferenceTime);
|
||||
return uniqueResult(
|
||||
GET_SUBSCRIPTIONDAO_BY_REGISTRY_ID_AND_BASEREFERENCETIME,
|
||||
params);
|
||||
return bandwidthSubscriptionDao.getByRegistryIdReferenceTime(
|
||||
registryId, baseReferenceTime);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -256,13 +164,7 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
@Override
|
||||
public List<BandwidthSubscription> getBandwidthSubscription(
|
||||
Subscription subscription) {
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("owner", subscription.getOwner());
|
||||
params.put("provider", subscription.getProvider());
|
||||
params.put("name", subscription.getName());
|
||||
params.put("dataSetName", subscription.getDataSetName());
|
||||
return query(GET_SUBSCRIPTIONDAO_BY_SUBSCRIPTION, params);
|
||||
return bandwidthSubscriptionDao.getBySubscription(subscription);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -271,9 +173,7 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
@Override
|
||||
public List<BandwidthSubscription> getBandwidthSubscriptionByRegistryId(
|
||||
String registryId) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("registryId", registryId);
|
||||
return query(GET_SUBSCRIPTIONDAO_BY_REGISTRYID, params);
|
||||
return bandwidthSubscriptionDao.getByRegistryId(registryId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -281,10 +181,7 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
*/
|
||||
@Override
|
||||
public SubscriptionRetrieval getSubscriptionRetrieval(long identifier) {
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("identifier", identifier);
|
||||
return uniqueResult(GET_SUBSCRIPTIONRETRIEVAL_BY_IDENTIFIER, params);
|
||||
return subscriptionRetrievalDao.getById(identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -293,13 +190,8 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
@Override
|
||||
public List<SubscriptionRetrieval> getSubscriptionRetrievals(
|
||||
String provider, String dataSetName, Calendar baseReferenceTime) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("provider", provider);
|
||||
params.put("dataSetName", dataSetName);
|
||||
params.put("baseReferenceTime", baseReferenceTime);
|
||||
return query(
|
||||
GET_SUBSCRIPTIONRETRIEVAL_BY_PROVIDER_AND_DATASET_AND_BASEREFERENCETIME,
|
||||
params);
|
||||
return subscriptionRetrievalDao.getByProviderDataSetReferenceTime(
|
||||
provider, dataSetName, baseReferenceTime);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -308,19 +200,16 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
@Override
|
||||
public List<SubscriptionRetrieval> getSubscriptionRetrievals(
|
||||
String provider, String dataSetName) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("provider", provider);
|
||||
params.put("dataSetName", dataSetName);
|
||||
return query(GET_SUBSCRIPTIONRETRIEVAL_BY_PROVIDER_AND_DATASET, params);
|
||||
return subscriptionRetrievalDao.getByProviderDataSet(provider,
|
||||
dataSetName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<BandwidthSubscription> getBandwidthSubscriptions() {
|
||||
return template.find(GET_SUBSCRIPTIONDAO);
|
||||
return bandwidthSubscriptionDao.getAll();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -329,13 +218,8 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
@Override
|
||||
public List<BandwidthSubscription> getBandwidthSubscriptions(
|
||||
String provider, String dataSetName, Calendar baseReferenceTime) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("provider", provider);
|
||||
params.put("dataSetName", dataSetName);
|
||||
params.put("baseReferenceTime", baseReferenceTime);
|
||||
return query(
|
||||
GET_SUBSCRIPTIONDAO_BY_PROVIDER_AND_DATASET_AND_BASEREFERENCETIME,
|
||||
params);
|
||||
return bandwidthSubscriptionDao.getByProviderDataSetReferenceTime(
|
||||
provider, dataSetName, baseReferenceTime);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -345,12 +229,11 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
public BandwidthDataSetUpdate newBandwidthDataSetUpdate(
|
||||
DataSetMetaData dataSetMetaData) {
|
||||
|
||||
BandwidthDataSetUpdate dao = BandwidthUtil
|
||||
BandwidthDataSetUpdate entity = BandwidthUtil
|
||||
.newDataSetMetaDataDao(dataSetMetaData);
|
||||
bandwidthDataSetUpdateDao.create(entity);
|
||||
|
||||
create(dao);
|
||||
|
||||
return dao;
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -360,12 +243,13 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
public BandwidthSubscription newBandwidthSubscription(
|
||||
Subscription subscription, Calendar baseReferenceTime)
|
||||
throws SerializationException {
|
||||
BandwidthSubscription dao = BandwidthUtil
|
||||
BandwidthSubscription entity = BandwidthUtil
|
||||
.getSubscriptionDaoForSubscription(subscription,
|
||||
baseReferenceTime);
|
||||
|
||||
store(dao);
|
||||
return dao;
|
||||
bandwidthSubscriptionDao.create(entity);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -374,9 +258,7 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
@Override
|
||||
public List<SubscriptionRetrieval> querySubscriptionRetrievals(
|
||||
long subscriptionId) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("subscriptionId", subscriptionId);
|
||||
return query(GET_SUBSCRIPTIONRETRIEVAL_BY_SUBSCRIPTIONID, params);
|
||||
return subscriptionRetrievalDao.getBySubscriptionId(subscriptionId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -393,27 +275,19 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
*/
|
||||
@Override
|
||||
public void remove(BandwidthSubscription subscriptionDao) {
|
||||
List<BandwidthAllocation> bandwidthReservations = getBandwidthAllocations(subscriptionDao
|
||||
.getIdentifier());
|
||||
bandwidthAllocationDao.deleteAll(bandwidthReservations);
|
||||
List<SubscriptionRetrieval> bandwidthReservations = subscriptionRetrievalDao
|
||||
.getBySubscriptionId(subscriptionDao.getIdentifier());
|
||||
subscriptionRetrievalDao.deleteAll(bandwidthReservations);
|
||||
bandwidthSubscriptionDao.delete(subscriptionDao);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void store(BandwidthAllocation bandwidthAllocation) {
|
||||
update(bandwidthAllocation);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void store(List<SubscriptionRetrieval> retrievals) {
|
||||
for (SubscriptionRetrieval retrieval : retrievals) {
|
||||
store(retrieval);
|
||||
subscriptionRetrievalDao.create(retrieval);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -423,7 +297,23 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
@Override
|
||||
@Transactional
|
||||
public void store(BandwidthSubscription subscriptionDao) {
|
||||
template.save(subscriptionDao);
|
||||
bandwidthSubscriptionDao.create(subscriptionDao);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void store(BandwidthAllocation bandwidthAllocation) {
|
||||
bandwidthAllocationDao.create(bandwidthAllocation);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void createOrUpdate(BandwidthAllocation allocation) {
|
||||
bandwidthAllocationDao.createOrUpdate(allocation);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -431,7 +321,7 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
*/
|
||||
@Override
|
||||
public void update(BandwidthAllocation allocation) {
|
||||
createOrUpdate(allocation);
|
||||
bandwidthAllocationDao.update(allocation);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -439,15 +329,7 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
*/
|
||||
@Override
|
||||
public void update(BandwidthSubscription dao) {
|
||||
template.update(dao);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void update(SubscriptionRetrieval subscriptionRetrieval) {
|
||||
createOrUpdate(subscriptionRetrieval);
|
||||
bandwidthSubscriptionDao.update(dao);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -457,29 +339,29 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
* The unit of work to do.
|
||||
*/
|
||||
public void doWork(Work work) {
|
||||
template.getSessionFactory().getCurrentSession().doWork(work);
|
||||
subscriptionRetrievalDao.doWork(work);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the bandwidthAllocationDao
|
||||
* @return the subscriptionRetrievalDao
|
||||
*/
|
||||
public BandwidthAllocationDao getBandwidthAllocationDao() {
|
||||
return bandwidthAllocationDao;
|
||||
public ISubscriptionRetrievalDao getSubscriptionRetrievalDao() {
|
||||
return subscriptionRetrievalDao;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bandwidthAllocationDao
|
||||
* the bandwidthAllocationDao to set
|
||||
* @param subscriptionRetrievalDao
|
||||
* the subscriptionRetrievalDao to set
|
||||
*/
|
||||
public void setBandwidthAllocationDao(
|
||||
BandwidthAllocationDao bandwidthAllocationDao) {
|
||||
this.bandwidthAllocationDao = bandwidthAllocationDao;
|
||||
public void setSubscriptionRetrievalDao(
|
||||
ISubscriptionRetrievalDao bandwidthAllocationDao) {
|
||||
this.subscriptionRetrievalDao = bandwidthAllocationDao;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the subscriptionDaoDao
|
||||
*/
|
||||
public BandwidthSubscriptionDao getBandwidthSubscriptionDao() {
|
||||
public IBandwidthSubscriptionDao getBandwidthSubscriptionDao() {
|
||||
return bandwidthSubscriptionDao;
|
||||
}
|
||||
|
||||
|
@ -488,7 +370,40 @@ public class HibernateBandwidthDao extends SessionManagedDao implements
|
|||
* the subscriptionDaoDao to set
|
||||
*/
|
||||
public void setBandwidthSubscriptionDao(
|
||||
BandwidthSubscriptionDao bandwidthSubscriptionDao) {
|
||||
IBandwidthSubscriptionDao bandwidthSubscriptionDao) {
|
||||
this.bandwidthSubscriptionDao = bandwidthSubscriptionDao;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the bandwidthAllocationDao
|
||||
*/
|
||||
public IBandwidthAllocationDao getBandwidthAllocationDao() {
|
||||
return bandwidthAllocationDao;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bandwidthAllocationDao
|
||||
* the bandwidthAllocationDao to set
|
||||
*/
|
||||
public void setBandwidthAllocationDao(
|
||||
IBandwidthAllocationDao bandwidthAllocationDao) {
|
||||
this.bandwidthAllocationDao = bandwidthAllocationDao;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the bandwidthDataSetUpdateDao
|
||||
*/
|
||||
public IBandwidthDataSetUpdateDao getBandwidthDataSetUpdateDao() {
|
||||
return bandwidthDataSetUpdateDao;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bandwidthDataSetUpdateDao
|
||||
* the bandwidthDataSetUpdateDao to set
|
||||
*/
|
||||
public void setBandwidthDataSetUpdateDao(
|
||||
IBandwidthDataSetUpdateDao bandwidthDataSetUpdateDao) {
|
||||
this.bandwidthDataSetUpdateDao = bandwidthDataSetUpdateDao;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.hibernate;
|
||||
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
|
||||
|
||||
/**
|
||||
* BandwidthAllocation dao.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 13, 2013 1543 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
interface IBandwidthAllocationDao extends
|
||||
IBaseBandwidthAllocationDao<BandwidthAllocation> {
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.hibernate;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.edex.database.dao.ISessionManagedDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthDataSetUpdate;
|
||||
|
||||
/**
|
||||
* DAO for {@link BandwidthDataSetUpdate} instances.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 13, 2013 1543 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
interface IBandwidthDataSetUpdateDao extends
|
||||
ISessionManagedDao<Long, BandwidthDataSetUpdate> {
|
||||
|
||||
/**
|
||||
* Get {@link BandwidthDataSetUpdate} instances by the provider and dataset
|
||||
* name.
|
||||
*
|
||||
* @param providerName
|
||||
* @param dataSetName
|
||||
* @return
|
||||
*/
|
||||
List<BandwidthDataSetUpdate> getByProviderDataSet(String providerName,
|
||||
String dataSetName);
|
||||
|
||||
/**
|
||||
* Get {@link BandwidthDataSetUpdate} instances by the provider name,
|
||||
* dataset name, and base reference time.
|
||||
*
|
||||
* @param providerName
|
||||
* @param dataSetName
|
||||
* @param baseReferenceTime
|
||||
* @return
|
||||
*/
|
||||
List<BandwidthDataSetUpdate> getByProviderDataSetReferenceTime(
|
||||
String providerName, String dataSetName, Calendar baseReferenceTime);
|
||||
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.hibernate;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.edex.database.dao.ISessionManagedDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
|
||||
|
||||
/**
|
||||
* DAO interface for {@link BandwidthSubscription}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 13, 2013 1543 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
interface IBandwidthSubscriptionDao extends
|
||||
ISessionManagedDao<Long, BandwidthSubscription> {
|
||||
|
||||
/**
|
||||
* Get {@link BandwidthSubscription} instances by the subscription object's
|
||||
* registry id and a base reference time.
|
||||
*
|
||||
* @param registryId
|
||||
* @param baseReferenceTime
|
||||
* @return
|
||||
*/
|
||||
BandwidthSubscription getByRegistryIdReferenceTime(String registryId,
|
||||
Calendar baseReferenceTime);
|
||||
|
||||
/**
|
||||
* Get {@link BandwidthSubscription} instances by the subscription object's
|
||||
* registry id.
|
||||
*
|
||||
* @param subscription
|
||||
* @return
|
||||
*/
|
||||
List<BandwidthSubscription> getBySubscription(Subscription subscription);
|
||||
|
||||
/**
|
||||
* Get {@link BandwidthSubscription} instances by the subscription object's
|
||||
* registry id.
|
||||
*
|
||||
* @param registryId
|
||||
* @return
|
||||
*/
|
||||
List<BandwidthSubscription> getByRegistryId(String registryId);
|
||||
|
||||
/**
|
||||
* Get {@link BandwidthSubscription} instances by the provider name, dataset
|
||||
* name, and base reference time.
|
||||
*
|
||||
* @param provider
|
||||
* @param dataSetName
|
||||
* @param baseReferenceTime
|
||||
* @return
|
||||
*/
|
||||
List<BandwidthSubscription> getByProviderDataSetReferenceTime(
|
||||
String provider, String dataSetName, Calendar baseReferenceTime);
|
||||
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.hibernate;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.edex.database.dao.ISessionManagedDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
|
||||
|
||||
/**
|
||||
* Base DAO interface for bandwidth allocations.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 13, 2013 1543 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
* @param <ENTITY>
|
||||
*/
|
||||
interface IBaseBandwidthAllocationDao<ENTITY extends BandwidthAllocation>
|
||||
extends ISessionManagedDao<Long, ENTITY> {
|
||||
|
||||
/**
|
||||
* Get by the subscription id.
|
||||
*
|
||||
* @param subscriptionId
|
||||
* the subscription id
|
||||
* @return
|
||||
*/
|
||||
List<ENTITY> getBySubscriptionId(Long subscriptionId);
|
||||
|
||||
/**
|
||||
* Get by the network.
|
||||
*
|
||||
* @param network
|
||||
* @return
|
||||
*/
|
||||
List<ENTITY> getByNetwork(Network network);
|
||||
|
||||
/**
|
||||
* Get by retrieval status.
|
||||
*
|
||||
* @param state
|
||||
* @return
|
||||
*/
|
||||
List<ENTITY> getByState(RetrievalStatus state);
|
||||
|
||||
/**
|
||||
* Get deferred bandwidth allocations for the network and end time.
|
||||
*
|
||||
* @param network
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
List<ENTITY> getDeferred(Network network, Calendar endTime);
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.hibernate;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.jdbc.Work;
|
||||
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
|
||||
|
||||
/**
|
||||
* DAO for {@link SubscriptionRetrieval} instances.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 13, 2013 1543 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
interface ISubscriptionRetrievalDao extends
|
||||
IBaseBandwidthAllocationDao<SubscriptionRetrieval> {
|
||||
|
||||
/**
|
||||
* Get by provider name, dataset name, and base reference time.
|
||||
*
|
||||
* @param provider
|
||||
* @param dataSetName
|
||||
* @param baseReferenceTime
|
||||
* @return
|
||||
*/
|
||||
List<SubscriptionRetrieval> getByProviderDataSetReferenceTime(
|
||||
String provider, String dataSetName, Calendar baseReferenceTime);
|
||||
|
||||
/**
|
||||
* Get by provider and dataset names.
|
||||
*
|
||||
* @param provider
|
||||
* @param dataSetName
|
||||
* @return
|
||||
*/
|
||||
List<SubscriptionRetrieval> getByProviderDataSet(String provider,
|
||||
String dataSetName);
|
||||
|
||||
/**
|
||||
* Do arbitrary work.
|
||||
*
|
||||
* @param work
|
||||
* work
|
||||
*/
|
||||
// TODO: It would be nice to remove this method, if possible
|
||||
void doWork(Work work);
|
||||
|
||||
/**
|
||||
* Get the hibernate dialect.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
// TODO: It would be nice to remove this method, if possible
|
||||
Dialect getDialect();
|
||||
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.hibernate;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.jdbc.Work;
|
||||
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
|
||||
|
||||
/**
|
||||
* * DAO that handles {@link SubscriptionRetrieval} instances. Intentionally
|
||||
* package-private as Spring reflectively creates it, and application code must
|
||||
* rely on the interface.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 13, 2013 1543 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
class SubscriptionRetrievalDao extends
|
||||
BaseBandwidthAllocationDao<SubscriptionRetrieval> implements ISubscriptionRetrievalDao {
|
||||
|
||||
private static final String GET_SUBSCRIPTIONRETRIEVAL_BY_PROVIDER_AND_DATASET_BASE = "from SubscriptionRetrieval sr where "
|
||||
+ " sr.bandwidthSubscription.id in ("
|
||||
+ " select sub.id from BandwidthSubscription sub where "
|
||||
+ " sub.provider = :provider and "
|
||||
+ " sub.dataSetName = :dataSetName";
|
||||
|
||||
private static final String GET_SUBSCRIPTIONRETRIEVAL_BY_PROVIDER_AND_DATASET = GET_SUBSCRIPTIONRETRIEVAL_BY_PROVIDER_AND_DATASET_BASE
|
||||
+ ")";
|
||||
|
||||
private static final String GET_SUBSCRIPTIONRETRIEVAL_BY_PROVIDER_AND_DATASET_AND_BASEREFERENCETIME = GET_SUBSCRIPTIONRETRIEVAL_BY_PROVIDER_AND_DATASET_BASE
|
||||
+ " and sub.baseReferenceTime = :baseReferenceTime)";
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<SubscriptionRetrieval> getEntityClass() {
|
||||
return SubscriptionRetrieval.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<SubscriptionRetrieval> getByProviderDataSetReferenceTime(
|
||||
String provider, String dataSetName, Calendar baseReferenceTime) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("provider", provider);
|
||||
params.put("dataSetName", dataSetName);
|
||||
params.put("baseReferenceTime", baseReferenceTime);
|
||||
return query(
|
||||
GET_SUBSCRIPTIONRETRIEVAL_BY_PROVIDER_AND_DATASET_AND_BASEREFERENCETIME,
|
||||
params);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<SubscriptionRetrieval> getByProviderDataSet(
|
||||
String provider, String dataSetName) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("provider", provider);
|
||||
params.put("dataSetName", dataSetName);
|
||||
return query(GET_SUBSCRIPTIONRETRIEVAL_BY_PROVIDER_AND_DATASET, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
// TODO: Remove the requirement of this method
|
||||
public void doWork(Work work) {
|
||||
template.getSessionFactory().getCurrentSession().doWork(work);
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ import java.util.Map;
|
|||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -66,13 +66,13 @@ public class RetrievalAgentManager {
|
|||
* @param path
|
||||
*/
|
||||
public RetrievalAgentManager(final Object notifier,
|
||||
final Map<String, RetrievalAgent<?>> agents) {
|
||||
final Map<String, RetrievalAgent<?>> agents,
|
||||
IRetrievalDao retrievalDao) {
|
||||
this.notifier = notifier;
|
||||
this.agents = agents;
|
||||
|
||||
// set all Running state retrievals to pending
|
||||
RetrievalDao dao = RetrievalDao.getInstance();
|
||||
dao.resetRunningRetrievalsToPending();
|
||||
retrievalDao.resetRunningRetrievalsToPending();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
|
|
|
@ -99,12 +99,12 @@ public class RetrievalManager {
|
|||
+ bandwidthAllocation.getIdentifier()
|
||||
+ "]. The BandwidthAllocation will be deferred.");
|
||||
bandwidthAllocation.setStatus(RetrievalStatus.DEFERRED);
|
||||
bandwidthDao.update(bandwidthAllocation);
|
||||
bandwidthDao.createOrUpdate(bandwidthAllocation);
|
||||
} else {
|
||||
|
||||
synchronized (plan) {
|
||||
unscheduled.addAll(plan.schedule(bandwidthAllocation));
|
||||
bandwidthDao.update(bandwidthAllocation);
|
||||
bandwidthDao.createOrUpdate(bandwidthAllocation);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -116,7 +116,7 @@ public class RetrievalManager {
|
|||
// Update any unscheduled allocations
|
||||
for (BandwidthAllocation allocation : unscheduled) {
|
||||
allocation.setStatus(RetrievalStatus.UNSCHEDULED);
|
||||
bandwidthDao.update(allocation);
|
||||
bandwidthDao.createOrUpdate(allocation);
|
||||
}
|
||||
|
||||
return unscheduled;
|
||||
|
|
|
@ -130,7 +130,7 @@ public class RetrievalPlan {
|
|||
allocation = o;
|
||||
allocation.setStatus(RetrievalStatus.PROCESSING);
|
||||
// Persist this change to the database
|
||||
bandwidthDao.update(allocation);
|
||||
bandwidthDao.createOrUpdate(allocation);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -601,7 +601,7 @@ public class RetrievalPlan {
|
|||
BandwidthBucket bucket = buckets.firstEntry().getValue();
|
||||
bucket.add(allocation);
|
||||
allocation.setBandwidthBucket(bucket.getBucketStartTime());
|
||||
bandwidthDao.update(allocation);
|
||||
bandwidthDao.createOrUpdate(allocation);
|
||||
|
||||
bucket.add(allocation);
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
|
|||
import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalGenerator;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalManagerNotifyEvent;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.ServiceTypeFactory;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
|
||||
|
||||
/**
|
||||
|
@ -64,12 +64,16 @@ public class SubscriptionRetrievalAgent extends
|
|||
|
||||
private final IBandwidthDao bandwidthDao;
|
||||
|
||||
private final IRetrievalDao retrievalDao;
|
||||
|
||||
public SubscriptionRetrievalAgent(Network network, String destinationUri,
|
||||
final Object notifier, int defaultPriority,
|
||||
RetrievalManager retrievalManager, IBandwidthDao bandwidthDao) {
|
||||
RetrievalManager retrievalManager, IBandwidthDao bandwidthDao,
|
||||
IRetrievalDao retrievalDao) {
|
||||
super(network, destinationUri, notifier, retrievalManager);
|
||||
this.defaultPriority = defaultPriority;
|
||||
this.bandwidthDao = bandwidthDao;
|
||||
this.retrievalDao = retrievalDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -152,7 +156,6 @@ public class SubscriptionRetrievalAgent extends
|
|||
private boolean generateRetrieval(SubscriptionBundle bundle,
|
||||
Long subRetrievalKey) {
|
||||
|
||||
RetrievalDao dao = RetrievalDao.getInstance();
|
||||
// process the bundle into a retrieval
|
||||
RetrievalGenerator rg = ServiceTypeFactory.retrieveServiceFactory(
|
||||
bundle.getProvider()).getRetrievalGenerator();
|
||||
|
@ -220,7 +223,7 @@ public class SubscriptionRetrievalAgent extends
|
|||
timer.reset();
|
||||
timer.start();
|
||||
|
||||
dao.persistAll(requestRecords);
|
||||
retrievalDao.persistAll(requestRecords);
|
||||
|
||||
timer.stop();
|
||||
statusHandler.info("Time to persist requests to db ["
|
||||
|
|
|
@ -270,7 +270,7 @@ public class BandwidthDaoUtil {
|
|||
*/
|
||||
public void update(BandwidthAllocation allocation) {
|
||||
|
||||
bandwidthDao.update(allocation);
|
||||
bandwidthDao.createOrUpdate(allocation);
|
||||
retrievalManager.updateBandwidthAllocation(allocation);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,18 +3,23 @@
|
|||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
|
||||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
|
||||
|
||||
<bean id="ddRetrievalDatabaseProperties" class="com.raytheon.uf.edex.database.DatabasePluginProperties">
|
||||
<property name="pluginFQN" value="com.raytheon.uf.edex.datadelivery.retrieval" />
|
||||
<property name="database" value="metadata" />
|
||||
</bean>
|
||||
<bean factory-bean="dbPluginRegistry" factory-method="register">
|
||||
<constructor-arg value="com.raytheon.uf.edex.datadelivery.retrieval"/>
|
||||
<constructor-arg ref="ddRetrievalDatabaseProperties"/>
|
||||
</bean>
|
||||
|
||||
<bean id="subNotifyTask" class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.SubscriptionNotifyTask" />
|
||||
|
||||
|
||||
<bean id="ddRetrievalDatabaseProperties"
|
||||
class="com.raytheon.uf.edex.database.DatabasePluginProperties">
|
||||
<property name="pluginFQN"
|
||||
value="com.raytheon.uf.edex.datadelivery.retrieval" />
|
||||
<property name="database" value="metadata" />
|
||||
</bean>
|
||||
<bean factory-bean="dbPluginRegistry" factory-method="register">
|
||||
<constructor-arg value="com.raytheon.uf.edex.datadelivery.retrieval" />
|
||||
<constructor-arg ref="ddRetrievalDatabaseProperties" />
|
||||
</bean>
|
||||
|
||||
<bean id="subNotifyTask"
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.SubscriptionNotifyTask">
|
||||
<constructor-arg ref="retrievalDao" />
|
||||
</bean>
|
||||
|
||||
<!-- A RetrievalTask takes three constructor arguments:
|
||||
1) How to find retrievals, in this case perform the actual retrieval and return it
|
||||
2) What to do with found retrievals, in this case process it and send a notification event
|
||||
|
@ -27,23 +32,20 @@
|
|||
<bean
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.PerformRetrievalPluginDataObjectsFinder">
|
||||
<constructor-arg value="OPSNET" />
|
||||
<constructor-arg ref="retrievalDao" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
<constructor-arg>
|
||||
<bean
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.NotifyOfPluginDataObjectsDecorator">
|
||||
<constructor-arg>
|
||||
<bean
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.StoreRetrievedData">
|
||||
<constructor-arg value="directvm:dataDeliveryNotify" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.StoreRetrievedData">
|
||||
<constructor-arg value="directvm:dataDeliveryNotify" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
<constructor-arg>
|
||||
<bean
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.RetrievalResponseCompleter">
|
||||
<constructor-arg ref="subNotifyTask" />
|
||||
<constructor-arg ref="retrievalDao" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
@ -60,6 +62,7 @@
|
|||
<bean
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.PerformRetrievalPluginDataObjectsFinder">
|
||||
<constructor-arg value="OPSNET" />
|
||||
<constructor-arg ref="retrievalDao" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
<constructor-arg>
|
||||
|
@ -74,7 +77,7 @@
|
|||
</constructor-arg>
|
||||
</bean>
|
||||
-->
|
||||
|
||||
|
||||
<bean id="sbnRetrievalTask"
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.RetrievalTask">
|
||||
<constructor-arg value="SBN" />
|
||||
|
@ -86,30 +89,28 @@
|
|||
</constructor-arg>
|
||||
<constructor-arg>
|
||||
<bean
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.NotifyOfPluginDataObjectsDecorator">
|
||||
<constructor-arg>
|
||||
<bean
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.StoreRetrievedData">
|
||||
<constructor-arg value="directvm:dataDeliveryNotify" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.StoreRetrievedData">
|
||||
<constructor-arg value="directvm:dataDeliveryNotify" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
<constructor-arg>
|
||||
<bean
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.RetrievalResponseCompleter">
|
||||
<constructor-arg ref="subNotifyTask" />
|
||||
<constructor-arg ref="retrievalDao" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="scheduledExecutorService" class="java.util.concurrent.Executors" factory-method="newScheduledThreadPool">
|
||||
<constructor-arg value="3"/>
|
||||
<bean id="scheduledExecutorService" class="java.util.concurrent.Executors"
|
||||
factory-method="newScheduledThreadPool">
|
||||
<constructor-arg value="3" />
|
||||
</bean>
|
||||
|
||||
<bean id="retrievalHandler"
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.RetrievalHandler">
|
||||
<constructor-arg ref="scheduledExecutorService" />
|
||||
<constructor-arg ref="retrievalDao" />
|
||||
<constructor-arg>
|
||||
<util:list
|
||||
value-type="com.raytheon.uf.edex.datadelivery.retrieval.handlers.RetrievalTask.RetrievalTask">
|
||||
|
@ -119,22 +120,21 @@
|
|||
</constructor-arg>
|
||||
<constructor-arg ref="subNotifyTask" />
|
||||
</bean>
|
||||
|
||||
|
||||
<camelContext id="dataDeliveryNotify-camel"
|
||||
xmlns="http://camel.apache.org/schema/spring"
|
||||
errorHandlerRef="errorHandler">
|
||||
xmlns="http://camel.apache.org/schema/spring" errorHandlerRef="errorHandler">
|
||||
<!-- Wake retrieval threads if were not running -->
|
||||
<route id="notifyRetrieval">
|
||||
<!-- If data delivery clustered, move this to topic -->
|
||||
<from uri="directvm:notifyRetrieval"/>
|
||||
<bean ref="retrievalHandler" method="notify"/>
|
||||
<from uri="directvm:notifyRetrieval" />
|
||||
<bean ref="retrievalHandler" method="notify" />
|
||||
</route>
|
||||
|
||||
<route id="dataDeliveryNotify">
|
||||
<from uri="directvm:dataDeliveryNotify"/>
|
||||
<bean ref="toDataURI" method="toDataURI"/>
|
||||
<to uri="vm:stageNotification"/>
|
||||
<from uri="directvm:dataDeliveryNotify" />
|
||||
<bean ref="toDataURI" method="toDataURI" />
|
||||
<to uri="vm:stageNotification" />
|
||||
</route>
|
||||
</camelContext>
|
||||
</camelContext>
|
||||
|
||||
</beans>
|
|
@ -31,7 +31,7 @@ import com.raytheon.uf.common.serialization.SerializationUtil;
|
|||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.util.CollectionUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.State;
|
||||
|
||||
|
@ -52,20 +52,20 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.Sta
|
|||
* @author dhladky
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class RetrievalGenerationHandler implements IGenerateRetrieval {
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(RetrievalGenerationHandler.class);
|
||||
|
||||
public RetrievalGenerationHandler() {
|
||||
private final IRetrievalDao retrievalDao;
|
||||
|
||||
public RetrievalGenerationHandler(IRetrievalDao retrievalDao) {
|
||||
this.retrievalDao = retrievalDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> generateRetrieval(List<SubscriptionBundle> bundles) {
|
||||
|
||||
if (bundles != null) {
|
||||
RetrievalDao dao = RetrievalDao.getInstance();
|
||||
ArrayList<String> names = new ArrayList<String>(bundles.size());
|
||||
|
||||
for (SubscriptionBundle bundle : bundles) {
|
||||
|
@ -139,7 +139,7 @@ public class RetrievalGenerationHandler implements IGenerateRetrieval {
|
|||
|
||||
try {
|
||||
long t1 = System.currentTimeMillis();
|
||||
dao.persistAll(requestRecords);
|
||||
retrievalDao.persistAll(requestRecords);
|
||||
statusHandler.info("Time to persist requests to db ["
|
||||
+ (System.currentTimeMillis() - t1) + "] ms");
|
||||
names.add(subscriptionName);
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.retrieval.db;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.dao.ISessionManagedDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.State;
|
||||
|
||||
/**
|
||||
* DAO interface for retrievals.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 13, 2013 1543 djohnson Generated from RetrievalDao.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public interface IRetrievalDao extends
|
||||
ISessionManagedDao<RetrievalRequestRecordPK, RetrievalRequestRecord> {
|
||||
|
||||
/**
|
||||
* Returns the next PENDING retrieval request, puts it into a RUNNING state,
|
||||
* based on current time.
|
||||
*
|
||||
* @param network
|
||||
* the network to constrain requests to
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
RetrievalRequestRecord activateNextRetrievalRequest(Network network)
|
||||
throws DataAccessLayerException;
|
||||
|
||||
void completeRetrievalRequest(RetrievalRequestRecord rec)
|
||||
throws DataAccessLayerException;
|
||||
|
||||
/**
|
||||
* TODO: This will fail in a cluster, need to limit by machine in a cluster
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean resetRunningRetrievalsToPending();
|
||||
|
||||
/**
|
||||
* Returns the state counts for the passed subscription.
|
||||
*
|
||||
* @param sess
|
||||
* @param subName
|
||||
* @return
|
||||
*/
|
||||
Map<State, Integer> getSubscriptionStateCounts(String subName)
|
||||
throws DataAccessLayerException;
|
||||
|
||||
List<RetrievalRequestRecord> getFailedRequests(String subName)
|
||||
throws DataAccessLayerException;
|
||||
|
||||
boolean removeSubscription(String subName) throws DataAccessLayerException;
|
||||
|
||||
/**
|
||||
* Get all requests for the subscription name.
|
||||
*
|
||||
* @param subName
|
||||
* @return
|
||||
*/
|
||||
List<RetrievalRequestRecord> getRequests(String subName)
|
||||
throws DataAccessLayerException;
|
||||
|
||||
}
|
|
@ -23,7 +23,8 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.Sta
|
|||
|
||||
/**
|
||||
*
|
||||
* DAO for {@link RetrievalRequestRecord} entities.
|
||||
* DAO for {@link RetrievalRequestRecord} entities. Intentionally
|
||||
* package-private as all access should be through the Spring set interface.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -33,6 +34,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.Sta
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 30, 2013 1543 djohnson Add SW history.
|
||||
* Feb 07, 2013 1543 djohnson Use session management code.
|
||||
* Feb 13, 2013 1543 djohnson Exported interface which is now implemented.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -42,36 +44,22 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.Sta
|
|||
@Repository
|
||||
@Transactional
|
||||
// TODO: Split service functionality from DAO functionality
|
||||
public class RetrievalDao extends SessionManagedDao {
|
||||
class RetrievalDao extends
|
||||
SessionManagedDao<RetrievalRequestRecordPK, RetrievalRequestRecord> implements IRetrievalDao {
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(RetrievalDao.class);
|
||||
|
||||
private static RetrievalDao instance;
|
||||
|
||||
/**
|
||||
* @return the instance
|
||||
*/
|
||||
public static RetrievalDao getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public RetrievalDao() {
|
||||
// TODO: Don't use a static instance
|
||||
RetrievalDao.instance = this;
|
||||
RetrievalDao() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next PENDING retrieval request, puts it into a RUNNING state,
|
||||
* based on current time.
|
||||
*
|
||||
* @param network
|
||||
* the network to constrain requests to
|
||||
*
|
||||
* @return
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public RetrievalRequestRecord activateNextRetrievalRequest(Network network)
|
||||
throws DataAccessLayerException {
|
||||
Session sess = null;
|
||||
|
@ -170,6 +158,10 @@ public class RetrievalDao extends SessionManagedDao {
|
|||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void completeRetrievalRequest(RetrievalRequestRecord rec)
|
||||
throws DataAccessLayerException {
|
||||
try {
|
||||
|
@ -183,10 +175,9 @@ public class RetrievalDao extends SessionManagedDao {
|
|||
}
|
||||
|
||||
/**
|
||||
* TODO: This will fail in a cluster, need to limit by machine in a cluster
|
||||
*
|
||||
* @return
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean resetRunningRetrievalsToPending() {
|
||||
boolean rval = false;
|
||||
|
||||
|
@ -208,12 +199,9 @@ public class RetrievalDao extends SessionManagedDao {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the state counts for the passed subscription.
|
||||
*
|
||||
* @param sess
|
||||
* @param subName
|
||||
* @return
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Map<State, Integer> getSubscriptionStateCounts(String subName)
|
||||
throws DataAccessLayerException {
|
||||
Map<State, Integer> rval = new HashMap<State, Integer>(8);
|
||||
|
@ -249,6 +237,10 @@ public class RetrievalDao extends SessionManagedDao {
|
|||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<RetrievalRequestRecord> getFailedRequests(String subName)
|
||||
throws DataAccessLayerException {
|
||||
|
@ -266,6 +258,10 @@ public class RetrievalDao extends SessionManagedDao {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean removeSubscription(String subName)
|
||||
throws DataAccessLayerException {
|
||||
boolean rval = false;
|
||||
|
@ -287,11 +283,9 @@ public class RetrievalDao extends SessionManagedDao {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get all requests for the subscription name.
|
||||
*
|
||||
* @param subName
|
||||
* @return
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<RetrievalRequestRecord> getRequests(String subName)
|
||||
throws DataAccessLayerException {
|
||||
|
@ -324,4 +318,12 @@ public class RetrievalDao extends SessionManagedDao {
|
|||
query.setParameter("network", network);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<RetrievalRequestRecord> getEntityClass() {
|
||||
return RetrievalRequestRecord.class;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,108 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.event.retrieval.DataRetrievalEvent;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType;
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.util.DataSizeUtils;
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval;
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.event.EventBus;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
|
||||
|
||||
/**
|
||||
* Performs processing on the retrieved plugin data objects, and then sends an
|
||||
* event about the retrieval.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 01, 2013 1543 djohnson Initial creation
|
||||
* Feb 05, 2013 1580 mpduff EventBus refactor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class NotifyOfPluginDataObjectsDecorator implements
|
||||
IRetrievalPluginDataObjectsProcessor {
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(NotifyOfPluginDataObjectsDecorator.class);
|
||||
|
||||
private final IRetrievalPluginDataObjectsProcessor retrievedDataProcessor;
|
||||
|
||||
public NotifyOfPluginDataObjectsDecorator(
|
||||
IRetrievalPluginDataObjectsProcessor retrievedDataProcessor) {
|
||||
this.retrievedDataProcessor = retrievedDataProcessor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processRetrievedPluginDataObjects(
|
||||
RetrievalPluginDataObjects retrievalPluginDataObjects)
|
||||
throws Exception {
|
||||
|
||||
// TODO: What if one of the records fails to store or serialize, is that
|
||||
// already handled somewhere?
|
||||
retrievedDataProcessor
|
||||
.processRetrievedPluginDataObjects(retrievalPluginDataObjects);
|
||||
|
||||
final RetrievalRequestRecord requestRecord = retrievalPluginDataObjects
|
||||
.getRequestRecord();
|
||||
final List<RetrievalAttributePluginDataObjects> retrievalAttributePluginDataObjects = retrievalPluginDataObjects
|
||||
.getRetrievalAttributePluginDataObjects();
|
||||
|
||||
for (RetrievalAttributePluginDataObjects pluginDataObjectEntry : retrievalAttributePluginDataObjects) {
|
||||
RetrievalAttribute attXML = pluginDataObjectEntry.getAttributeXml();
|
||||
PluginDataObject[] value = pluginDataObjectEntry
|
||||
.getPluginDataObjects();
|
||||
|
||||
if (value.length == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String pluginName = value[0].getPluginName();
|
||||
Retrieval retrieval = requestRecord.getRetrievalObj();
|
||||
ServiceType serviceType = retrieval.getServiceType();
|
||||
|
||||
statusHandler.info("Successfully processed: " + value.length
|
||||
+ " : " + serviceType + " Plugin : " + pluginName);
|
||||
DataRetrievalEvent event = new DataRetrievalEvent();
|
||||
event.setId(retrieval.getSubscriptionName());
|
||||
event.setOwner(retrieval.getOwner());
|
||||
event.setNetwork(retrieval.getNetwork().name());
|
||||
event.setPlugin(pluginName);
|
||||
event.setProvider(attXML.getProvider());
|
||||
event.setNumRecords(value.length);
|
||||
event.setBytes(DataSizeUtils.calculateSize(attXML, serviceType));
|
||||
|
||||
EventBus.publish(event);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,15 +21,12 @@ package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType;
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval;
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -37,7 +34,7 @@ import com.raytheon.uf.common.time.util.ITimer;
|
|||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.ServiceTypeFactory;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.State;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalRequestBuilder;
|
||||
|
@ -55,6 +52,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalResponse
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 01, 2013 1543 djohnson Initial creation
|
||||
* Feb 07, 2013 1543 djohnson Expose process() for testing.
|
||||
* Feb 12, 2013 1543 djohnson Retrieval responses are now passed further down the chain.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -70,13 +68,17 @@ public class PerformRetrievalPluginDataObjectsFinder implements
|
|||
|
||||
private final Network network;
|
||||
|
||||
private final IRetrievalDao retrievalDao;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param network
|
||||
*/
|
||||
public PerformRetrievalPluginDataObjectsFinder(Network network) {
|
||||
public PerformRetrievalPluginDataObjectsFinder(Network network,
|
||||
IRetrievalDao retrievalDao) {
|
||||
this.network = network;
|
||||
this.retrievalDao = retrievalDao;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,13 +87,12 @@ public class PerformRetrievalPluginDataObjectsFinder implements
|
|||
@Override
|
||||
public RetrievalPluginDataObjects findRetrievalPluginDataObjects()
|
||||
throws Exception {
|
||||
RetrievalDao dao = RetrievalDao.getInstance();
|
||||
RetrievalPluginDataObjects retVal = null;
|
||||
|
||||
ITimer timer = TimeUtil.getTimer();
|
||||
try {
|
||||
timer.start();
|
||||
RetrievalRequestRecord request = dao
|
||||
RetrievalRequestRecord request = retrievalDao
|
||||
.activateNextRetrievalRequest(network);
|
||||
|
||||
if (request == null) {
|
||||
|
@ -132,8 +133,7 @@ public class PerformRetrievalPluginDataObjectsFinder implements
|
|||
* The actual work gets done here.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
RetrievalPluginDataObjects process(
|
||||
RetrievalRequestRecord requestRecord) {
|
||||
RetrievalPluginDataObjects process(RetrievalRequestRecord requestRecord) {
|
||||
requestRecord.setState(State.FAILED);
|
||||
List<RetrievalAttributePluginDataObjects> retrievalAttributePluginDataObjects = new ArrayList<RetrievalAttributePluginDataObjects>();
|
||||
|
||||
|
@ -167,27 +167,21 @@ public class PerformRetrievalPluginDataObjectsFinder implements
|
|||
IRetrievalResponse response = pra.performRequest(request);
|
||||
|
||||
if (response != null) {
|
||||
Map<String, PluginDataObject[]> pdoHash = pra
|
||||
.processResponse(response);
|
||||
if (pdoHash != null && !pdoHash.isEmpty()) {
|
||||
for (Entry<String, PluginDataObject[]> entry : pdoHash
|
||||
.entrySet()) {
|
||||
retrievalAttributePluginDataObjects
|
||||
.add(new RetrievalAttributePluginDataObjects(
|
||||
attXML, entry.getValue()));
|
||||
}
|
||||
requestRecord.setState(State.COMPLETED);
|
||||
} else {
|
||||
throw new IllegalStateException(
|
||||
"No PDO's to store: " + serviceType
|
||||
+ " original: " + attXML.toString());
|
||||
}
|
||||
setCompletionStateFromResponse(requestRecord, response);
|
||||
|
||||
retrievalAttributePluginDataObjects
|
||||
.add(new RetrievalAttributePluginDataObjects(
|
||||
attXML, response));
|
||||
} else {
|
||||
// null response
|
||||
throw new IllegalStateException(
|
||||
"Null response for service: " + serviceType
|
||||
+ " original: " + attXML.toString());
|
||||
throw new IllegalStateException("No PDO's to store: "
|
||||
+ serviceType + " original: "
|
||||
+ attXML.toString());
|
||||
}
|
||||
} else {
|
||||
// null response
|
||||
throw new IllegalStateException(
|
||||
"Null response for service: " + serviceType
|
||||
+ " original: " + attXML.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,4 +193,21 @@ public class PerformRetrievalPluginDataObjectsFinder implements
|
|||
return retrievalPluginDataObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link RetrievalRequestRecord} status based on the
|
||||
* {@link IRetrievalResponse}.
|
||||
*
|
||||
* @param requestRecord
|
||||
* the request record
|
||||
* @param response
|
||||
* the response
|
||||
*/
|
||||
@VisibleForTesting
|
||||
static void setCompletionStateFromResponse(RetrievalRequestRecord requestRecord,
|
||||
IRetrievalResponse response) {
|
||||
final State completionState = response.getPayLoad() == null ? State.FAILED
|
||||
: State.COMPLETED;
|
||||
requestRecord.setState(completionState);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalResponse;
|
||||
|
||||
/**
|
||||
* Plugin data objects and the retrieval information they are associated with.
|
||||
|
@ -34,6 +34,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 01, 2013 1543 djohnson Initial creation
|
||||
* Feb 12, 2013 1543 djohnson Takes retrieval response rather than plugin data objects.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -47,7 +48,7 @@ public class RetrievalAttributePluginDataObjects {
|
|||
private RetrievalAttribute attributeXml;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private PluginDataObject[] pluginDataObjects;
|
||||
private IRetrievalResponse retrievalResponse;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -59,12 +60,12 @@ public class RetrievalAttributePluginDataObjects {
|
|||
* Constructor.
|
||||
*
|
||||
* @param attributeXml
|
||||
* @param pluginDataObjects
|
||||
* @param response
|
||||
*/
|
||||
public RetrievalAttributePluginDataObjects(RetrievalAttribute attributeXml,
|
||||
PluginDataObject[] pluginDataObjects) {
|
||||
IRetrievalResponse response) {
|
||||
this.attributeXml = attributeXml;
|
||||
this.pluginDataObjects = pluginDataObjects;
|
||||
this.retrievalResponse = response;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,18 +84,18 @@ public class RetrievalAttributePluginDataObjects {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return the pluginDataObjects
|
||||
* @return the retrievalResponse
|
||||
*/
|
||||
public PluginDataObject[] getPluginDataObjects() {
|
||||
return pluginDataObjects;
|
||||
public IRetrievalResponse getRetrievalResponse() {
|
||||
return retrievalResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pluginDataObjects
|
||||
* the pluginDataObjects to set
|
||||
* @param retrievalResponse
|
||||
* the retrievalResponse to set
|
||||
*/
|
||||
public void setPluginDataObjects(PluginDataObject[] pluginDataObjects) {
|
||||
this.pluginDataObjects = pluginDataObjects;
|
||||
public void setRetrievalResponse(IRetrievalResponse retrievalResponse) {
|
||||
this.retrievalResponse = retrievalResponse;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,10 +25,11 @@ import java.util.concurrent.ExecutorService;
|
|||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
||||
|
||||
/**
|
||||
* Provider Retrieval Handler
|
||||
|
@ -46,7 +47,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao;
|
|||
* @author dhladky
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class RetrievalHandler {
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
|
@ -58,21 +59,8 @@ public class RetrievalHandler {
|
|||
|
||||
private final SubscriptionNotifyTask subNotifyTask;
|
||||
|
||||
/**
|
||||
* useful public constructor
|
||||
*
|
||||
* @param executor
|
||||
*/
|
||||
public RetrievalHandler(ScheduledExecutorService executorService,
|
||||
List<RetrievalTask> retrievalTasks,
|
||||
SubscriptionNotifyTask subNotifyTask) {
|
||||
this(executorService, RetrievalDao.getInstance(), retrievalTasks,
|
||||
subNotifyTask);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
RetrievalHandler(ScheduledExecutorService executorService,
|
||||
RetrievalDao retrievalDao, List<RetrievalTask> retrievalTasks,
|
||||
IRetrievalDao retrievalDao, List<RetrievalTask> retrievalTasks,
|
||||
SubscriptionNotifyTask subNotifyTask) {
|
||||
this.executorService = executorService;
|
||||
this.retrievalTasks = retrievalTasks;
|
||||
|
|
|
@ -22,7 +22,7 @@ package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
|||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
|
||||
|
||||
/**
|
||||
|
@ -49,8 +49,12 @@ public class RetrievalResponseCompleter implements IRetrievalResponseCompleter {
|
|||
|
||||
private final SubscriptionNotifyTask notifyTask;
|
||||
|
||||
public RetrievalResponseCompleter(SubscriptionNotifyTask notifyTask) {
|
||||
private final IRetrievalDao dao;
|
||||
|
||||
public RetrievalResponseCompleter(SubscriptionNotifyTask notifyTask,
|
||||
IRetrievalDao dao) {
|
||||
this.notifyTask = notifyTask;
|
||||
this.dao = dao;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,7 +69,6 @@ public class RetrievalResponseCompleter implements IRetrievalResponseCompleter {
|
|||
|
||||
// update database
|
||||
try {
|
||||
RetrievalDao dao = RetrievalDao.getInstance();
|
||||
dao.completeRetrievalRequest(retrieval);
|
||||
notifyTask.checkNotify(retrieval);
|
||||
} catch (DataAccessLayerException e) {
|
||||
|
|
|
@ -20,8 +20,22 @@
|
|||
package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.raytheon.uf.common.datadelivery.event.retrieval.DataRetrievalEvent;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType;
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.util.DataSizeUtils;
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval;
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.event.EventBus;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.util.CollectionUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.ServiceTypeFactory;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.util.RetrievalPersistUtil;
|
||||
|
||||
|
@ -36,6 +50,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.util.RetrievalPersistUtil;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 31, 2013 1543 djohnson Initial creation
|
||||
* Feb 12, 2013 1543 djohnson Now handles the retrieval responses directly.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -47,6 +62,9 @@ public class StoreRetrievedData implements IRetrievalPluginDataObjectsProcessor
|
|||
|
||||
private final String generalDestinationUri;
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(StoreRetrievedData.class);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -62,21 +80,69 @@ public class StoreRetrievedData implements IRetrievalPluginDataObjectsProcessor
|
|||
*/
|
||||
@Override
|
||||
public void processRetrievedPluginDataObjects(
|
||||
RetrievalPluginDataObjects retrievalPluginDataObjects) {
|
||||
RetrievalPluginDataObjects retrievalPluginDataObjects)
|
||||
throws Exception {
|
||||
Map<String, PluginDataObject[]> pluginDataObjects = Maps.newHashMap();
|
||||
final RetrievalRequestRecord requestRecord = retrievalPluginDataObjects
|
||||
.getRequestRecord();
|
||||
final List<RetrievalAttributePluginDataObjects> retrievalAttributePluginDataObjects = retrievalPluginDataObjects
|
||||
.getRetrievalAttributePluginDataObjects();
|
||||
final Retrieval retrieval = requestRecord.getRetrievalObj();
|
||||
final ServiceType serviceType = retrieval.getServiceType();
|
||||
final RetrievalAdapter serviceRetrievalAdapter = ServiceTypeFactory
|
||||
.retrieveServiceRetrievalAdapter(serviceType);
|
||||
|
||||
for (RetrievalAttributePluginDataObjects pluginDataObjectEntry : retrievalAttributePluginDataObjects) {
|
||||
PluginDataObject[] value = pluginDataObjectEntry
|
||||
.getPluginDataObjects();
|
||||
Map<String, PluginDataObject[]> value = serviceRetrievalAdapter
|
||||
.processResponse(pluginDataObjectEntry
|
||||
.getRetrievalResponse());
|
||||
|
||||
if (value.length == 0) {
|
||||
if (value == null || value.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
sendToDestinationForStorage(requestRecord, value);
|
||||
for (Entry<String, PluginDataObject[]> entry : value.entrySet()) {
|
||||
final String key = entry.getKey();
|
||||
final PluginDataObject[] objectsForEntry = entry.getValue();
|
||||
|
||||
PluginDataObject[] objectsForPlugin = pluginDataObjects
|
||||
.get(key);
|
||||
objectsForPlugin = CollectionUtil.combine(
|
||||
PluginDataObject.class, objectsForPlugin,
|
||||
objectsForEntry);
|
||||
|
||||
pluginDataObjects.put(key, objectsForPlugin);
|
||||
}
|
||||
|
||||
final RetrievalAttribute attXML = pluginDataObjectEntry
|
||||
.getAttributeXml();
|
||||
for (Entry<String, PluginDataObject[]> entry : pluginDataObjects
|
||||
.entrySet()) {
|
||||
final String pluginName = entry.getKey();
|
||||
final PluginDataObject[] records = entry.getValue();
|
||||
|
||||
if (records == null) {
|
||||
statusHandler
|
||||
.warn("The plugin data objects was a null array, the service retrieval adapter "
|
||||
+ "should not return a null map of plugin data objects!");
|
||||
continue;
|
||||
}
|
||||
|
||||
statusHandler.info("Successfully processed: " + records.length
|
||||
+ " : " + serviceType + " Plugin : " + pluginName);
|
||||
DataRetrievalEvent event = new DataRetrievalEvent();
|
||||
event.setId(retrieval.getSubscriptionName());
|
||||
event.setOwner(retrieval.getOwner());
|
||||
event.setNetwork(retrieval.getNetwork().name());
|
||||
event.setPlugin(pluginName);
|
||||
event.setProvider(attXML.getProvider());
|
||||
event.setNumRecords(records.length);
|
||||
event.setBytes(DataSizeUtils.calculateSize(attXML, serviceType));
|
||||
|
||||
EventBus.publish(event);
|
||||
|
||||
sendToDestinationForStorage(requestRecord, records);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,18 +150,14 @@ public class StoreRetrievedData implements IRetrievalPluginDataObjectsProcessor
|
|||
* Sends the plugin data objects to their configured destination for storage
|
||||
* to the database.
|
||||
*/
|
||||
public boolean sendToDestinationForStorage(
|
||||
RetrievalRequestRecord requestRecord,
|
||||
PluginDataObject[] pdos) {
|
||||
// do all of the PDO storage magic...
|
||||
boolean success = false;
|
||||
public void sendToDestinationForStorage(
|
||||
RetrievalRequestRecord requestRecord, PluginDataObject[] pdos) {
|
||||
String pluginName = pdos[0].getPluginName();
|
||||
|
||||
if (pluginName != null) {
|
||||
success = RetrievalPersistUtil.routePlugin(generalDestinationUri,
|
||||
RetrievalPersistUtil.routePlugin(generalDestinationUri,
|
||||
pluginName, pdos);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import com.raytheon.uf.common.status.UFStatus;
|
|||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalManagerNotifyEvent;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
|
||||
|
||||
/**
|
||||
|
@ -201,6 +201,12 @@ public class SubscriptionNotifyTask implements Runnable {
|
|||
|
||||
private final DelayQueue<SubscriptionDelay> subscriptionQueue = new DelayQueue<SubscriptionDelay>();
|
||||
|
||||
private final IRetrievalDao dao;
|
||||
|
||||
public SubscriptionNotifyTask(IRetrievalDao dao) {
|
||||
this.dao = dao;
|
||||
}
|
||||
|
||||
public void checkNotify(RetrievalRequestRecord record) {
|
||||
SubscriptionDelay subDelay = createSubscriptionDelay(record,
|
||||
System.currentTimeMillis());
|
||||
|
@ -209,8 +215,6 @@ public class SubscriptionNotifyTask implements Runnable {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
RetrievalDao dao = null;
|
||||
|
||||
statusHandler.info("SubscriptionNotifyTask() - Running...");
|
||||
try {
|
||||
SubscriptionDelay nextSub = subscriptionQueue.peek();
|
||||
|
@ -241,10 +245,6 @@ public class SubscriptionNotifyTask implements Runnable {
|
|||
|
||||
SubscriptionDelay subToCheck = subscriptionQueue.poll();
|
||||
while (subToCheck != null) {
|
||||
if (dao == null) {
|
||||
dao = RetrievalDao.getInstance();
|
||||
}
|
||||
|
||||
Map<RetrievalRequestRecord.State, Integer> stateCounts = dao
|
||||
.getSubscriptionStateCounts(subToCheck.subName);
|
||||
Integer numPending = stateCounts
|
||||
|
|
|
@ -31,6 +31,7 @@ import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 16, 2011 dhladky Initial creation
|
||||
* Feb 12, 2013 1543 djohnson The payload can just be an arbitrary object, implementations can define an array if required.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -42,9 +43,9 @@ import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
|
|||
|
||||
public interface IRetrievalResponse {
|
||||
|
||||
public void setPayLoad(Object[] payLoad);
|
||||
public void setPayLoad(Object payLoad);
|
||||
|
||||
public Object[] getPayLoad();
|
||||
public Object getPayLoad();
|
||||
|
||||
public RetrievalAttribute getAttribute();
|
||||
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.retrieval.opendap;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.raytheon.edex.util.Util;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
|
||||
import dods.dap.DConnect;
|
||||
import dods.dap.DataDDS;
|
||||
|
||||
/**
|
||||
* Utilities for working with net.dods.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 12, 2013 1543 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class DodsUtils {
|
||||
|
||||
/**
|
||||
* Prevent construction.
|
||||
*/
|
||||
private DodsUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the DataDDS instance to a byte array.
|
||||
*
|
||||
* @param dataDds
|
||||
* the DataDDS instance
|
||||
* @return the byte array
|
||||
* @throws SerializationException
|
||||
* on error converting to a byte array
|
||||
*/
|
||||
public static byte[] convertDataDdsToByteArray(DataDDS dataDds)
|
||||
throws SerializationException {
|
||||
ByteArrayOutputStream os = null;
|
||||
|
||||
try {
|
||||
os = new ByteArrayOutputStream(700);
|
||||
|
||||
dataDds.externalize(os, true, true);
|
||||
|
||||
return os.toByteArray();
|
||||
} catch (IOException e) {
|
||||
throw new SerializationException(
|
||||
"Unable to externalize the DataDDS instance.", e);
|
||||
} finally {
|
||||
Util.close(os);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the {@link DataDDS} from the byte array.
|
||||
*
|
||||
* @param byteArray
|
||||
* @return the DataDDS instance
|
||||
* @throws SerializationException
|
||||
* on error restoring the DataDDS
|
||||
*/
|
||||
public static DataDDS restoreDataDdsFromByteArray(byte[] byteArray)
|
||||
throws SerializationException {
|
||||
DConnect dconnect = new DConnect(new ByteArrayInputStream(byteArray));
|
||||
DataDDS data = null;
|
||||
try {
|
||||
data = dconnect.getData(null);
|
||||
return data;
|
||||
} catch (Exception e) {
|
||||
throw new SerializationException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -21,6 +21,7 @@ package com.raytheon.uf.edex.datadelivery.retrieval.opendap;
|
|||
**/
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
|
@ -28,6 +29,7 @@ import com.raytheon.uf.common.event.EventBus;
|
|||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.common.util.CollectionUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalEvent;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalRequestBuilder;
|
||||
|
@ -51,6 +53,7 @@ import dods.dap.DataDDS;
|
|||
* Jun 28, 2012 819 djohnson Use utility class for DConnect.
|
||||
* Jul 25, 2012 955 djohnson Make package-private.
|
||||
* Feb 05, 2013 1580 mpduff EventBus refactor.
|
||||
* Feb 12, 2013 1543 djohnson The payload can just be an arbitrary object, implementations can define an array if required.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -73,7 +76,8 @@ class OpenDAPRetrievalAdapter extends RetrievalAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public RetrievalResponse performRequest(IRetrievalRequestBuilder request) {
|
||||
public RetrievalResponse performRequest(
|
||||
IRetrievalRequestBuilder request) {
|
||||
|
||||
DataDDS data = null;
|
||||
|
||||
|
@ -85,16 +89,17 @@ class OpenDAPRetrievalAdapter extends RetrievalAdapter {
|
|||
EventBus.publish(new RetrievalEvent(e.getMessage()));
|
||||
}
|
||||
|
||||
RetrievalResponse pr = new RetrievalResponse(request.getAttribute());
|
||||
pr.setPayLoad(new Object[] { data });
|
||||
RetrievalResponse pr = new OpenDapRetrievalResponse(
|
||||
request.getAttribute());
|
||||
pr.setPayLoad(data);
|
||||
|
||||
return pr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, PluginDataObject[]> processResponse(
|
||||
public Map<String, PluginDataObject[]> processResponse(
|
||||
IRetrievalResponse response) throws TranslationException {
|
||||
HashMap<String, PluginDataObject[]> map = new HashMap<String, PluginDataObject[]>();
|
||||
Map<String, PluginDataObject[]> map = new HashMap<String, PluginDataObject[]>();
|
||||
|
||||
OpenDAPTranslator translator;
|
||||
try {
|
||||
|
@ -104,19 +109,21 @@ class OpenDAPRetrievalAdapter extends RetrievalAdapter {
|
|||
"Unable to instantiate a required class!", e);
|
||||
}
|
||||
|
||||
if (response.getPayLoad() != null && response.getPayLoad().length > 0) {
|
||||
for (Object obj : response.getPayLoad()) {
|
||||
PluginDataObject[] pdos = null;
|
||||
final DataDDS payload;
|
||||
try {
|
||||
payload = DataDDS.class.cast(response.getPayLoad());
|
||||
} catch (ClassCastException e) {
|
||||
throw new TranslationException(e);
|
||||
}
|
||||
|
||||
if (obj instanceof DataDDS) {
|
||||
pdos = translator.asPluginDataObjects((DataDDS) obj);
|
||||
}
|
||||
if (payload != null) {
|
||||
PluginDataObject[] pdos = translator.asPluginDataObjects(payload);
|
||||
|
||||
if (pdos != null && pdos.length > 0) {
|
||||
String pluginName = pdos[0].getPluginName();
|
||||
// TODO Need to check if pluginName already exists
|
||||
map.put(pluginName, pdos);
|
||||
}
|
||||
if (!CollectionUtil.isNullOrEmpty(pdos)) {
|
||||
String pluginName = pdos[0].getPluginName();
|
||||
map.put(pluginName,
|
||||
CollectionUtil.combine(PluginDataObject.class,
|
||||
map.get(pluginName), pdos));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.retrieval.opendap;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeTypeAdapter;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.response.RetrievalResponse;
|
||||
|
||||
/**
|
||||
* {@link RetrievalResponse} for OpenDAP.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 12, 2013 1543 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
@DynamicSerializeTypeAdapter(factory = OpenDapRetrievalResponseSerializer.class)
|
||||
public class OpenDapRetrievalResponse extends RetrievalResponse {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public OpenDapRetrievalResponse() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param attribute
|
||||
*/
|
||||
public OpenDapRetrievalResponse(RetrievalAttribute attribute) {
|
||||
super(attribute);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.retrieval.opendap;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
|
||||
import com.raytheon.uf.common.serialization.IDeserializationContext;
|
||||
import com.raytheon.uf.common.serialization.ISerializationContext;
|
||||
import com.raytheon.uf.common.serialization.ISerializationTypeAdapter;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
|
||||
import dods.dap.DataDDS;
|
||||
|
||||
/**
|
||||
* Dynamic serializer for OpenDAP retrieval responses.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 12, 2013 1543 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class OpenDapRetrievalResponseSerializer implements
|
||||
ISerializationTypeAdapter<OpenDapRetrievalResponse> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void serialize(ISerializationContext serializer,
|
||||
OpenDapRetrievalResponse object) throws SerializationException {
|
||||
serializer.writeObject(object.getAttribute());
|
||||
serializer.writeBinary(DodsUtils
|
||||
.convertDataDdsToByteArray((DataDDS) object.getPayLoad()));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public OpenDapRetrievalResponse deserialize(
|
||||
IDeserializationContext deserializer) throws SerializationException {
|
||||
OpenDapRetrievalResponse response = new OpenDapRetrievalResponse();
|
||||
response.setAttribute((RetrievalAttribute) deserializer.readObject());
|
||||
response.setPayLoad(DodsUtils.restoreDataDdsFromByteArray(deserializer
|
||||
.readBinary()));
|
||||
return response;
|
||||
}
|
||||
}
|
|
@ -22,6 +22,8 @@ package com.raytheon.uf.edex.datadelivery.retrieval.response;
|
|||
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalResponse;
|
||||
|
||||
/**
|
||||
|
@ -33,6 +35,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalResponse
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 07, 2011 dhladky Initial creation
|
||||
* Feb 12, 2013 1543 djohnson Abstract class now.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -41,27 +44,40 @@ import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalResponse
|
|||
* @author dhladky
|
||||
* @version 1.0
|
||||
*/
|
||||
@DynamicSerialize
|
||||
public abstract class RetrievalResponse implements IRetrievalResponse {
|
||||
|
||||
public class RetrievalResponse implements IRetrievalResponse {
|
||||
@DynamicSerializeElement
|
||||
private RetrievalAttribute attribute;
|
||||
|
||||
private RetrievalAttribute attXML;
|
||||
@DynamicSerializeElement
|
||||
private Object payLoad;
|
||||
|
||||
private Object[] payLoad;
|
||||
public RetrievalResponse() {
|
||||
|
||||
public RetrievalResponse(RetrievalAttribute attXML) {
|
||||
this.attXML = attXML;
|
||||
}
|
||||
|
||||
public void setPayLoad(Object[] payLoad) {
|
||||
public RetrievalResponse(RetrievalAttribute attribute) {
|
||||
this.attribute = attribute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPayLoad(Object payLoad) {
|
||||
this.payLoad = payLoad;
|
||||
}
|
||||
|
||||
public Object[] getPayLoad() {
|
||||
@Override
|
||||
public Object getPayLoad() {
|
||||
return payLoad;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RetrievalAttribute getAttribute() {
|
||||
return attXML;
|
||||
return attribute;
|
||||
}
|
||||
|
||||
public void setAttribute(RetrievalAttribute attribute) {
|
||||
this.attribute = attribute;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.metadata.adapters.AbstractMet
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 18, 2011 191 dhladky Initial creation
|
||||
* Feb 07, 2013 1543 djohnson Allow overriding of methods for mocking in tests.
|
||||
* Feb 12, 2013 1543 djohnson Pass the exception as the cause for instantiation exceptions.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -79,7 +80,9 @@ public abstract class RetrievalTranslator implements IRetrievalTranslator {
|
|||
try {
|
||||
configureFromPdoClassName(className);
|
||||
} catch (Exception e) {
|
||||
throw new InstantiationException(e.toString());
|
||||
InstantiationException ie = new InstantiationException();
|
||||
ie.initCause(e);
|
||||
throw ie;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
</property>
|
||||
</bean>
|
||||
|
||||
<tx:annotation-driven transaction-manager="metadataTxManager" proxy-target-class="true" />
|
||||
<tx:annotation-driven transaction-manager="metadataTxManager" />
|
||||
|
||||
<bean id="metadataTxManager"
|
||||
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.database.dao;
|
||||
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
|
||||
/**
|
||||
* DAO interface for MockService.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 13, 2013 1543 djohnson Generated from MockService.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public interface IMockService {
|
||||
|
||||
/**
|
||||
* Stores a {@link BandwidthSubscription} then attempts an invalid transactable
|
||||
* operation.
|
||||
*
|
||||
* @param subscription
|
||||
* the subscription
|
||||
*/
|
||||
void storeStuffThenThrowException(BandwidthSubscription subscription);
|
||||
|
||||
/**
|
||||
* Stores a {@link BandwidthSubscription}, not throwing an exception as long as
|
||||
* the subscription object is valid.
|
||||
*
|
||||
* @param subscription
|
||||
* the subscription
|
||||
*/
|
||||
void storeStuffAndNotThrowException(BandwidthSubscription subscription);
|
||||
|
||||
/**
|
||||
* @param bandwidthService
|
||||
* the bandwidthService to set
|
||||
*/
|
||||
void setBandwidthService(IBandwidthDao bandwidthService);
|
||||
|
||||
}
|
|
@ -24,7 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
|
||||
/**
|
||||
* Mock service which uses another service.
|
||||
|
@ -44,9 +44,9 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthD
|
|||
*/
|
||||
@Transactional
|
||||
@Repository
|
||||
public class MockService extends SessionManagedDao {
|
||||
public class MockService extends SessionManagedDao<Long, BandwidthSubscription> implements IMockService {
|
||||
|
||||
private HibernateBandwidthDao bandwidthService;
|
||||
private IBandwidthDao bandwidthService;
|
||||
|
||||
/**
|
||||
* @param config
|
||||
|
@ -55,12 +55,9 @@ public class MockService extends SessionManagedDao {
|
|||
}
|
||||
|
||||
/**
|
||||
* Stores a {@link BandwidthSubscription} then attempts an invalid transactable
|
||||
* operation.
|
||||
*
|
||||
* @param subscription
|
||||
* the subscription
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void storeStuffThenThrowException(BandwidthSubscription subscription) {
|
||||
SpringTransactionUtils
|
||||
.transactionRequired("storeStuffThenThrowException");
|
||||
|
@ -71,12 +68,9 @@ public class MockService extends SessionManagedDao {
|
|||
}
|
||||
|
||||
/**
|
||||
* Stores a {@link BandwidthSubscription}, not throwing an exception as long as
|
||||
* the subscription object is valid.
|
||||
*
|
||||
* @param subscription
|
||||
* the subscription
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void storeStuffAndNotThrowException(BandwidthSubscription subscription) {
|
||||
SpringTransactionUtils
|
||||
.transactionRequired("storeStuffAndNotThrowException");
|
||||
|
@ -89,11 +83,19 @@ public class MockService extends SessionManagedDao {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param bandwidthService
|
||||
* the bandwidthService to set
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setBandwidthService(HibernateBandwidthDao bandwidthService) {
|
||||
@Override
|
||||
public void setBandwidthService(IBandwidthDao bandwidthService) {
|
||||
this.bandwidthService = bandwidthService;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class<BandwidthSubscription> getEntityClass() {
|
||||
return BandwidthSubscription.class;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,10 +32,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||
|
||||
import com.raytheon.uf.common.util.SpringFiles;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthSubscription;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDaoFixture;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrievalFixture;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthDao;
|
||||
|
||||
/**
|
||||
* Test {@link SessionManagedService}.
|
||||
|
@ -70,10 +70,10 @@ public class SessionManagedServiceTest {
|
|||
}
|
||||
|
||||
@Autowired
|
||||
private HibernateBandwidthDao bandwidthService;
|
||||
private IBandwidthDao bandwidthService;
|
||||
|
||||
@Autowired
|
||||
private MockService service;
|
||||
private IMockService service;
|
||||
|
||||
@Test
|
||||
public void exceptionThrownInDaoWillRollbackTransaction() {
|
||||
|
|
|
@ -629,7 +629,7 @@ public abstract class AbstractBandwidthDaoTest<T extends IBandwidthDao> {
|
|||
entity.setAgentType("someAgentType");
|
||||
dao.store(entity);
|
||||
entity.setEstimatedSize(estimatedSize);
|
||||
dao.update(entity);
|
||||
dao.createOrUpdate(entity);
|
||||
|
||||
assertEquals("Expected the entity to have been updated!", 25L, dao
|
||||
.getBandwidthAllocations(entity.getNetwork()).iterator().next()
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||
|
||||
import com.raytheon.uf.common.util.SpringFiles;
|
||||
import com.raytheon.uf.edex.database.dao.DatabaseUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthDao;
|
||||
|
||||
/**
|
||||
|
@ -53,16 +54,16 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.hibernate.HibernateBandwidthD
|
|||
SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML })
|
||||
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public class HibernateBandwidthDaoTest extends
|
||||
AbstractBandwidthDaoTest<HibernateBandwidthDao> {
|
||||
AbstractBandwidthDaoTest<IBandwidthDao> {
|
||||
|
||||
@Autowired
|
||||
private HibernateBandwidthDao dao;
|
||||
private IBandwidthDao dao;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected HibernateBandwidthDao getDao() {
|
||||
protected IBandwidthDao getDao() {
|
||||
return dao;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
|
|||
import com.raytheon.uf.edex.database.dao.DatabaseUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.State;
|
||||
|
||||
|
@ -79,7 +79,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.Sta
|
|||
public class SubscriptionRetrievalAgentTest {
|
||||
|
||||
@Autowired
|
||||
private RetrievalDao retrievalDao;
|
||||
private IRetrievalDao retrievalDao;
|
||||
|
||||
@Before
|
||||
public void setUp() throws RegistryHandlerException {
|
||||
|
@ -117,7 +117,8 @@ public class SubscriptionRetrievalAgentTest {
|
|||
IBandwidthDao bandwidthDao = mock(IBandwidthDao.class);
|
||||
|
||||
SubscriptionRetrievalAgent agent = new SubscriptionRetrievalAgent(
|
||||
route, "someUri", new Object(), 1, null, bandwidthDao) {
|
||||
route, "someUri", new Object(), 1, null, bandwidthDao,
|
||||
retrievalDao) {
|
||||
@Override
|
||||
void wakeRetrievalTasks() throws EdexException {
|
||||
// Do nothing
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
||||
|
||||
import static com.raytheon.uf.common.util.Matchers.hasNoFiles;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
|
@ -41,6 +41,7 @@ import com.raytheon.uf.common.util.TestUtil;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 01, 2013 1543 djohnson Initial creation
|
||||
* Feb 12, 2013 1543 djohnson Can only test the retrieval response is now not null.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -67,13 +68,9 @@ public class DeserializeRetrievedDataFromDirectoryTest {
|
|||
final RetrievalPluginDataObjects restored = service
|
||||
.findRetrievalPluginDataObjects();
|
||||
|
||||
// Just make sure the grid record URI is the same, that's good enough
|
||||
// for our purposes
|
||||
// Just make sure the payload is present
|
||||
assertThat(restored.getRetrievalAttributePluginDataObjects().get(0)
|
||||
.getPluginDataObjects()[0].getDataURI(),
|
||||
is(equalTo(retrievalPluginDataObjects
|
||||
.getRetrievalAttributePluginDataObjects().get(0)
|
||||
.getPluginDataObjects()[0].getDataURI())));
|
||||
.getRetrievalResponse(), is(notNullValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -22,6 +22,8 @@ package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
|||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -34,8 +36,10 @@ import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval;
|
|||
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.State;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalResponse;
|
||||
|
||||
/**
|
||||
* Test {@link PerformRetrievalPluginDataObjectsFinder}.
|
||||
|
@ -57,6 +61,8 @@ public class PerformRetrievalPluginDataObjectsFinderTest {
|
|||
|
||||
private static final String EXCEPTION_MESSAGE = "thrown on purpose";
|
||||
|
||||
private static final IRetrievalDao MOCK_DAO = mock(IRetrievalDao.class);
|
||||
|
||||
private final Retrieval retrievalThatThrowsException = new Retrieval() {
|
||||
private static final long serialVersionUID = 1109443017002028345L;
|
||||
|
||||
|
@ -74,12 +80,14 @@ public class PerformRetrievalPluginDataObjectsFinderTest {
|
|||
}
|
||||
};
|
||||
|
||||
private final RetrievalRequestRecord retrievalThatDoesNotThrowException = RetrievalRequestRecordFixture.INSTANCE
|
||||
.get();
|
||||
private RetrievalRequestRecord retrievalThatDoesNotThrowException;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
PathManagerFactoryTest.initLocalization();
|
||||
|
||||
retrievalThatDoesNotThrowException = RetrievalRequestRecordFixture.INSTANCE
|
||||
.get();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -110,9 +118,21 @@ public class PerformRetrievalPluginDataObjectsFinderTest {
|
|||
is(equalTo(State.COMPLETED)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void requestRecordSetToFailedStatusWhenNoPayloadReturned() {
|
||||
IRetrievalResponse retrievalResponse = mock(IRetrievalResponse.class);
|
||||
when(retrievalResponse.getPayLoad()).thenReturn(null);
|
||||
|
||||
PerformRetrievalPluginDataObjectsFinder.setCompletionStateFromResponse(
|
||||
retrievalThatDoesNotThrowException, retrievalResponse);
|
||||
|
||||
assertThat(retrievalThatDoesNotThrowException.getState(),
|
||||
is(equalTo(State.FAILED)));
|
||||
}
|
||||
|
||||
private void processRetrieval(RetrievalRequestRecord retrieval) {
|
||||
final PerformRetrievalPluginDataObjectsFinder pluginDataObjectsFinder = new PerformRetrievalPluginDataObjectsFinder(
|
||||
Network.OPSNET);
|
||||
Network.OPSNET, MOCK_DAO);
|
||||
pluginDataObjectsFinder.process(retrieval);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
||||
|
||||
/**
|
||||
* Test {@link RetrievalHandler}.
|
||||
|
@ -57,7 +57,7 @@ public class RetrievalHandlerTest {
|
|||
|
||||
private final ScheduledExecutorService executorService = mock(ScheduledExecutorService.class);
|
||||
|
||||
private final RetrievalDao mockDao = mock(RetrievalDao.class);
|
||||
private final IRetrievalDao mockDao = mock(IRetrievalDao.class);
|
||||
|
||||
private final RetrievalTask retrievalTask = mock(RetrievalTask.class);
|
||||
|
||||
|
|
|
@ -22,12 +22,13 @@ package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Time;
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.util.AbstractFixture;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalRequestBuilder;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.opendap.MockOpenDapRetrievalAdapter;
|
||||
|
||||
/**
|
||||
* Fixture for {@link RetrievalPluginDataObjects} instances.
|
||||
|
@ -39,6 +40,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 01, 2013 1543 djohnson Initial creation
|
||||
* Feb 12, 2013 1543 djohnson No longer set plugin data objects themselves, just retrieval attributes.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -67,21 +69,41 @@ public class RetrievalPluginDataObjectsFixture extends
|
|||
.get(seedValue);
|
||||
List<RetrievalAttributePluginDataObjects> retrievalAttributePluginDataObjects = new ArrayList<RetrievalAttributePluginDataObjects>();
|
||||
try {
|
||||
for (RetrievalAttribute attribute : requestRecord.getRetrievalObj()
|
||||
.getAttributes()) {
|
||||
// TODO: GridRecordFixture
|
||||
final GridRecord gridRecord = new GridRecord();
|
||||
gridRecord.setDataURI("dataUri" + seedValue);
|
||||
for (final RetrievalAttribute attribute : requestRecord
|
||||
.getRetrievalObj().getAttributes()) {
|
||||
retrievalAttributePluginDataObjects
|
||||
.add(new RetrievalAttributePluginDataObjects(attribute,
|
||||
new PluginDataObject[] { gridRecord }));
|
||||
.add(new RetrievalAttributePluginDataObjects(
|
||||
attribute,
|
||||
new MockOpenDapRetrievalAdapter()
|
||||
.performRequest(new IRetrievalRequestBuilder() {
|
||||
@Override
|
||||
public String processTime(
|
||||
Time prtXML) {
|
||||
return "" + prtXML;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String processCoverage() {
|
||||
return "noCoverage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequest() {
|
||||
return "request";
|
||||
}
|
||||
|
||||
@Override
|
||||
public RetrievalAttribute getAttribute() {
|
||||
return attribute;
|
||||
}
|
||||
})));
|
||||
}
|
||||
} catch (SerializationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
final RetrievalPluginDataObjects retrievalPluginDataObjects = new RetrievalPluginDataObjects(requestRecord,
|
||||
retrievalAttributePluginDataObjects);
|
||||
final RetrievalPluginDataObjects retrievalPluginDataObjects = new RetrievalPluginDataObjects(
|
||||
requestRecord, retrievalAttributePluginDataObjects);
|
||||
return retrievalPluginDataObjects;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,25 +30,38 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.annotation.DirtiesContext.ClassMode;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.raytheon.uf.common.datadelivery.event.retrieval.DataRetrievalEvent;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType;
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.event.EventBus;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.util.SpringFiles;
|
||||
import com.raytheon.uf.common.util.TestUtil;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.dao.DatabaseUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.ServiceTypeFactory;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.State;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalResponse;
|
||||
|
||||
/**
|
||||
* Test {@link RetrievalTask}.
|
||||
|
@ -61,13 +74,17 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.Sta
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 30, 2013 1543 djohnson Initial creation
|
||||
* Feb 07, 2013 1543 djohnson Add test to simulate SBN retrieval task behavior.
|
||||
* Feb 12, 2013 1543 djohnson Retrieval responses are now sent further down the chain.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
|
||||
SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML })
|
||||
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public class RetrievalTaskTest {
|
||||
/**
|
||||
* Places the plugin data object into a collection for inspection.
|
||||
|
@ -85,11 +102,21 @@ public class RetrievalTaskTest {
|
|||
throws Exception {
|
||||
final List<RetrievalAttributePluginDataObjects> retrievalAttributePluginDataObjects = retrievalPluginDataObjects
|
||||
.getRetrievalAttributePluginDataObjects();
|
||||
final RetrievalRequestRecord requestRecord = retrievalPluginDataObjects
|
||||
.getRequestRecord();
|
||||
final Retrieval retrieval = requestRecord.getRetrievalObj();
|
||||
final ServiceType serviceType = retrieval.getServiceType();
|
||||
final RetrievalAdapter serviceRetrievalAdapter = ServiceTypeFactory
|
||||
.retrieveServiceRetrievalAdapter(serviceType);
|
||||
|
||||
for (RetrievalAttributePluginDataObjects pluginDataObjectEntry : retrievalAttributePluginDataObjects) {
|
||||
PluginDataObject[] value = pluginDataObjectEntry
|
||||
.getPluginDataObjects();
|
||||
pluginDataObjects.addAll(Arrays.asList(value));
|
||||
IRetrievalResponse value = pluginDataObjectEntry
|
||||
.getRetrievalResponse();
|
||||
final Map<String, PluginDataObject[]> processed = serviceRetrievalAdapter
|
||||
.processResponse(value);
|
||||
for (PluginDataObject[] pdos : processed.values()) {
|
||||
pluginDataObjects.addAll(Arrays.asList(pdos));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +125,8 @@ public class RetrievalTaskTest {
|
|||
|
||||
private RetrievalRequestRecord sbnRetrieval;
|
||||
|
||||
private RetrievalDao dao;
|
||||
@Autowired
|
||||
private IRetrievalDao dao;
|
||||
|
||||
private final PlaceInCollectionProcessor retrievedDataProcessor = new PlaceInCollectionProcessor();
|
||||
|
||||
|
@ -106,7 +134,6 @@ public class RetrievalTaskTest {
|
|||
|
||||
@Before
|
||||
public void setUp() throws RegistryHandlerException {
|
||||
DatabaseUtil.start();
|
||||
PathManagerFactoryTest.initLocalization();
|
||||
|
||||
opsnetRetrieval = RetrievalRequestRecordFixture.INSTANCE.get(1);
|
||||
|
@ -114,16 +141,9 @@ public class RetrievalTaskTest {
|
|||
opsnetRetrieval.setNetwork(Network.OPSNET);
|
||||
sbnRetrieval.setNetwork(Network.SBN);
|
||||
|
||||
dao = RetrievalDao.getInstance();
|
||||
|
||||
EventBus.register(this);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
DatabaseUtil.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void processesRetrievalForItsSpecifiedNetwork()
|
||||
throws DataAccessLayerException {
|
||||
|
@ -148,7 +168,7 @@ public class RetrievalTaskTest {
|
|||
.size()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("dataRetrievalEvent is no longer sent separately from storage, perhaps restore it later?")
|
||||
public void dataRetrievalEventIsSentForItsSpecifiedNetwork()
|
||||
throws Exception {
|
||||
|
||||
|
@ -223,14 +243,12 @@ public class RetrievalTaskTest {
|
|||
// Create required strategies for finding, processing, and completing
|
||||
// retrievals
|
||||
final IRetrievalPluginDataObjectsFinder retrievalDataFinder = new PerformRetrievalPluginDataObjectsFinder(
|
||||
Network.OPSNET);
|
||||
final IRetrievalPluginDataObjectsProcessor retrievalPluginDataObjectsProcessor = new NotifyOfPluginDataObjectsDecorator(
|
||||
retrievedDataProcessor);
|
||||
Network.OPSNET, dao);
|
||||
final IRetrievalResponseCompleter retrievalCompleter = new RetrievalResponseCompleter(
|
||||
mock(SubscriptionNotifyTask.class));
|
||||
mock(SubscriptionNotifyTask.class), dao);
|
||||
|
||||
new RetrievalTask(Network.OPSNET, retrievalDataFinder,
|
||||
retrievalPluginDataObjectsProcessor, retrievalCompleter).run();
|
||||
retrievedDataProcessor, retrievalCompleter).run();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,18 +19,15 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.retrieval.opendap;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.util.TestUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalRequestBuilder;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.response.MockOpenDAPTranslator;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.response.OpenDAPTranslator;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.response.RetrievalResponse;
|
||||
|
||||
import dods.dap.DConnect;
|
||||
import dods.dap.DConnectTest;
|
||||
import dods.dap.DataDDS;
|
||||
|
||||
|
@ -45,6 +42,7 @@ import dods.dap.DataDDS;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 06, 2013 1543 djohnson Initial creation
|
||||
* Feb 12, 2013 1543 djohnson Use DodsUtils.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -58,20 +56,21 @@ public class MockOpenDapRetrievalAdapter extends OpenDAPRetrievalAdapter {
|
|||
* file and recreates the {@link DataDDS} instance.
|
||||
*/
|
||||
@Override
|
||||
public RetrievalResponse performRequest(IRetrievalRequestBuilder request) {
|
||||
DConnect dconnect = new DConnect(new ByteArrayInputStream(
|
||||
TestUtil.readResource(DConnectTest.class,
|
||||
"/datadelivery/opendap/compressed_rap_dataset.dods")));
|
||||
DataDDS data = null;
|
||||
public OpenDapRetrievalResponse performRequest(
|
||||
IRetrievalRequestBuilder request) {
|
||||
DataDDS data;
|
||||
try {
|
||||
data = dconnect.getData(null);
|
||||
} catch (Exception e) {
|
||||
data = DodsUtils.restoreDataDdsFromByteArray(TestUtil.readResource(
|
||||
DConnectTest.class,
|
||||
"/datadelivery/opendap/compressed_rap_dataset.dods"));
|
||||
} catch (SerializationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
final RetrievalResponse response = new RetrievalResponse(
|
||||
request.getAttribute());
|
||||
response.setPayLoad(new Object[] { data });
|
||||
final OpenDapRetrievalResponse response = new OpenDapRetrievalResponse();
|
||||
response.setAttribute(request.getAttribute());
|
||||
response.setPayLoad(data);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue