use of gov.ca.cwds.data.persistence.cms.SystemMeta in project API by ca-cwds.
the class SystemCodeService method listOfSystemMetas.
/**
*
* @return the response containing List of Values from System Meta Table
*/
private Response listOfSystemMetas() {
SystemMeta[] sysMeta = systemMetaDao.findAll();
ImmutableSet.Builder<gov.ca.cwds.rest.api.domain.cms.SystemMeta> builder = ImmutableSet.builder();
for (SystemMeta s : sysMeta) {
if (s != null) {
builder.add(new gov.ca.cwds.rest.api.domain.cms.SystemMeta(s));
}
}
return new SystemMetaListResponse(builder.build());
}
use of gov.ca.cwds.data.persistence.cms.SystemMeta in project api-core by ca-cwds.
the class SystemMetaDao method findAll.
/**
* @return all meta data records
*/
@SuppressWarnings("unchecked")
public SystemMeta[] findAll() {
final String namedQueryName = SystemMeta.class.getName() + ".findAll";
Session session = getSessionFactory().getCurrentSession();
Transaction txn = session.getTransaction();
boolean transactionExists = txn != null && txn.isActive();
try {
txn = transactionExists ? txn : session.beginTransaction();
Query query = session.getNamedQuery(namedQueryName);
SystemMeta[] systemMetas = (SystemMeta[]) query.list().toArray(new SystemMeta[0]);
if (!transactionExists)
txn.commit();
return systemMetas;
} catch (HibernateException h) {
if (txn != null) {
txn.rollback();
}
throw new DaoException(h);
}
}
use of gov.ca.cwds.data.persistence.cms.SystemMeta in project api-core by ca-cwds.
the class SystemCodeService method loadSystemMetas.
/**
* @return the response containing List of Values from System Meta Table
*/
protected Response loadSystemMetas() {
Response response = null;
SystemMeta[] sysMeta = systemMetaDao.findAll();
if (sysMeta != null) {
ImmutableSet.Builder<gov.ca.cwds.rest.api.domain.cms.SystemMeta> builder = ImmutableSet.builder();
for (SystemMeta s : sysMeta) {
if (s != null) {
builder.add(new gov.ca.cwds.rest.api.domain.cms.SystemMeta(s));
}
}
Set<gov.ca.cwds.rest.api.domain.cms.SystemMeta> systemMetas = builder.build();
if (systemMetas != null) {
response = new SystemMetaListResponse(builder.build());
}
}
return response;
}
use of gov.ca.cwds.data.persistence.cms.SystemMeta in project api-core by ca-cwds.
the class SystemMetaDaoTest method findAll_Args__.
@Test
public void findAll_Args__() throws Exception {
SessionFactory sessionFactory = mock(SessionFactory.class);
Session session = mock(Session.class);
Transaction tx = mock(Transaction.class);
Query query = mock(Query.class);
when(sessionFactory.getCurrentSession()).thenReturn(session);
when(session.getNamedQuery(any(String.class))).thenReturn(query);
when(session.beginTransaction()).thenReturn(tx);
SystemMetaDao target = new SystemMetaDao(sessionFactory);
SystemMeta[] actual = target.findAll();
SystemMeta[] expected = new SystemMeta[0];
assertThat(actual, is(equalTo(expected)));
}
Aggregations