@Override public <T extends Entity> T find(Class<T> clazz, Object id) throws UnifyException { Query<T> query = new Query<T>(clazz); query.equals("id", id); return (T) db().list(query); }
@Override public <T, U extends Entity> T listValue(Class<T> valueClazz, Class<U> recordClazz, Object id, String property) throws UnifyException { return db().value(valueClazz, property, new Query<U>(recordClazz).equals("id", id)); }
@SuppressWarnings({ "unchecked", "rawtypes" }) private void deleteChildRecords(SqlEntityInfo sqlEntityInfo, Object id) throws UnifyException { for (OnDeleteCascadeInfo odci : sqlEntityInfo.getOnDeleteCascadeInfoList()) { Query<? extends Entity> query = new Query(odci.getChildEntityClass()); query.equals(odci.getChildFkField().getName(), id); deleteAll(query); } }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public <T extends Entity> T findConstraint(T record) throws UnifyException { SqlEntityInfo sqlEntityInfo = sqlDataSourceDialect.getSqlEntityInfo(record.getClass()); if (sqlEntityInfo.isUniqueConstraints()) { Query<T> query = new Query(record.getClass()); for (SqlUniqueConstraintInfo suci : sqlEntityInfo.getUniqueConstraintList().values()) { query.clear(); for (String fieldName : suci.getFieldNameList()) { query.equals(fieldName, ReflectUtils.getBeanProperty(record, fieldName)); } T constrainingRecord = find(query); if (constrainingRecord != null) { return constrainingRecord; } } } return null; }
@Override public List<SystemControlState> findSystemControlStates(SystemParameterQuery query) throws UnifyException { List<SystemControlState> systemControlStateList = new ArrayList<SystemControlState>(); Criteria criteria = query.getCriteria(); Query<SystemParameter> innerQuery = query.copyNoCriteria().add(criteria).equals("control", Boolean.TRUE).order("name"); int index = 0; List<SystemParameter> list = db().findAll(innerQuery); for (SystemParameter sysParameter : list) { systemControlStateList.add(new SystemControlState(index++, sysParameter.getName(), sysParameter.getDescription(), convert(boolean.class, sysParameter.getValue(), null))); } return systemControlStateList; }
Object value = transferBlock.getValue(); if (value != null) { criteria.equals(transferBlock.getShortProperty(), value);
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public List<? extends Listable> execute(Locale locale, SearchProviderParams params) throws UnifyException { String key = params.getKey(); if (!StringUtils.isBlank(key)) { return genericService.listAll(new Query(recordType).equals(keyProperty, key).limit(searchLimit)); } String filter = params.getFilter(); if (!StringUtils.isBlank(filter)) { return genericService.listAll(new Query(recordType).like(descProperty, filter).limit(searchLimit)); } return Collections.emptyList(); }