if (in.getIdentifier() instanceof Property) {
propertyInQuery = true;
final Property property = (Property) in.getIdentifier();
return new INEvaluator<String, Criterion, Object>() {
public Criterion evaluate(Object paramValue) {
Disjunction disj = Restrictions.disjunction();
String propertyNS = property.getNamespace();
String propertyName = property.getName();
for (Value value : in.getValues()) {
Conjunction conj = Restrictions.conjunction();
if (!StringUtils.isEmpty(property.getNamespace())) {
conj.add(Restrictions.gt(PROPERTY_NS_DB_FIELD, propertyNS));
}
conj.add(Restrictions.gt(PROPERTY_NAME_DB_FIELD, propertyName));
conj.add(Restrictions.gt(PROPERTY_VALUE_DB_FIELD, value.getValue()));
disj.add(conj);
}
return disj;
};
public String getIdentifier() {
return property.toString();
};
};
} else {
final String fieldName = in.getIdentifier().getName();
if (INSTANCE_STATUS_FIELD.equals(fieldName)) {
short noState = 200; // TODO move to constants
final Disjunction disj = Restrictions.disjunction();
final Collection values = ValuesHelper.extract((Collection<Value>) in.getValues());
if (values.contains(STATUS_ACTIVE)) {
disj.add(Restrictions.eq(INSTANCE_STATUS_DB_FIELD, ProcessState.STATE_NEW));
disj.add(Restrictions.eq(INSTANCE_STATUS_DB_FIELD, ProcessState.STATE_ACTIVE));
disj.add(Restrictions.eq(INSTANCE_STATUS_DB_FIELD, ProcessState.STATE_READY));
}
if (values.contains(STATUS_SUSPENDED)) {
disj.add(Restrictions.eq(INSTANCE_STATUS_DB_FIELD, ProcessState.STATE_SUSPENDED));
}
if (values.contains(STATUS_ERROR)) {
disj.add(Restrictions.eq(INSTANCE_STATUS_DB_FIELD, noState)); // Error instance state doesn't exist yet
}
if (values.contains(STATUS_COMPLETED)) {
disj.add(Restrictions.eq(INSTANCE_STATUS_DB_FIELD, ProcessState.STATE_COMPLETED_OK));
}
if (values.contains(STATUS_TERMINATED)) {
disj.add(Restrictions.eq(INSTANCE_STATUS_DB_FIELD, ProcessState.STATE_TERMINATED));
}
if (values.contains(STATUS_FAULTED)) {
disj.add(Restrictions.eq(INSTANCE_STATUS_DB_FIELD, ProcessState.STATE_COMPLETED_WITH_FAULT));
}
return new INEvaluator<String, Criterion, Object>() {
public Criterion evaluate(Object paramValue) {
return disj;
};