cancel
Showing results for 
Search instead for 
Did you mean: 

Get custom model properties

mjuarez
Champ in-the-making
Champ in-the-making
Hi, i need get the properties of my model "factura".

i have this:

for (NamedValue prop : props) {

            if (prop.getName().endsWith(Constants.PROP_NAME) == true) {
               document.setName(prop.getValue());
            }
            if (prop.getName().endsWith(Constants.PROP_TITLE) == true) {
               document.setTitle(prop.getValue());
            }
            if (prop.getName().endsWith(Constants.PROP_DESCRIPTION) == true) {
               document.setDescription(prop.getValue());
            }   
            if (!prop.getName()
                  .startsWith("{http://www.alfresco.org/model")) {
               String contentString = prop.getName();
               String[] values = contentString.split("[}]");
               attributeList.put(values[1], prop.getValue());
            }
         }

My model is this:


<?xml version="1.0" encoding="UTF-8"?>

<!–  Modelo personalizado –>

<!– Note: This model is pre-configured to load at startup of the Repository.  So, all custom –>
<!–       types and aspects added here will automatically be registered –>

<model name="fact:ModeloPersonalizado" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– Optional meta-data about the model –>
   <description>Modelo personalizado</description>
   <author>mgomarg</author>
   <version>1.0</version>

   <imports>
      <!– Import Alfresco Dictionary Definitions –>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <!– Import Alfresco Content Domain Model Definitions –>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>

   <!– Registramos el Nuevo namespaces que se utilizara en este modelo –>
   <!– NOTE: The following namespace custom.model should be changed to reflect your own namespace –>
   <namespaces>
      <namespace uri="modelo.miniguia" prefix="fact"/>
   </namespaces>

   <types>
      <!– Definicion de los tipos de contenido personalizados –>
      <!– Definicion del tipo de contenido fact:factura –>
      <type name="fact:factura">
         <title>Factura</title>
         <parent>cm:content</parent>
         <properties>
           
            <property name="fact:Concepto">
               <title>Concepto</title>
               <type>d:text</type>
            </property>
      
            <property name="fact:Importe">
               <title>Importe</title>
               <type>d:float</type>
            </property>

            <property name="fact:Proveedor">
               <title>Proveedor</title>
               <type>d:text</type>
            </property>
           
            <property name="fact:NumFac">
               <title>Numero de factura</title>
               <type>d:int</type>
            </property>

            <property name="fact:FecFac">
               <title>Fecha de la factura</title>
               <type>d:date</type>
            </property>

         </properties>

       </type>

   </types>  
  
</model>

i can get the values, but don't can get the name of properties, only get the sufix of this. For example: i can get "FecFac", when i need get "Fecha de la factura".

Understand?? Please help!!!


Goodbye, i`m from Argentina, sorry by my english, is bad…
1 REPLY 1

mjuarez
Champ in-the-making
Champ in-the-making
Now, i can get the title and the data type of properties… For example:

DataType = {http://www.alfresco.org/model/dictionary/1.0}date
Title = Fecha de la Factura

I get this attributes of this way:

DictionaryServiceSoapBindingStub dssbs = WebServiceFactory
            .getDictionaryService();         
      PropertyDefinition[] propDefs = dssbs.getProperties(new String[] {
            "fact:FecFac" });
      int j = 0;
      while (j < propDefs.length) {
         System.out.println("DataType = " + propDefs[j].getDataType());
         System.out.println("Title = " + propDefs[j].getTitle());
         j++;
      }

But, i need get the properties dynamically for PropertyDefinition. I can define this properties with NamespaceUri in instead of prefix??