Package org.vosao.entity

Examples of org.vosao.entity.FieldEntity


    if (form == null) {
      errors.add(Messages.get("form_not_found", field.getFormId()));
    }
    else {   
      if (field.getId() == null) {
        FieldEntity myField = getDao().getFieldDao().getByName(
            form, field.getName());
        if (myField != null) {
          errors.add(Messages.get("form.field_already_exists"));
        }
      }
View Full Code Here


  @Override
  public List<FieldEntity> checkOrder(FormEntity form) {
    List<FieldEntity> fields = getDao().getFieldDao().getByForm(form);
    for (int i = 0; i < fields.size(); i++) {
      FieldEntity field = fields.get(i);
      if (i != field.getIndex()) {
        field.setIndex(i);
        getDao().getFieldDao().save(field);
      }
    }
    return getDao().getFieldDao().getByForm(form);
  }
View Full Code Here

  public void testSave() {
    FormEntity form = formTool.addForm("form");
    fieldTool.addField("field1", FieldType.TEXT, "text", form);
    List<FieldEntity> fields = getDao().getFieldDao().getByForm(form);
    assertEquals(1, fields.size());
    FieldEntity field1 = fields.get(0);
    assertEquals("field1", field1.getName());
 
View Full Code Here

    assertEquals("field1", field1.getName());
 
 
  public void testGetById() {
    FormEntity form = formTool.addForm("form");
    FieldEntity field = fieldTool.addField("field1", FieldType.TEXT, "text",
        form);
    assertNotNull(field.getId());
    FieldEntity field2 = getDao().getFieldDao().getById(field.getId());
    assertEquals(field.getTitle(), field2.getTitle());
 
View Full Code Here

    assertEquals(field.getTitle(), field2.getTitle());
 

  public void testUpdate() {
    FormEntity form = formTool.addForm("form");
    FieldEntity field = fieldTool.addField("field1", FieldType.TEXT, "text",
        form);
    assertNotNull(field.getId());
    FieldEntity field2 = getDao().getFieldDao().getById(field.getId());
    field2.setTitle("update");
    getDao().getFieldDao().save(field2);
    FieldEntity field3 = getDao().getFieldDao().getById(field.getId());
    assertEquals("update", field3.getTitle());
  }
View Full Code Here

    fieldTool.addField("field2", FieldType.TEXT, "text2", form);
    fieldTool.addField("field3", FieldType.TEXT, "text3", form);
    FormEntity form2 = formTool.addForm("form");
    fieldTool.addField("field21", FieldType.TEXT, "text21", form2);
    fieldTool.addField("field22", FieldType.TEXT, "text22", form2);
    FieldEntity field = getDao().getFieldDao().getByName(form, "field3");
    assertNotNull(field);
    assertEquals("field3", field.getName());
  }
View Full Code Here

    dao = aDao;
  }

  public FieldEntity addField(final String name, final FieldType type,
      final String defaultValue, final FormEntity form) {
    FieldEntity field = new FieldEntity(form.getId(), name, name, type,
        false, defaultValue);
    dao.getFieldDao().save(field);
    return field;
  }
View Full Code Here

  public void readFields(Element formElement, FormEntity form)
      throws DaoTaskException {
    for (Iterator<Element> i = formElement.elementIterator(); i.hasNext(); ) {
            Element element = i.next();
            if (element.getName().equals("field")) {
              FieldEntity field = new FieldEntity();
              field.setFormId(form.getId());
              field.setName(element.attributeValue("name"));
              field.setTitle(element.attributeValue("title"));
              try {
                  field.setFieldType(FieldType.valueOf(element
                      .attributeValue("fieldType")));
              }
              catch (Exception e) {
                field.setFieldType(FieldType.TEXT);
              }
              field.setMandatory(XmlUtil.readBooleanAttr(element,
                  "mandatory", false));
              field.setValues(element.attributeValue("values"));
              field.setDefaultValue(element.attributeValue("defaultValue"));
              field.setHeight(XmlUtil.readIntAttr(element, "height", 0));
              field.setWidth(XmlUtil.readIntAttr(element, "width", 20));
              field.setIndex(XmlUtil.readIntAttr(element, "index", 0));
              getDaoTaskAdapter().fieldSave(field);
            }
    }   
  }
View Full Code Here

  public void fieldSave(FieldEntity entity) throws DaoTaskException {
    if (isSkip()) {
      if (entity.getId() == null) {
        FormEntity form = getDao().getFormDao().getById(
            entity.getFormId());
        FieldEntity found = getDao().getFieldDao().getByName(form,
            entity.getName());
        if (found == null) {
          throw new DaoTaskException("Field not found while "
            + "skipping save operation. " + entity.getName());
        }
        entity.setKey(found.getKey());
      }
    }
    else {
      getDao().getFieldDao().save(entity);
    }
View Full Code Here

public class FieldServiceImpl extends AbstractServiceImpl
    implements FieldService {

  @Override
  public ServiceResponse updateField(Map<String, String> fieldMap) {
    FieldEntity field = new FieldEntity();
    List<String> errors = getBusiness().getFieldBusiness().convertFromVO(
        field, fieldMap);
    if (errors.isEmpty()) {
      List<String> validateErrors = getBusiness().getFieldBusiness()
          .validateBeforeUpdate(field);
      if (validateErrors.isEmpty()) {
        boolean newField = field.getId() == null;
        getDao().getFieldDao().save(field);
        if (newField) {
          FormEntity form = getDao().getFormDao().getById(field.getFormId());
          getBusiness().getFieldBusiness().checkOrder(form);
        }
        return ServiceResponse.createSuccessResponse(
            Messages.get("form.field_success_update"));
      }
View Full Code Here

TOP

Related Classes of org.vosao.entity.FieldEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.