Package org.infoglue.cms.entities.management

Examples of org.infoglue.cms.entities.management.ContentTypeAttributeParameter


            org.dom4j.Element param = (org.dom4j.Element)childnlIterator.next();

            String paramId = param.attributeValue("id");
            String paramInputTypeId = param.attributeValue("inputTypeId");
                       
            ContentTypeAttributeParameter contentTypeAttributeParameter = new ContentTypeAttributeParameter();
            contentTypeAttributeParameter.setId(paramId);
            if(paramInputTypeId != null && paramInputTypeId.length() > 0)
              contentTypeAttributeParameter.setType(Integer.parseInt(paramInputTypeId));

            contentTypeAttribute.putContentTypeAttributeParameter(paramId, contentTypeAttributeParameter);
           
            existingParams.put(paramId, contentTypeAttributeParameter);

            if(paramId.equalsIgnoreCase("dataProviderClass"))
            {
              org.dom4j.Element valueElement = (org.dom4j.Element)param.selectSingleNode("values/value");
              dataProviderClass = valueElement.attributeValue("label");
            }
            else if(paramId.equalsIgnoreCase("dataProviderParameters"))
            {
              org.dom4j.Element valueElement = (org.dom4j.Element)param.selectSingleNode("values/value");
              dataProviderParameters = valueElement.attributeValue("label");
            }

            List valuesNodeList = param.elements("values");
            Iterator valuesNodeListIterator = valuesNodeList.iterator();
            while(valuesNodeListIterator.hasNext())
            {
              org.dom4j.Element vsnli = (org.dom4j.Element)valuesNodeListIterator.next();
             
              List valueNodeList = vsnli.elements("value");
              Iterator valueNodeListIterator = valueNodeList.iterator();
              while(valueNodeListIterator.hasNext())
              {
                org.dom4j.Element value = (org.dom4j.Element)valueNodeListIterator.next();

                String valueId = value.attributeValue("id");

                ContentTypeAttributeParameterValue contentTypeAttributeParameterValue = new ContentTypeAttributeParameterValue();
                contentTypeAttributeParameterValue.setId(valueId);

                List attributesList = value.attributes();
                Iterator attributesListIterator = attributesList.iterator();
                String optionName = null;
                String optionValue = null;
                while(attributesListIterator.hasNext())
                {
                  org.dom4j.Attribute attribute = (org.dom4j.Attribute)attributesListIterator.next();
                 
                  String valueAttributeName = attribute.getName();
                  String valueAttributeValue = attribute.getStringValue();
                                   
                  if(valueAttributeName.equals("label"))
                    optionName = valueAttributeValue;
                  if(valueAttributeName.equals("id"))
                    optionValue = valueAttributeValue;
                 
                  contentTypeAttributeParameterValue.addAttribute(valueAttributeName, valueAttributeValue);
                }
               
                if(paramInputTypeId.equals("1"))
                  contentTypeAttribute.getOptions().add(new ContentTypeAttributeOptionDefinition(optionName, optionValue));

                contentTypeAttributeParameter.addContentTypeAttributeParameterValue(valueId, contentTypeAttributeParameterValue);
              }
            }
          }
        }

        if(dataProviderClass != null && !dataProviderClass.equals(""))
        {
          try
          {
            PropertyOptionsDataProvider provider = (PropertyOptionsDataProvider)Class.forName(dataProviderClass).newInstance();
            Map parameters = httpHelper.toMap(dataProviderParameters, "UTF-8", ";");
            List<GenericOptionDefinition> options = provider.getOptions(parameters, languageCode, principal, db);
            contentTypeAttribute.getOptions().addAll(options);
          }
          catch (Exception e)
          {
            if(logger.isDebugEnabled())
              logger.error("Unable to fetch data from custom class [" + dataProviderClass + "]:" + e.getMessage(), e);
            else
              logger.error("Unable to fetch data from custom class [" + dataProviderClass + "]:" + e.getMessage());
          }
        }
       
        if((attributeType.equals("select") || attributeType.equals("radiobutton") || attributeType.equals("checkbox")) && !existingParams.containsKey("widget"))
        {
          ContentTypeAttributeParameter contentTypeAttributeParameter = new ContentTypeAttributeParameter();
          contentTypeAttributeParameter.setId("widget");
          contentTypeAttributeParameter.setType(0);
          contentTypeAttribute.putContentTypeAttributeParameter("widget", contentTypeAttributeParameter);

          ContentTypeAttributeParameterValue contentTypeAttributeParameterValue = new ContentTypeAttributeParameterValue();
          contentTypeAttributeParameterValue.setId("0");
          contentTypeAttributeParameterValue.addAttribute("id", "default");
          contentTypeAttributeParameterValue.addAttribute("label", "Default");
          contentTypeAttributeParameter.addContentTypeAttributeParameterValue("0", contentTypeAttributeParameterValue);
        }

        // End extra parameters
        attributes.add(contentTypeAttribute);
      }
     
      if(addPriorityAttribute)
      {
        ContentTypeAttribute contentTypeAttribute = new ContentTypeAttribute();
        contentTypeAttribute.setPosition(i);
        contentTypeAttribute.setName("PropertyPriority");
        contentTypeAttribute.setInputType("select");

        ContentTypeAttributeParameter contentTypeAttributeParameter = new ContentTypeAttributeParameter();
        contentTypeAttributeParameter.setId("title");
        contentTypeAttributeParameter.setType(0);
        contentTypeAttribute.putContentTypeAttributeParameter("title", contentTypeAttributeParameter);
        ContentTypeAttributeParameterValue contentTypeAttributeParameterValue = new ContentTypeAttributeParameterValue();
        contentTypeAttributeParameterValue.setId("title");
        contentTypeAttributeParameterValue.addAttribute("title", "PropertyPriority");
        contentTypeAttributeParameter.addContentTypeAttributeParameterValue("title", contentTypeAttributeParameterValue);

        contentTypeAttributeParameter = new ContentTypeAttributeParameter();
        contentTypeAttributeParameter.setId("description");
        contentTypeAttributeParameter.setType(0);
        contentTypeAttribute.putContentTypeAttributeParameter("description", contentTypeAttributeParameter);
        contentTypeAttributeParameterValue = new ContentTypeAttributeParameterValue();
        contentTypeAttributeParameterValue.setId("description");
        contentTypeAttributeParameterValue.addAttribute("description", "What prio should this have");
        contentTypeAttributeParameter.addContentTypeAttributeParameterValue("description", contentTypeAttributeParameterValue);

        contentTypeAttributeParameter = new ContentTypeAttributeParameter();
        contentTypeAttributeParameter.setId("initialData");
        contentTypeAttributeParameter.setType(0);
        contentTypeAttribute.putContentTypeAttributeParameter("initialData", contentTypeAttributeParameter);
        contentTypeAttributeParameterValue = new ContentTypeAttributeParameterValue();
        contentTypeAttributeParameterValue.setId("initialData");
        contentTypeAttributeParameterValue.addAttribute("initialData", "");
        contentTypeAttributeParameter.addContentTypeAttributeParameterValue("initialData", contentTypeAttributeParameterValue);

        contentTypeAttributeParameter = new ContentTypeAttributeParameter();
        contentTypeAttributeParameter.setId("class");
        contentTypeAttributeParameter.setType(0);
        contentTypeAttribute.putContentTypeAttributeParameter("class", contentTypeAttributeParameter);
        contentTypeAttributeParameterValue = new ContentTypeAttributeParameterValue();
        contentTypeAttributeParameterValue.setId("class");
        contentTypeAttributeParameterValue.addAttribute("class", "longtextfield");
        contentTypeAttributeParameter.addContentTypeAttributeParameterValue("class", contentTypeAttributeParameterValue);

        contentTypeAttributeParameter = new ContentTypeAttributeParameter();
        contentTypeAttributeParameter.setId("values");
        contentTypeAttributeParameter.setType(1);
        contentTypeAttribute.putContentTypeAttributeParameter("values", contentTypeAttributeParameter);

        contentTypeAttribute.getOptions().add(new ContentTypeAttributeOptionDefinition("Lowest", "1"));
        contentTypeAttribute.getOptions().add(new ContentTypeAttributeOptionDefinition("Low", "2"));
        contentTypeAttribute.getOptions().add(new ContentTypeAttributeOptionDefinition("Medium", "3"));
        contentTypeAttribute.getOptions().add(new ContentTypeAttributeOptionDefinition("High", "4"));
        contentTypeAttribute.getOptions().add(new ContentTypeAttributeOptionDefinition("Highest", "5"));

        contentTypeAttributeParameterValue = new ContentTypeAttributeParameterValue();
        contentTypeAttributeParameterValue.setId("1");
        contentTypeAttributeParameterValue.addAttribute("id", "1");
        contentTypeAttributeParameterValue.addAttribute("label", "Lowest");
        contentTypeAttributeParameter.addContentTypeAttributeParameterValue("1", contentTypeAttributeParameterValue);

        contentTypeAttributeParameterValue = new ContentTypeAttributeParameterValue();
        contentTypeAttributeParameterValue.setId("2");
        contentTypeAttributeParameterValue.addAttribute("id", "2");
        contentTypeAttributeParameterValue.addAttribute("label", "Low");
        contentTypeAttributeParameter.addContentTypeAttributeParameterValue("2", contentTypeAttributeParameterValue);

        contentTypeAttributeParameterValue = new ContentTypeAttributeParameterValue();
        contentTypeAttributeParameterValue.setId("3");
        contentTypeAttributeParameterValue.addAttribute("id", "3");
        contentTypeAttributeParameterValue.addAttribute("label", "Medium");
        contentTypeAttributeParameter.addContentTypeAttributeParameterValue("3", contentTypeAttributeParameterValue);

        contentTypeAttributeParameterValue = new ContentTypeAttributeParameterValue();
        contentTypeAttributeParameterValue.setId("4");
        contentTypeAttributeParameterValue.addAttribute("id", "4");
        contentTypeAttributeParameterValue.addAttribute("label", "High");
        contentTypeAttributeParameter.addContentTypeAttributeParameterValue("4", contentTypeAttributeParameterValue);

        contentTypeAttributeParameterValue = new ContentTypeAttributeParameterValue();
        contentTypeAttributeParameterValue.setId("5");
        contentTypeAttributeParameterValue.addAttribute("id", "5");
        contentTypeAttributeParameterValue.addAttribute("label", "Highest");
        contentTypeAttributeParameter.addContentTypeAttributeParameterValue("5", contentTypeAttributeParameterValue);
        // End extra parameters

        attributes.add(contentTypeAttribute);
      }
    }
View Full Code Here


    Locale currentLocale = pc.getLocale();
    ContentTypeAttribute attr = getContentTypeDefinitionAttribute(ctd, attributeName);

    if (attr != null)
    {
      ContentTypeAttributeParameter valuesParameter =
      // This method actually gets a ContentTypeAttributeParameter
      attr.getContentTypeAttribute(CTD_VALUES_KEY);
     
      if (valuesParameter != null)
      {
        ContentTypeAttributeParameterValue value = valuesParameter.getContentTypeAttributeParameterValue(attributeValueName);
        if (value != null)
        {
          return value.getLocalizedValue(CTD_LABEL_KEY, currentLocale);
        }
      }
View Full Code Here

          {
            Element param = (Element)childnl.item(ci);
            String paramId = param.getAttribute("id");
            String paramInputTypeId = param.getAttribute("inputTypeId");
             
            ContentTypeAttributeParameter contentTypeAttributeParameter = new ContentTypeAttributeParameter();
            contentTypeAttributeParameter.setId(paramId);
            if(paramInputTypeId != null && paramInputTypeId.length() > 0)
              contentTypeAttributeParameter.setType(Integer.parseInt(paramInputTypeId));
         
            contentTypeAttribute.putContentTypeAttributeParameter(paramId, contentTypeAttributeParameter);
             
            NodeList valuesNodeList = param.getElementsByTagName("values");
            for(int vsnli=0; vsnli < valuesNodeList.getLength(); vsnli++)
            {
              Element values = (Element)valuesNodeList.item(vsnli);
 
              NodeList valueNodeList = param.getElementsByTagName("value");
              for(int vnli=0; vnli < valueNodeList.getLength(); vnli++)
              {
                Element value = (Element)valueNodeList.item(vnli);
                String valueId = value.getAttribute("id");
                 
                ContentTypeAttributeParameterValue contentTypeAttributeParameterValue = new ContentTypeAttributeParameterValue();
                contentTypeAttributeParameterValue.setId(valueId);
                 
                NamedNodeMap nodeMap = value.getAttributes();
                for(int nmi =0; nmi < nodeMap.getLength(); nmi++)
                {
                  Node attribute = (Node)nodeMap.item(nmi);
                  String valueAttributeName = attribute.getNodeName();
                  String valueAttributeValue = attribute.getNodeValue();
                  contentTypeAttributeParameterValue.addAttribute(valueAttributeName, valueAttributeValue);
                }
                 
                contentTypeAttributeParameter.addContentTypeAttributeParameterValue(valueId, contentTypeAttributeParameterValue);
              }
            }               
          }
        }
        // End extra parameters
View Full Code Here

TOP

Related Classes of org.infoglue.cms.entities.management.ContentTypeAttributeParameter

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.