templateForm.setView(viewName);
    private static int fillTemplateForm(TemplateQuery template, InterMineObject object,                                        TemplateForm templateForm, Model model) {        List constraints = template.getAllConstraints();        int unmatchedConstraintCount = constraints.size();        String equalsString = ConstraintOp.EQUALS.getIndex().toString();        for (int constraintIndex = 0; constraintIndex < constraints.size(); constraintIndex++) {            Constraint c = (Constraint) constraints.get(constraintIndex);            String constraintIdentifier = c.getIdentifier();            String[] bits = constraintIdentifier.split("\\.");                        if (bits.length == 2) {                String className = model.getPackageName() + "." + bits[0];                String fieldName = bits[1];                                try {                    Class testClass = Class.forName(className);                    if (testClass.isInstance(object)) {                        ClassDescriptor cd = model.getClassDescriptorByName(className);                        if (cd.getFieldDescriptorByName(fieldName) != null) {                            Object fieldValue = TypeUtil.getFieldValue(object, fieldName);                                                        if (fieldValue == null) {                                // this field is not a good constraint value                                continue;                            }                                                        unmatchedConstraintCount--;                            templateForm.setAttributeOps("" + (constraintIndex + 1), equalsString);                            templateForm.setAttributeValues("" + (constraintIndex + 1), fieldValue);                        }                    }                } catch (ClassNotFoundException e) {                    LOG.error(e);                } catch (IllegalAccessException e) {                    LOG.error(e);                }                            }        }        return unmatchedConstraintCount;    }