Package com.dotmarketing.portlets.structure.model

Examples of com.dotmarketing.portlets.structure.model.Field


  public void createBaseWidgetFields(Structure structurethrows DotDataException,DotStateException {
    if(!InodeUtils.isSet(structure.getInode())){
      throw new DotStateException("Cannot create base widget feilds on a structure that doesn't exist");
    }
    Field preExecute = new Field(WIDGET_PRE_EXECUTE_FIELD_NAME,Field.FieldType.HIDDEN,Field.DataType.TEXT,structure,false,false,false,4,"", "", "", true, true, true);
    preExecute.setFieldContentlet(FieldAPI.ELEMENT_CONSTANT);
    Field codeField = new Field(WIDGET_CODE_FIELD_NAME,Field.FieldType.HIDDEN,Field.DataType.TEXT,structure,false,false,false,3,"", "", "", true, true, true);
    codeField.setFieldContentlet(FieldAPI.ELEMENT_CONSTANT);
    Field usageField = new Field(WIDGET_USAGE_FIELD_NAME,Field.FieldType.TEXT_AREA,Field.DataType.TEXT,structure,false,false,false,2,"", "", "", true, true, true);
    usageField.setFieldContentlet(FieldAPI.ELEMENT_CONSTANT);
    Field titleField = new Field(WIDGET_TITLE_FIELD_NAME,Field.FieldType.TEXT,Field.DataType.TEXT,structure,true,true,true,1,"", "", "", true, false, true);
    FieldFactory.saveField(preExecute);
    FieldFactory.saveField(codeField);
    FieldFactory.saveField(usageField);
    FieldFactory.saveField(titleField);
    FieldsCache.clearCache();
View Full Code Here


   * @param respectFrontEndRoles
   * @return String
   */
  public String getFieldVariableValue(String structureVarName, String fieldVarName, String fieldVariable){
    Structure st = StructureCache.getStructureByVelocityVarName(structureVarName);
    Field field = findFieldByVarName(st, fieldVarName);       
    return getFieldVariableValue(field,fieldVariable);
  }
View Full Code Here

  }

  public void deleteFieldVariable(FieldVariable fieldVar, User user,
      boolean respectFrontendRoles) throws DotDataException,
      DotSecurityException {
    Field field = APILocator.getFieldAPI().find(fieldVar.getFieldId(), APILocator.getUserAPI().getSystemUser(), true);
    FieldFactory.deleteFieldVariable(fieldVar);
    FieldsCache.removeFieldVariables(field);
  }
View Full Code Here

        // delete Forms entry if it is a form structure
        if (st.getStructureType() == Structure.STRUCTURE_TYPE_FORM) {
            Structure sf = StructureCache.getStructureByVelocityVarName(
                    FormAPI.FORM_WIDGET_STRUCTURE_NAME_VELOCITY_VAR_NAME);
            if (UtilMethods.isSet(sf) && UtilMethods.isSet(sf.getInode())) {
                Field field = st.getFieldVar(FormAPI.FORM_WIDGET_FORM_ID_FIELD_VELOCITY_VAR_NAME);
                conAPI.delete( conAPI.search(
                        "+structureInode:" + sf.getInode() +
                        " +structureInode:" + st.getInode(), 0, 0,
                        "", user, false), user, false);
            }
View Full Code Here

  }

  //### DELETE ###
  public static void deleteField(String inode) throws DotHibernateException
  {
    Field field = getFieldByInode(inode);
    deleteField(field);
  }
View Full Code Here

        int lastDataTypeIdx = 0;
        for (int i=1;i<=25;i++) {
          boolean found = false;
          Iterator fieldsIter = fields.iterator();
          while (fieldsIter.hasNext() && !found) {
            Field nextField = (Field) fieldsIter.next();
            try {
              lastDataTypeIdx =Integer.parseInt(nextField.getFieldContentlet().replace(dataType,""));
              if (i == lastDataTypeIdx) {
                //found this field, break and try to find the next one
                found = true;
              }
            }
View Full Code Here

  }

  public static void saveFieldVariable(FieldVariable fieldVar){

    String id = fieldVar.getId();
    Field proxy = new Field();
    proxy.setInode(fieldVar.getFieldId());


    if(InodeUtils.isSet(id)) {
      try {
        HibernateUtil.update(fieldVar);
      } catch (DotHibernateException e) {
        Logger.error(FieldFactory.class, e.getMessage());
      }
    }else{
      try {
        HibernateUtil.save(fieldVar);
      } catch (DotHibernateException e) {
        Logger.error(FieldFactory.class, e.getMessage());
      }
    }
    FieldsCache.removeField(proxy);
    FieldsCache.removeFieldVariables(proxy);

    Field f = getFieldByInode(fieldVar.getFieldId());
    f.setModDate(new Date());
    try {
      saveField(f);
    } catch (DotHibernateException e) {
      Logger.error(FieldFactory.class, e.getMessage());
    }
View Full Code Here

        }
        if(folder!=null){
          java.io.File binFile = null;
          try {
            Structure faStructure = StructureCache.getStructureByInode(folder.getDefaultFileType());
            Field fieldVar = faStructure.getFieldVar(FileAssetAPI.BINARY_FIELD);
            java.io.File assetFile = APILocator.getFileAPI().getAssetIOFile(file);
            if(assetFile!=null && assetFile.exists()){
              java.io.File tempUserFolder = new java.io.File(APILocator.getFileAPI().getRealAssetPathTmpBinary() + java.io.File.separator + APILocator.getUserAPI().getSystemUser().getUserId() +
                  java.io.File.separator + fieldVar.getFieldContentlet());
              if (!tempUserFolder.exists())
                tempUserFolder.mkdirs();

              binFile = new java.io.File(tempUserFolder.getAbsolutePath() + java.io.File.separator + file.getFileName());
              if(binFile.exists())
View Full Code Here

    return result;
  }

  public static List<FieldVariable> getFieldVariablesForField (String fieldId ){

    Field proxy = new Field();
    proxy.setInode(fieldId);
    return getFieldVariablesForField(proxy);
  }
View Full Code Here

     */
    if ((cmd != null) && cmd.equals(Constants.ADD)) {
      try {
        Logger.debug(this, "Calling Add/Edit Method");

        Field field = (Field) req.getAttribute(WebKeys.Field.FIELD);
        if (InodeUtils.isSet(field.getInode())) {
          if (field.isFixed()
              || (field.getFieldType().equals(Field.FieldType.LINE_DIVIDER.toString())
                  || field.getFieldType().equals(Field.FieldType.TAB_DIVIDER.toString())
                  || field.getFieldType().equals(Field.FieldType.CATEGORIES_TAB.toString())
                  || field.getFieldType().equals(Field.FieldType.PERMISSIONS_TAB.toString())
                  || field.getFieldType().equals(Field.FieldType.RELATIONSHIPS_TAB.toString())
                  || field.getFieldContentlet().equals(FieldAPI.ELEMENT_CONSTANT) || field
                  .getFieldType().equals(Field.FieldType.HIDDEN.toString()))) {
            FieldForm fieldForm = (FieldForm) form;
            field.setFieldName(fieldForm.getFieldName());

            // This is what you can change on a fixed field
            if (field.isFixed()) {
              field.setHint(fieldForm.getHint());
              field.setDefaultValue(fieldForm.getDefaultValue());
              field.setSearchable(fieldForm.isSearchable());
              field.setListed(fieldForm.isListed());
              // field.setFieldName(fieldForm.getFieldName());
            }

            Structure structure = StructureCache.getStructureByInode(field.getStructureInode());

            if (((structure.getStructureType() == Structure.STRUCTURE_TYPE_CONTENT) && !fAPI
                .isElementConstant(field))
                || ((structure.getStructureType() == Structure.STRUCTURE_TYPE_WIDGET) && fAPI
                    .isElementConstant(field))
                || ((structure.getStructureType() == Structure.STRUCTURE_TYPE_FILEASSET) && fAPI
                    .isElementConstant(field))
                || ((structure.getStructureType() == Structure.STRUCTURE_TYPE_FORM) && fAPI
                    .isElementConstant(field))) {
              field.setValues(fieldForm.getValues());
            }
            BeanUtils.copyProperties(fieldForm, field);
          }
        }
        if (Validator.validate(req, form, mapping)) {
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.structure.model.Field

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.