Example usage for org.hibernate.criterion DetachedCriteria add

List of usage examples for org.hibernate.criterion DetachedCriteria add

Introduction

In this page you can find the example usage for org.hibernate.criterion DetachedCriteria add.

Prototype

public DetachedCriteria add(Criterion criterion) 

Source Link

Document

Add a restriction

Usage

From source file:com.ephesoft.dcma.da.dao.hibernate.SecurityGroupDaoImpl.java

License:Open Source License

@Override
public SecurityGroup findSecurityGroupByName(final String groupName) {
    LOGGER.debug("Finding group with the given group name");
    SecurityGroup group = null;//  w w  w. j a  va 2 s . com
    if (!EphesoftStringUtil.isNullOrEmpty(groupName)) {
        final DetachedCriteria criteria = this.criteria();
        if (null != criteria) {
            criteria.add(Restrictions.eq(GROUP_NAME, groupName));
            group = this.findSingle(criteria);
        }
    }
    LOGGER.debug("Group with group name ", groupName, (null == group) ? " not found." : "founded.");
    return group;
}

From source file:com.ephesoft.dcma.da.dao.hibernate.SecurityUserDaoImpl.java

License:Open Source License

@Override
public SecurityUser findSecurityUserByName(final String userName) {
    LOGGER.debug("Finding user with the given user name");
    SecurityUser user = null;//from   ww  w  . j a  v  a  2s.co m
    if (!EphesoftStringUtil.isNullOrEmpty(userName)) {
        final DetachedCriteria criteria = this.criteria();
        if (null != criteria) {
            criteria.add(Restrictions.eq(USER_NAME, userName));
            user = this.findSingle(criteria);
        }
    }
    LOGGER.debug("User with user name ", userName, (null == user) ? " not founded." : "found.");
    return user;
}

From source file:com.ephesoft.dcma.da.dao.hibernate.ServerRegistryDaoImpl.java

License:Open Source License

/**
 * An api to fetch all the Server Registry by IP address, port number and context.
 * //from w  ww.  j a v  a  2  s .  com
 * @param ipAddress String
 * @param portNumber String
 * @param context String
 * 
 * @return ServerRegistry return the server registry.
 */
@Override
public ServerRegistry getServerRegistry(String ipAddress, String portNumber, String context) {
    DetachedCriteria criteria = criteria();
    criteria.add(Restrictions.eq("ipAddress", ipAddress));
    criteria.add(Restrictions.eq("port", portNumber));
    criteria.add(Restrictions.eq("appContext", context));
    return findSingle(criteria);
}

From source file:com.ephesoft.dcma.da.dao.hibernate.ServerRegistryDaoImpl.java

License:Open Source License

/**
 * API to get Inactive Servers.//  w w w. j  av  a 2 s  .c  om
 * 
 * @return List<ServerRegistry>
 */
@Override
public List<ServerRegistry> getInactiveServers() {
    DetachedCriteria criteria = criteria();
    criteria.add(Restrictions.eq("active", false));
    return find(criteria);
}

From source file:com.ephesoft.dcma.da.dao.hibernate.ServiceStatusDaoImpl.java

License:Open Source License

@Override
public List<ServiceStatus> getServiceStatusList(final ServiceType serviceType) {
    LOGGER.debug(EphesoftStringUtil.concatenate("Getting status of service: ", serviceType.toString()));
    final DetachedCriteria detachedCriteria = criteria();
    detachedCriteria.add(Restrictions.eq(SERVICE_TYPE, serviceType));
    final List<ServiceStatus> serviceStatusList = find(detachedCriteria);
    if (!CollectionUtil.isEmpty(serviceStatusList)) {
        final ServerRegistry serverRegistry = serviceStatusList.get(0).getServerRegistry();
        LOGGER.debug(EphesoftStringUtil.concatenate("Status of service list", serviceType.toString(),
                "is under: ", serverRegistry.getIpAddress()));
    } else {//from w w  w.  j  a va 2 s .  c o  m
        LOGGER.debug(EphesoftStringUtil.concatenate("Status of service list", serviceType.toString(),
                "is not under any server"));
    }
    return serviceStatusList;
}

From source file:com.ephesoft.dcma.da.dao.hibernate.ServiceStatusDaoImpl.java

License:Open Source License

@Override
public List<ServiceStatus> getServiceStatusListForServer(final ServerRegistry serverRegistry,
        final ServiceType serviceType) {
    LOGGER.debug(EphesoftStringUtil.concatenate("Getting status of service: ", serviceType.toString(),
            "for Server: ", serverRegistry.getIpAddress()));
    final DetachedCriteria detachedCriteria = criteria();
    detachedCriteria.add(Restrictions.and(Restrictions.eq(SERVER_REGISTRY, serverRegistry),
            Restrictions.eq(SERVICE_TYPE, serviceType)));
    final List<ServiceStatus> serviceStatusList = find(detachedCriteria);
    if (!CollectionUtil.isEmpty(serviceStatusList)) {
        LOGGER.debug(EphesoftStringUtil.concatenate("Status of service list", serviceType.toString(),
                "is under: ", serverRegistry.getIpAddress()));
    } else {/* w  w  w. ja  v a 2 s  .  c o m*/
        LOGGER.debug(EphesoftStringUtil.concatenate("Status of service list", serviceType.toString(),
                "is not under given server"));
    }
    return serviceStatusList;
}

From source file:com.ephesoft.dcma.da.dao.hibernate.TableColumnsInfoDaoImpl.java

License:Open Source License

/**
 * An API to fetch all TableColumnsInfo by TableInfo.
 * /* ww  w .  j a v a  2s  .  co  m*/
 * @param tableInfo TableInfo
 * @return List<TableColumnsInfo>
 */
@Override
public List<TableColumnsInfo> getTableColumnsInfoByTableInfo(TableInfo tableInfo) {

    LOGGER.info("TableInfo : " + tableInfo);
    DetachedCriteria criteria = criteria();
    criteria.add(Restrictions.eq("tableInfo", tableInfo));

    return find(criteria);

}

From source file:com.ephesoft.dcma.da.dao.hibernate.TableColumnsInfoDaoImpl.java

License:Open Source License

/**
 * An API to fetch all TableColumnsInfo by document type name and table name.
 * /*  w  w  w . ja  v a  2 s  .c  o  m*/
 * @param docTypeName String
 * @param tableName String
 * @return List<TableInfo>
 */
@Override
public List<TableColumnsInfo> getTableColumnsInfo(String docTypeName, String tableName) {

    LOGGER.info("docTypeName  : " + docTypeName);
    DetachedCriteria criteria = criteria();
    criteria.createAlias("tableInfo", "tableInfo", JoinFragment.INNER_JOIN);
    criteria.add(Restrictions.eq("tableInfo.name", tableName));
    criteria.createAlias("tableInfo.docType", "docType", JoinFragment.INNER_JOIN);
    criteria.add(Restrictions.eq("docType.name", docTypeName));

    return find(criteria);

}

From source file:com.ephesoft.dcma.da.dao.hibernate.TableInfoDaoImpl.java

License:Open Source License

/**
 * An API to fetch all TableInfo by document type name.
 * //from   w  w  w.  j  av a2 s. c  o  m
 * @param docTypeName String
 * @param batchClassIdentifier String
 * @return List<TableInfo>
 */
@Override
public List<TableInfo> getTableInfoByDocTypeName(String docTypeName, String batchClassIdentifier) {

    LOGGER.info("Document type name : " + docTypeName);
    DetachedCriteria criteria = criteria();
    criteria.createAlias("docType", "docType", JoinFragment.INNER_JOIN);
    criteria.add(Restrictions.eq("docType.name", docTypeName));
    criteria.createAlias("docType.batchClass", "batchClass", JoinFragment.INNER_JOIN);
    criteria.add(Restrictions.eq("batchClass.identifier", batchClassIdentifier));

    return find(criteria);

}

From source file:com.ephesoft.dcma.da.dao.hibernate.TableInfoDaoImpl.java

License:Open Source License

/**
 * An API to fetch all TableInfo by document type.
 * /*from   w w w.j  ava  2 s.co  m*/
 * @param documentType DocumentType
 * @return List<TableInfo>
 */
@Override
public List<TableInfo> getTableInfoByDocumentType(DocumentType documentType) {
    DetachedCriteria criteria = criteria();
    criteria.add(Restrictions.eq("docType", documentType));
    return find(criteria);
}