Package org.vosao.entity

Examples of org.vosao.entity.FieldEntity$Option


    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

    return FieldVO.create(result);
  }

  @Override
  public FieldVO getById(Long fieldId) {
    FieldEntity field = getDao().getFieldDao().getById(fieldId);
    if (field != null) {
      return new FieldVO(field);
    }
    return null;
  }
View Full Code Here

  }

  @Override
  public ServiceResponse remove(List<String> ids) {
    if (ids.size() > 0) {
      FieldEntity field = null;
      FormEntity form = null;
      for (String id : ids) {
        field = getDao().getFieldDao().getById(Long.valueOf(id));
        if (field != null) {
          form = getDao().getFormDao().getById(field.getFormId());
          break;
        }
      }
      if (form == null) {
        return ServiceResponse.createErrorResponse("not_found");
View Full Code Here

    }   
  }
 
  private int indexOf(List<FieldEntity> fields, final Long fieldId) {
    for (int i = 0; i < fields.size(); i++) {
      FieldEntity field = fields.get(i);
      if (field.getId().equals(fieldId)) {
        return i;
      }
    }
    return -1;
  }
View Full Code Here

TOP

Related Classes of org.vosao.entity.FieldEntity$Option

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.