Java 类org.hibernate.criterion.SimpleExpression 实例源码

项目:Equella    文件:URLCheckerPolicy.java   
@SuppressWarnings("nls")
public Criteria addRequiresCheckingCriteria(Criteria c)
{
    // DO NOT CHANGE THIS METHOD without also changing the other methods in
    // this policy class, and also the documented policy in the class
    // comments.

    SimpleExpression overOneMonthAgo = lt("lastChecked", new Date(oneMonthAgo()));

    SimpleExpression overOneDayAgo = lt("lastChecked", new Date(oneDayAgo()));
    SimpleExpression lessThanFiveTries = lt("tries", triesUntilDisabled);
    SimpleExpression notSuccessful = eq("success", false);
    LogicalExpression badButStillTrying = and(notSuccessful, and(lessThanFiveTries, overOneDayAgo));

    return c.add(or(overOneMonthAgo, badButStillTrying));
}
项目:ords-database-api    文件:DatabaseServiceImpl.java   
protected List<?> getModelObjects (List<SimpleExpression> restrictions, Class<?> cls,  boolean clearSession) {
    Session session = this.getOrdsDBSessionFactory().openSession();
    try {
        Transaction transaction = session.beginTransaction();
        if ( clearSession ) {
            session.clear();
        }
        Criteria c = session.createCriteria(cls);
        for (SimpleExpression exp : restrictions) {
            c.add(exp);
        }
        List<?> objects = (List<?>) c.list();
        transaction.commit();
        return objects;
    }
    finally {
        session.close();
    }
}
项目:ords-database-api    文件:DatabaseServiceImpl.java   
protected <T> T getModelObject(List<SimpleExpression> restrictions,
        Class<T> cls, boolean clearSession) {
    Session session = this.getOrdsDBSessionFactory().openSession();
    try {
        Transaction transaction = session.beginTransaction();
        if ( clearSession ) {
            session.clear();
        }
        Criteria c = session.createCriteria(cls);
        for (SimpleExpression exp : restrictions) {
            c.add(exp);
        }
        @SuppressWarnings("unchecked")
        List<T> objects = (List<T>) c.list();
        transaction.commit();
        if (objects.size() == 1) {
            return objects.get(0);
            //T obj =  objects.get(0);
            //session.refresh(obj);
            //return obj;
        }
        return null;
    } finally {
        session.close();
    }
}
项目:greenpepper    文件:HibernateRepositoryDao.java   
@SuppressWarnings("unchecked")
  private List<Repository> getAllRepositories(String projectName, ContentType type)
  {
      final Criteria crit = sessionService.getSession().createCriteria(Repository.class);
      SimpleExpression restriction = Restrictions.eq("contentType", type);
      SimpleExpression bothRestriction = Restrictions.eq("contentType", ContentType.BOTH);
      crit.add(Restrictions.or(restriction, bothRestriction));
      if (projectName != null)
      {
          crit.createAlias("project", "p");
          crit.add(Restrictions.eq("p.name", projectName));
      }
List<Repository> list = crit.list();
HibernateLazyInitializer.initCollection(list);
return list;
  }
项目:momo3-backend    文件:MomoApplicationService.java   
/**
 * @param mapContainer
 * @return
 */
private CompositeModule buildViewport(CompositeModule mapContainer) {
    CompositeModule viewport = new CompositeModule();
    viewport.setXtype("viewport");

    // get layout
    final SimpleExpression isBorderLayout = Restrictions.eq("type", "border");
    final Layout borderLayout = layoutService.getDao().findByUniqueCriteria(isBorderLayout);

    // submodules
    List<Module> vpSubModules = new ArrayList<Module>();
    vpSubModules.add(mapContainer); //add the map
    final ModuleDao<Module> moduleDao = moduleService.getDao();

    for (String moduleName : DEFAULT_VIEWPORT_MODULES) {
        Criterion hasModuleName = Restrictions.eq("name", moduleName);
        vpSubModules.add(moduleDao.findByUniqueCriteria(hasModuleName));
    }

    viewport.setLayout(borderLayout);
    viewport.setSubModules(vpSubModules);

    moduleService.saveOrUpdate(viewport);
    return viewport;
}
项目:momo3-backend    文件:MomoApplicationService.java   
/**
 * @param map
 * @return
 */
private CompositeModule buildMapContainer(Map map) {
    CompositeModule mapContainer = (CompositeModule) applicationContext.getBean(BEAN_ID_DEFAULT_MAP_CONTAINER);

    // get layout
    final SimpleExpression isAbsoluteLayout = Restrictions.eq("type", "absolute");
    final Layout absoluteLayout = layoutService.getDao().findByUniqueCriteria(isAbsoluteLayout);

    // submodules
    List<Module> mcSubModules = new ArrayList<Module>();
    mcSubModules.add(map); //add the map

    final ModuleDao<Module> moduleDao = moduleService.getDao();

    // add in correct order
    for (String moduleName : DEFAULT_MAP_CONTAINER_MODULES) {
        Criterion hasModuleName = Restrictions.eq("name", moduleName);
        mcSubModules.add(moduleDao.findByUniqueCriteria(hasModuleName));
    }

    mapContainer.setLayout(absoluteLayout);
    mapContainer.setSubModules(mcSubModules);

    moduleService.saveOrUpdate(mapContainer);
    return mapContainer;
}
项目:shogun2    文件:AbstractUserTokenServiceTest.java   
@SuppressWarnings("unchecked")
@Test
public void getValidTokenForUser_shouldReturnNewTokenWithDefaultExpirationAsExpected()
        throws NoSuchMethodException, SecurityException,
        InstantiationException, IllegalAccessException,
        IllegalArgumentException, InvocationTargetException {

    User user = implToTest.getUser();

    // mock the dao
    // will be called by findByUser -> return null, i.e. there is no
    // existing token for the user
    when(dao.findByUniqueCriteria(any(SimpleExpression.class))).thenReturn(null);

    E newUserToken = crudService.getValidTokenForUser(user, null);

    // verify dao invocations
    verify(dao, times(1)).findByUniqueCriteria(any(SimpleExpression.class));
    verify(dao, times(1)).saveOrUpdate((E) any(UserToken.class));
    verifyNoMoreInteractions(dao);

    assertEquals(user, newUserToken.getUser());
}
项目:shogun2    文件:AbstractUserTokenServiceTest.java   
@SuppressWarnings("unchecked")
@Test
public void getValidTokenForUser_shouldReturnNewTokenWithExplicitExpirationAsExpected()
        throws NoSuchMethodException, SecurityException,
        InstantiationException, IllegalAccessException,
        IllegalArgumentException, InvocationTargetException {

    User user = implToTest.getUser();

    // mock the dao
    // will be called by findByUser -> return null, i.e. there is no
    // existing token for the user
    when(dao.findByUniqueCriteria(any(SimpleExpression.class))).thenReturn(null);

    Integer expirationInMinutes = 120;
    E newUserToken = crudService.getValidTokenForUser(user, expirationInMinutes);

    // verify dao invocations
    verify(dao, times(1)).findByUniqueCriteria(any(SimpleExpression.class));
    verify(dao, times(1)).saveOrUpdate((E) any(UserToken.class));
    verifyNoMoreInteractions(dao);

    assertEquals(user, newUserToken.getUser());
}
项目:shogun2    文件:AbstractUserTokenServiceTest.java   
@Test
public void getValidTokenForUser_shouldReturnExistingTokenAsExpected()
        throws NoSuchMethodException, SecurityException,
        InstantiationException, IllegalAccessException,
        IllegalArgumentException, InvocationTargetException {

    User user = implToTest.getUser();

    // mock the dao
    // will be called by findByUser -> return null, i.e. there is no
    // existing token for the user
    when(dao.findByUniqueCriteria(any(SimpleExpression.class))).thenReturn(implToTest);

    E newUserToken = crudService.getValidTokenForUser(user, null);

    // verify dao invocations
    verify(dao, times(1)).findByUniqueCriteria(any(SimpleExpression.class));
    verifyNoMoreInteractions(dao);

    assertEquals(user, newUserToken.getUser());
}
项目:shogun2    文件:AbstractUserTokenServiceTest.java   
@SuppressWarnings("unchecked")
@Test
public void getValidTokenForUser_shouldDeleteExpiredTokenAndReturnNewTokenAsExpected()
        throws NoSuchMethodException, SecurityException,
        InstantiationException, IllegalAccessException,
        IllegalArgumentException, InvocationTargetException {

    E expiredToken = getExpiredUserToken();
    User user = expiredToken .getUser();

    // mock the dao
    // will be called by findByUser -> return null, i.e. there is no
    // existing token for the user
    when(dao.findByUniqueCriteria(any(SimpleExpression.class))).thenReturn((E) expiredToken);

    E newUserToken = crudService.getValidTokenForUser(user, null);

    // verify dao invocations
    verify(dao, times(1)).findByUniqueCriteria(any(SimpleExpression.class));
    verify(dao, times(1)).delete((E) any(UserToken.class));
    verify(dao, times(1)).saveOrUpdate((E) any(UserToken.class));
    verifyNoMoreInteractions(dao);

    assertEquals(user, newUserToken.getUser());
}
项目:greenpepper3    文件:HibernateRepositoryDao.java   
@SuppressWarnings("unchecked")
  private List<Repository> getAllRepositories(String projectName, ContentType type)
  {
      final Criteria crit = sessionService.getSession().createCriteria(Repository.class);
      SimpleExpression restriction = Restrictions.eq("contentType", type);
      SimpleExpression bothRestriction = Restrictions.eq("contentType", ContentType.BOTH);
      crit.add(Restrictions.or(restriction, bothRestriction));
      if (projectName != null)
      {
          crit.createAlias("project", "p");
          crit.add(Restrictions.eq("p.name", projectName));
      }
List<Repository> list = crit.list();
HibernateLazyInitializer.initCollection(list);
return list;
  }
项目:national-biomedical-image-archive    文件:GtCriteriaFactory.java   
public SimpleExpression constructCriteria(String fieldName, String value, String fieldType)
  throws Exception
  {
if (fieldType.equalsIgnoreCase("java.lang.String"))
{
    if (value.equalsIgnoreCase("Not Populated (NULL)"))
    {
        value="null";
    }
    return Restrictions.gt(fieldName, value);
}
else
{
    return Restrictions.gt(fieldName, ConstructorGenerator.getConstructor(fieldType).newInstance(value));
}
  }
项目:national-biomedical-image-archive    文件:LeCriteriaFactory.java   
public SimpleExpression constructCriteria(String fieldName, String value, String fieldType)
throws Exception
{

    if (fieldType.equalsIgnoreCase("java.lang.String"))
    {
        if (value.equalsIgnoreCase("Not Populated (NULL)"))
        {
            value = "null";
        }
        return Restrictions.le(fieldName, value);
    }
    else
    {
        return Restrictions.le(fieldName, ConstructorGenerator.getConstructor(fieldType).newInstance(value));
    }
}
项目:national-biomedical-image-archive    文件:GeCriteriaFactory.java   
public SimpleExpression constructCriteria(String fieldName, String value, String fieldType)
throws Exception
{
    if (fieldType.equalsIgnoreCase("java.lang.String"))
    {
        if (value.equalsIgnoreCase("Not Populated (NULL)"))
        {
            value = "null";
        }
        return Restrictions.ge(fieldName, value);
    }
    else
    {
        return Restrictions.ge(fieldName, ConstructorGenerator.getConstructor(fieldType).newInstance(value));
    }

}
项目:national-biomedical-image-archive    文件:LtCriteriaFactory.java   
public SimpleExpression constructCriteria(String fieldName, String value, String fieldType)
throws Exception
{
    if (fieldType.equalsIgnoreCase("java.lang.String"))
    {
        if(value.equalsIgnoreCase("Not Populated (NULL)"))
        {
            value = "null";
        }
        return Restrictions.lt(fieldName, value);
    }
    else
    {
        return Restrictions.lt(fieldName, ConstructorGenerator.getConstructor(fieldType).newInstance(value));
    }
}
项目:national-biomedical-image-archive    文件:NeCriteriaFactory.java   
public SimpleExpression constructCriteria(String fieldName, String value, String fieldType)
throws Exception
{
    if (fieldType.equalsIgnoreCase("java.lang.String"))
    {
        if (value.equalsIgnoreCase("Not Populated (NULL)"))
        {
            value = "null";
        }
        return Restrictions.ne(fieldName, value).ignoreCase();
    }
    else
    {
        return Restrictions.ne(fieldName, ConstructorGenerator.getConstructor(fieldType).newInstance(value));
    }

}
项目:openbravo-brazil    文件:DatabaseValidator.java   
/**
 * Checks if old-style password columns exist which should be updated to use the new references.
 * 
 */
private void checkPasswordColumns(SystemValidationResult result) {
  org.openbravo.model.ad.domain.Reference hashed = OBDal.getInstance().get(
      org.openbravo.model.ad.domain.Reference.class, "C5C21C28B39E4683A91779F16C112E40");
  org.openbravo.model.ad.domain.Reference encrypted = OBDal.getInstance().get(
      org.openbravo.model.ad.domain.Reference.class, "16EC6DF4A59747749FDF256B7FBBB058");

  // if one of the old-booleans is set, but not using new reference-id's -> report as warning
  SimpleExpression enc = Restrictions.eq(Column.PROPERTY_DISPLAYENCRIPTION, Boolean.TRUE);
  LogicalExpression newRefs = Restrictions.or(Restrictions.eq(Column.PROPERTY_REFERENCE, hashed),
      Restrictions.eq(Column.PROPERTY_REFERENCE, encrypted));
  OBCriteria<Column> colQuery = OBDal.getInstance().createCriteria(Column.class);
  colQuery.add(Restrictions.and(enc, Restrictions.not(newRefs)));

  // only validate given module (if given)
  if (validateModule != null) {
    colQuery.add(Restrictions.eq(Column.PROPERTY_MODULE, validateModule));
  }
  if (colQuery.count() > 0) {
    List<Column> columns = colQuery.list();
    for (Column column : columns) {
      result
          .addWarning(
              SystemValidationType.OLDSTYLE_PASSWORD_COLUMNS,
              "The column '"
                  + column.getTable().getName()
                  + "'.'"
                  + column.getName()
                  + "' is using old-style config for password-type columns. It should be changed to use one of the new references '"
                  + hashed.getName() + "' or '" + encrypted.getName() + "'");
    }
  }
}
项目:ords-database-api    文件:TableViewServiceImpl.java   
@SuppressWarnings("unchecked")
@Override
public List<TableViewInfo> listDatasetsForDatabase(int physicalDatabaseId)
        throws Exception {
    ArrayList<SimpleExpression> exprs = new ArrayList<SimpleExpression>();
    exprs.add(Restrictions.eq("physicalDatabaseId", physicalDatabaseId));
    List<TableView> views = (List<TableView>) this.getModelObjects(exprs, TableView.class, false);
    ArrayList<TableViewInfo> viewInfoList = new ArrayList<TableViewInfo>();
    for ( TableView v: views ) {
        TableViewInfo vi = new TableViewInfo(v);
        viewInfoList.add(vi);
    }
    return  viewInfoList;
}
项目:ords-database-api    文件:DatabaseRecordServiceImpl.java   
@Override
public OrdsPhysicalDatabase getRecordFromGivenName(String givenName)
        throws Exception {
    ArrayList<SimpleExpression> exprs = new ArrayList<SimpleExpression>();
    exprs.add(Restrictions.eq("dbName", givenName));
    OrdsDB odb = this.getModelObject(exprs, OrdsDB.class, false);

    exprs.clear();
    exprs.add(Restrictions.eq("logicalDatabaseId", odb.getLogicalDatabaseId()));

    return this.getModelObject(exprs, OrdsPhysicalDatabase.class, true);
}
项目:MirServer-Netty    文件:DB.java   
public static List query(Class clazz, SimpleExpression... simpleExpressions) {
    Criteria criteria = getSession().createCriteria(clazz);
    for (SimpleExpression simpleExpression : simpleExpressions) {
        criteria.add(simpleExpression);
    }
    List result = criteria.list();
    return result;
}
项目:livingdoc-confluence    文件:HibernateRepositoryDao.java   
@SuppressWarnings(SUPPRESS_UNCHECKED)
private List<Repository> getAllRepositories(String projectName, ContentType type) {
    final Criteria crit = sessionService.getSession().createCriteria(Repository.class);
    SimpleExpression restriction = Restrictions.eq("contentType", type);
    SimpleExpression bothRestriction = Restrictions.eq("contentType", ContentType.BOTH);
    crit.add(Restrictions.or(restriction, bothRestriction));
    if (projectName != null) {
        crit.createAlias("project", "p");
        crit.add(Restrictions.eq("p.name", projectName));
    }
    List<Repository> list = crit.list();
    HibernateLazyInitializer.initCollection(list);
    return list;
}
项目:momo3-backend    文件:ApplicationStateService.java   
/**
 *
 * @param owner
 * @return
 */
@PreAuthorize("hasRole(@configHolder.getDefaultUserRoleName())")
@Transactional(readOnly = true)
public List<E> findAllWorkstatesOfUser(User owner) {
    SimpleExpression eqOwner = Restrictions.eq("owner", owner);
    return dao.findByCriteria(eqOwner);
}
项目:shogun2    文件:RoleService.java   
/**
 * Returns the role for the given (unique) role name.
 * If no role was found, null will be returned.
 *
 * @param roleName A unique role name.
 * @return The unique role for the role name or null.
 */
@Transactional(readOnly = true)
public E findByRoleName(String roleName) {

    SimpleExpression eqRoleName =
        Restrictions.eq("name", roleName);

    E role = dao.findByUniqueCriteria(eqRoleName);

    return role;
}
项目:shogun2    文件:WpsProcessExecuteService.java   
/**
 * Removes the passed WpsProcessExecute from all WpsPlugins and afterwards
 * deletes the WpsProcessExecute itself. This overrides the generic method
 * to delete {@link AbstractCrudService#delete(de.terrestris.shogun2.model.PersistentObject)}.
 *
 * @param wpsProcessExecute
 */
@Override
@PreAuthorize("hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(#plugin, 'DELETE')")
public void delete(E wpsProcessExecute) {
    if (wpsPluginService == null) {
        LOG.error("WPSProcessExecute cannot be deleted, failed to autowire WpsPluginService");
        return;
    }

    WpsPluginDao<WpsPlugin> wpsPluginDao = wpsPluginService.getDao();

    SimpleExpression eqProcess = Restrictions.eq("process", wpsProcessExecute);
    List<WpsPlugin> wpsPlugins = wpsPluginDao.findByCriteria(eqProcess);

    Integer processId = wpsProcessExecute.getId();
    for (WpsPlugin wpsPlugin : wpsPlugins) {
        WpsProcessExecute process = wpsPlugin.getProcess();
        if (process != null) {
            String msg = String.format(
                "Remove WpsProcessExecute (id=%s) from WpsPlugin (id=%s)",
                processId, wpsPlugin.getId()
            );
            LOG.debug(msg);
            wpsPlugin.setProcess(null);
            wpsPluginService.saveOrUpdate(wpsPlugin);
        }
    }
    LOG.debug(String.format("Delete plugin (id=%s)", processId));

    // Call overridden parent to actually delete the entity itself
    super.delete(wpsProcessExecute);
}
项目:shogun2    文件:AbstractUserTokenServiceTest.java   
@Test
public void findByUser_shouldFindUserToken() {
    User user = new User();

    // mock the dao
    when(dao.findByUniqueCriteria(any(SimpleExpression.class))).thenReturn(implToTest);

    E actualUserToken = crudService.findByUser(user);

    verify(dao, times(1)).findByUniqueCriteria(any(SimpleExpression.class));
    verifyNoMoreInteractions(dao);

    assertEquals(actualUserToken, implToTest);
}
项目:shogun2    文件:AbstractUserTokenServiceTest.java   
@Test
public void findByUser_shouldFindNothing() {
    User userWithoutToken = new User();

    // mock the dao
    when(dao.findByUniqueCriteria(any(SimpleExpression.class))).thenReturn(null);

    E actualUserToken = crudService.findByUser(userWithoutToken);

    verify(dao, times(1)).findByUniqueCriteria(any(SimpleExpression.class));
    verifyNoMoreInteractions(dao);

    assertNull(actualUserToken);
}
项目:shogun2    文件:AbstractUserTokenServiceTest.java   
@Test(expected=HibernateException.class)
public void findByUser_shouldThrowHibernateException() {
    User userThatThrowsException = new User();

    // mock the dao
    doThrow(new HibernateException("errormsg"))
        .when(dao).findByUniqueCriteria(any(SimpleExpression.class));

    crudService.findByUser(userThatThrowsException);

    verify(dao, times(1)).findByUniqueCriteria(any(SimpleExpression.class));
    verifyNoMoreInteractions(dao);
}
项目:shogun2    文件:RoleServiceTest.java   
@Test(expected=HibernateException.class)
public void findByRoleName_shouldThrowHibernateException() {
    String roleName = "ROLE_THAT_THROWS_EXCEPTION";

    // mock the dao
    doThrow(new HibernateException("errormsg"))
        .when(dao).findByUniqueCriteria(any(SimpleExpression.class));

    crudService.findByRoleName(roleName);

    verify(dao, times(1)).findByUniqueCriteria(any(SimpleExpression.class));
    verifyNoMoreInteractions(dao);
}
项目:cagrid-core    文件:DomainModelBuilder.java   
private void setUMLClassReferences(UMLAssociationMetadata coreAssociation, UMLAssociation domainAssociation)
    throws ApplicationException, DomainModelGenerationException {

    SimpleExpression idRes = Restrictions.eq("id", coreAssociation.getId());
    ProjectionList projection = Projections.projectionList().add(Projections.property("sourceUMLClassMetadata.id"))
        .add(Projections.property("targetUMLClassMetadata.id"));
    DetachedCriteria criteria = DetachedCriteria.forClass(UMLAssociationMetadata.class);
    criteria.add(idRes);
    criteria.setProjection(projection);

    long start = System.currentTimeMillis();
    List rList = this.cadsr.query(criteria, UMLAssociationMetadata.class.getName());
    Iterator iterator = rList.iterator();
    if (iterator == null || !iterator.hasNext()) {
        throw new DomainModelGenerationException("Unable to located source and target ids for association!");
    }
    // should have length 2, with src, target
    Object[] ids = (Object[]) iterator.next();
    if (ids == null || ids.length != 2) {
        throw new DomainModelGenerationException("Unexpected result during query for association ids!");
    }

    domainAssociation.getSourceUMLAssociationEdge().getUMLAssociationEdge().setUMLClassReference(
        new UMLClassReference((String) ids[0]));

    domainAssociation.getTargetUMLAssociationEdge().getUMLAssociationEdge().setUMLClassReference(
        new UMLClassReference((String) ids[1]));

    double duration = (System.currentTimeMillis() - start) / 1000.0;
    LOG.info("Association id fetch took " + duration + " seconds.");

}
项目:eionet.webq    文件:RemoveExpiredUserFilesTaskTest.java   
@Test
public void performsRemovalBasedOnConfiguredProperties() throws Exception {
    removeExpiredUserFilesTask.setExpirationHours("1");
    removeExpiredUserFilesTask.removeExpiredUserFiles();

    ArgumentCaptor<SimpleExpression> criterionCaptor = ArgumentCaptor.forClass(SimpleExpression.class);
    verify(criteria).add(criterionCaptor.capture());

    Date expectedDate = DateUtils.addHours(new Date(), -expirationTimeInHours);
    Timestamp date = (Timestamp) criterionCaptor.getValue().getValue();
    assertEquals(expectedDate.getTime(), date.getTime(), 1000);
}
项目:cagrid2    文件:DomainModelBuilder.java   
private void setUMLClassReferences(UMLAssociationMetadata coreAssociation, UMLAssociation domainAssociation)
    throws ApplicationException, DomainModelGenerationException {

    SimpleExpression idRes = Restrictions.eq("id", coreAssociation.getId());
    ProjectionList projection = Projections.projectionList().add(Projections.property("sourceUMLClassMetadata.id"))
        .add(Projections.property("targetUMLClassMetadata.id"));
    DetachedCriteria criteria = DetachedCriteria.forClass(UMLAssociationMetadata.class);
    criteria.add(idRes);
    criteria.setProjection(projection);

    long start = System.currentTimeMillis();
    List rList = this.cadsr.query(criteria, UMLAssociationMetadata.class.getName());
    Iterator iterator = rList.iterator();
    if (iterator == null || !iterator.hasNext()) {
        throw new DomainModelGenerationException("Unable to located source and target ids for association!");
    }
    // should have length 2, with src, target
    Object[] ids = (Object[]) iterator.next();
    if (ids == null || ids.length != 2) {
        throw new DomainModelGenerationException("Unexpected result during query for association ids!");
    }

    UMLClassReference ref = new UMLClassReference();
    ref.setRefid(((String) ids[0]));
    domainAssociation.getSourceUMLAssociationEdge().getUMLAssociationEdge().setUMLClassReference(
       ref);
    UMLClassReference ref2 = new UMLClassReference();
    ref2.setRefid(((String) ids[1]));
    domainAssociation.getTargetUMLAssociationEdge().getUMLAssociationEdge().setUMLClassReference(
        ref2);

    double duration = (System.currentTimeMillis() - start) / 1000.0;
    LOG.info("Association id fetch took " + duration + " seconds.");

}
项目:caintegrator    文件:CopyNumberAlterationCriterionConverter.java   
private void addSegmentValueCriterion(Criteria segmentDataCrit) {
    // First case, if both are null.
    if (copyNumberCriterion.getUpperLimit() == null && copyNumberCriterion.getLowerLimit() == null) {
        return;
    }
    SimpleExpression upperLimitExpression = Restrictions.le("segmentValue",
            copyNumberCriterion.getUpperLimit());
    SimpleExpression lowerLimitExpression = Restrictions.ge("segmentValue",
            copyNumberCriterion.getLowerLimit());
    // Second case, upper limit is higher than lower limit, value is in between the two
    if (copyNumberCriterion.isInsideBoundaryType()) {
        segmentDataCrit.add(Restrictions.conjunction().add(upperLimitExpression).add(lowerLimitExpression));
        return;
     }
    // Third case, lower limit is higher than upper limit, value is outside of the limits
    if (copyNumberCriterion.isOutsideBoundaryType()) {
        segmentDataCrit.add(Restrictions.disjunction().add(upperLimitExpression).add(lowerLimitExpression));
        return;
    }
    // Fourth case, upper limit has a value, lower limit is null.
    if (copyNumberCriterion.getUpperLimit() != null) {
        segmentDataCrit.add(upperLimitExpression);
        return;
    }
    // Fifth case, lower limit has a value, upper limit is null.
    if (copyNumberCriterion.getLowerLimit() != null) {
        segmentDataCrit.add(lowerLimitExpression);
    }
}
项目:SensorWebClient    文件:HibernateUtil.java   
@SuppressWarnings("unchecked")
public static List<BasicRule> getAllOtherPublishedBasicRules(String userID) {
    Session session = getSessionFactory().getCurrentSession();
    session.beginTransaction();
    Criteria crit = session.createCriteria(BasicRule.class);
    Criterion isOwner = Restrictions.not(Restrictions.eq(OWNER_ID, valueOf(userID)));
    SimpleExpression isPublished = Restrictions.eq(PUBLISHED, true);
    List<BasicRule> rules = crit.add(Restrictions.and(isOwner, isPublished)).list();
    session.getTransaction().commit();
    return rules;
}
项目:SensorWebClient    文件:HibernateUtil.java   
@Deprecated
@SuppressWarnings("unchecked")
public static List<ComplexRule> getAllOtherPublishedComplexRules(String userID) {
    Session session = getSessionFactory().getCurrentSession();
    session.beginTransaction();
    Criteria crit = session.createCriteria(ComplexRule.class);
    Criterion isOwner = Restrictions.not(Restrictions.eq(OWNER_ID, valueOf(userID)));
    SimpleExpression isPublished = Restrictions.eq(PUBLISHED, true);
    List<ComplexRule> rules = crit.add(Restrictions.and(isOwner, isPublished)).list();
    session.getTransaction().commit();
    return rules;
}
项目:ords-database-api    文件:TableViewServiceImpl.java   
@Override
public TableView getTableViewRecord(int tableViewId) {
    ArrayList<SimpleExpression> exprs = new ArrayList<SimpleExpression>();
    exprs.add(Restrictions.eq("id", tableViewId));
    return this.getModelObject(exprs, TableView.class, false);
}
项目:ords-database-api    文件:DatabaseServiceImpl.java   
protected OrdsDB getLogicalDatabaseFromID(int id) {
    ArrayList<SimpleExpression> exprs = new ArrayList<SimpleExpression>();
    exprs.add(Restrictions.eq("logicalDatabaseId", id));
    return this.getModelObject(exprs, OrdsDB.class, false);

}
项目:ords-database-api    文件:DatabaseServiceImpl.java   
protected OrdsPhysicalDatabase getPhysicalDatabaseFromID(int dbId) {
    ArrayList<SimpleExpression> exprs = new ArrayList<SimpleExpression>();
    exprs.add(Restrictions.eq("physicalDatabaseId", dbId));
    return this.getModelObject(exprs, OrdsPhysicalDatabase.class, true);
}
项目:ords-database-api    文件:DatabaseRecordServiceImpl.java   
@Override
public OrdsPhysicalDatabase getRecordFromId(int id) {
    ArrayList<SimpleExpression> exprs = new ArrayList<SimpleExpression>();
    exprs.add(Restrictions.eq("physicalDatabaseId", id));
    return this.getModelObject(exprs, OrdsPhysicalDatabase.class, true);
}
项目:mamute    文件:InvisibleForUsersRule.java   
private SimpleExpression isAuthor(String modelAlias) {
    return eq(modelAlias+".author.id", currentUser.getCurrent().getId());
}
项目:mamute    文件:InvisibleForUsersRule.java   
private SimpleExpression isVisible(String modelAlias) {
    return eq(modelAlias+".moderationOptions.invisible", false);
}