Package com.dotmarketing.portlets.structure.model

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


        //Getting the fields for this structure
        Collection<Field> fields = FieldsCache.getFieldsByStructureInode( structure.getInode() );

        Iterator<Field> iterator = fields.iterator();
        Field field = iterator.next();

        //Verify we found an stored field
        Field foundField = FieldFactory.getFieldByInode( field.getInode() );
        assertNotNull( foundField );
    }
View Full Code Here


        //Validations
        assertTrue( fields != null && !fields.isEmpty() );

        Iterator<Field> iterator = fields.iterator();
        Field field = iterator.next();

        //Search by the field contentlet
        //TODO: The data type is used everywhere instead the field.getFieldContentlet() as the method name, parameter and even te query suggested...
        Collection<Field> fieldsByContentlet = FieldFactory.getFieldsByContentletField( Field.DataType.TEXT.toString(), field.getInode(), structure.getInode() );

        //Validations
        assertTrue( fieldsByContentlet != null && !fieldsByContentlet.isEmpty() );

        //Search by the field contentlet and with an Inode null
View Full Code Here

        //Validations
        assertTrue( fields != null && !fields.isEmpty() );

        Iterator<Field> iterator = fields.iterator();
        Field field = iterator.next();

        //Search by variable name
        Field foundField = FieldFactory.getFieldByVariableName( structure.getInode(), field.getVelocityVarName() );

        //Start with the validations
        assertNotNull( foundField );
        assertEquals( foundField.getInode(), field.getInode() );
    }
View Full Code Here

        //Validations
        assertTrue( fields != null && !fields.isEmpty() );

        Iterator<Field> iterator = fields.iterator();
        Field field = iterator.next();

        //Search by field name
        Field foundField = FieldFactory.getFieldByStructure( structure.getInode(), field.getFieldName() );

        //Start with the validations
        assertNotNull( foundField );
        assertEquals( foundField.getInode(), field.getInode() );
    }
View Full Code Here

        //Validations
        assertTrue( fields != null && !fields.isEmpty() );

        Iterator<Field> iterator = fields.iterator();
        Field field = iterator.next();

        //Search by field name
        //Field foundField = FieldFactory.getFieldByName( structure.getInode(), field.getFieldName() );
        //TODO: The definition of the method getFieldByName receive a parameter named "String:structureType", some examples I saw send the Inode, but actually what it needs is the structure name....
        Field foundField = FieldFactory.getFieldByName( structure.getName(), field.getFieldName() );

        //Start with the validations
        assertNotNull( foundField );
        assertEquals( foundField.getInode(), field.getInode() );
    }
View Full Code Here

        //Getting a known structure
        Structure structure = structures.iterator().next();

        //Creating a field
        Field field = new Field( NAME_ORIGINAL, Field.FieldType.TEXT, Field.DataType.TEXT, structure, false, true, false, 1, false, false, false );
        Field field2 = new Field( NAME_ORIGINAL + "_2", Field.FieldType.TEXT, Field.DataType.TEXT, structure, false, true, false, 1, false, false, false );

        //++++++++++++++++++++++++++++++++++++++++++++
        //Testing the save
        FieldFactory.saveField( field );
        FieldFactory.saveField( field2 );

        //Validations
        assertNotNull( field.getInode() );

        //++++++++++++++++++++++++++++++++++++++++++++
        //Updating the field
        field.setFieldName( NAME_UPDATED );
        FieldFactory.saveField( field );

        //Getting the field we just updated
        Field foundField = FieldFactory.getFieldByInode( field.getInode() );

        //Validations
        assertEquals( field.getInode(), foundField.getInode() );
        assertEquals( field.getFieldName(), foundField.getFieldName() );

        //++++++++++++++++++++++++++++++++++++++++++++
        //Testing one of the deletes
        FieldFactory.deleteField( field );

        //Trying to get the field we just deleted
        Field deletedField = FieldFactory.getFieldByInode( foundField.getInode() );

        //Validations
        assertTrue( deletedField.getInode() == null || deletedField.getInode().isEmpty() );

        //++++++++++++++++++++++++++++++++++++++++++++
        //Testing another delete
        String field2Inode = field2.getInode();
        FieldFactory.deleteField( field2 );

        //Trying to get the field we just deleted
        deletedField = FieldFactory.getFieldByInode( field2Inode );

        //Validations
        assertTrue( deletedField.getInode() == null || deletedField.getInode().isEmpty() );
    }
View Full Code Here

        //Validations
        assertTrue( fields != null && !fields.isEmpty() );

        Iterator<Field> iterator = fields.iterator();
        Field field = iterator.next();

        //FIXME: Work more on this test, verify when the max ammount of fields is reach....
        //Find the next available field number
        String fieldContentlet = FieldFactory.getNextAvaliableFieldNumber( Field.DataType.TEXT.toString(), field.getInode(), field.getStructureInode() );

        //Validations
        assertTrue( fieldContentlet != null && !fieldContentlet.isEmpty() );
    }
View Full Code Here

        //Validations
        assertTrue( fields != null && !fields.isEmpty() );

        Iterator<Field> iterator = fields.iterator();
        Field field = iterator.next();

        //Creating the FieldVariables
        FieldVariable fieldVariable = new FieldVariable();
        fieldVariable.setFieldId( field.getInode() );
        fieldVariable.setName( NAME_ORIGINAL );
        fieldVariable.setKey( "test_variable_key" );
        fieldVariable.setValue( "test variable value" );
        fieldVariable.setLastModifierId( user.getUserId() );
        fieldVariable.setLastModDate( new Date() );

        FieldVariable fieldVariable2 = new FieldVariable();
        fieldVariable2.setFieldId( field.getInode() );
        fieldVariable2.setName( NAME_ORIGINAL + "_2" );
        fieldVariable2.setKey( "test_variable_key_2" );
        fieldVariable2.setValue( "test variable value_2" );
        fieldVariable2.setLastModifierId( user.getUserId() );
        fieldVariable2.setLastModDate( new Date() );

        //++++++++++++++++++++++++++++++++++++++++++++
        //Saving the field variable
        FieldFactory.saveFieldVariable( fieldVariable );

        //Validations
        assertNotNull( fieldVariable.getId() );

        //++++++++++++++++++++++++++++++++++++++++++++
        //Getting the variable we just saved
        FieldVariable savedVariable = FieldFactory.getFieldVariable( fieldVariable.getId() );

        //Validations
        assertEquals( fieldVariable.getId(), savedVariable.getId() );

        //++++++++++++++++++++++++++++++++++++++++++++
        //Updating the field variable
        savedVariable.setName( NAME_UPDATED );
        FieldFactory.saveFieldVariable( fieldVariable );

        //Getting again the saved variable
        fieldVariable = FieldFactory.getFieldVariable( fieldVariable.getId() );

        //Validations
        assertNotNull( fieldVariable.getId() );
        assertEquals( fieldVariable.getName(), NAME_UPDATED );

        //++++++++++++++++++++++++++++++++++++++++++++
        //Getting all the variables for a given field
        Collection<FieldVariable> variables = FieldFactory.getFieldVariablesForField( field.getInode() );

        //Validations
        assertTrue( variables != null && !variables.isEmpty() );

        //++++++++++++++++++++++++++++++++++++++++++++
View Full Code Here

    cache.put(getPrimaryGroup() + inode, f, getPrimaryGroup());       
  }
   
  public static Field getField(String id) {
    DotCacheAdministrator cache = CacheLocator.getCacheAdministrator();
      Field field = null;
      try{
        field = (Field) cache.get(getPrimaryGroup() + id, getPrimaryGroup());
      }catch (DotCacheException e) {
      Logger.debug(FieldsCache.class, "Cache Entry not found", e);
    }
View Full Code Here

      upgradeStructureFields();
     
    Structure structure = StructureFactory.getStructureByVelocityVarName("Host");
    String structureInode = structure.getInode();
   
    Field field = new Field();
    field.setFieldName("Tag Storage");
        field.setStructureInode(structureInode);
        field.setFieldType(Field.FieldType.CUSTOM_FIELD.toString());
        field.setUnique(false);
        field.setFixed(true);
        field.setReadOnly(false);
        field.setIndexed(true);
        field.setReadOnly(false);
   
   
    List<Field> fields = FieldsCache.getFieldsByStructureInode(structure.getInode());
    int sortOrder = 0;
    boolean alreadyExists = false;
   
    for (Field f : fields) {
     
      if (f.getFieldType().equalsIgnoreCase(field.getFieldType())
          && f.getFieldType().equalsIgnoreCase(Field.FieldType.HOST_OR_FOLDER.toString())) {
        Logger.debug(this, "The field already exist on structure.");
        alreadyExists = true;
       
      }
      if (f.getVelocityVarName().equals("hostThumbnail"))
        sortOrder = f.getSortOrder() - 1;
    }
    if(!alreadyExists){
        field.setSortOrder(sortOrder);
       
      String fieldVelocityName = VelocityUtil.convertToVelocityVariable(field.getFieldName(), false);
      int found = 0;
      if (VelocityUtil.isNotAllowedVelocityVariableName(fieldVelocityName)) {
        found++;
      }

      String velvar;
      for (Field f : fields) {
        velvar = f.getVelocityVarName();
        if (velvar != null) {
          if (fieldVelocityName.equals(velvar)) {
            found++;
          } else if (velvar.contains(fieldVelocityName)) {
            String number = velvar.substring(fieldVelocityName.length());
            if (RegEX.contains(number, "^[0-9]+$")) {
              found++;
            }
          }
        }
      }
      if (found > 0) {
        fieldVelocityName = fieldVelocityName + Integer.toString(found);
      }
     
      if(!validateInternalFieldVelocityVarName(fieldVelocityName)){
        fieldVelocityName+="1";
      }
     
      field.setVelocityVarName(fieldVelocityName);
   
      field.setValues("#parse('static/tag/tag_storage_field_creation.vtl')");
     
      String fieldContentlet = FieldFactory.getNextAvaliableFieldNumber(Field.DataType.TEXT.toString(), field.getInode(), field
          .getStructureInode());
      if (fieldContentlet == null) {
        // didn't find any empty ones, so im throwing an error
        // to the user to select a new one
      }
      field.setFieldContentlet(fieldContentlet);
     
      FieldFactory.saveField(field);

      FieldsCache.removeFields(structure);
      StructureCache.removeStructure(structure);
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.