How to get complex type list document ref of complex type list custom in java?

Hi Guys!

I have the next code: Scheme:

<xs:element name="documentosRespuestaInterno" type="nxs:documentoRespuestaInternoListType"/>

<xs:complexType name="documentoRespuestaInternoListType">    
    <xs:sequence>        
        <xs:element name="item" type="nxs:documentoRespuestaInternoType" minOccurs="0" maxOccurs="unbounded"/>    
    </xs:sequence>
</xs:complexType>

<xs:complexType name="documentoRespuestaInternoType">    
    <xs:sequence>        
        <xs:element name="nombre" type="xs:string"/>        
        <xs:element name="docRespuestaInterno">            
            <xs:simpleType>                
                <xs:list>                    
                    <xs:simpleType>                        
                        <xs:restriction base="xs:string" ref:resolver="documentResolver" ref:store="id"/>                    
                    </xs:simpleType>                
                </xs:list>            
            </xs:simpleType>        
        </xs:element>    
    </xs:sequence>
</xs:complexType>

Java Class:

@OperationMethod(collector = DocumentModelCollector.class)
public DocumentModel run(DocumentRef docRef) throws Exception {    
DocumentModel doc = session.getDocument(docRef);    
    ArrayList<Map<String, Object>> referencias = (ArrayList<Map<String, Object>>)
    doc.getPropertyValue("doc_base:documentosRespuestaInterno");    
    for (Map<String, Object> referencia : referencias) {        
        String name = (String) referencia.get("nombre");        
        List<Document> docs = (List<Document>) referencia.get("docRespuestaInterno");        
        ArrayList<Map<String, Object>> docs1 = (ArrayList<Map<String, Object>>) referencia.get("docRespuestaInterno");
    DocumentModelList docs2 = (DocumentModelList) referencia.get("docRespuestaInterno");        
    List<DocumentModel> docs3 = (List<DocumentModel>) referencia.get("docRespuestaInterno");        
    log2.info("Referencia[1] : nombre = " + name + " docs = " + referencia.get("docRespuestaInterno"));        
    // PRINT CORRECT PROPERTY NOMBRE BUT docRespuestaInterno Wrong
    //Referencia[1] : nombre = revisor docs = [Ljava.lang.String;@72e86051        
    //Referencia[1] : nombre = gestor docs = [Ljava.lang.String;@78373eef    
}    
updateResponses(docRef);    
return doc;
}

When I try get value property for docRespuestaInterno (Type list of documentRefs) the program output Error in log similar (depend of case cast property):

Caused by: java.lang.ClassCastException: class [Ljava.lang.String; cannot be cast to class java.util.List ([Ljava.lang.String; and java.util.List are in module java.base of loader 'bootstrap')

Then, How to get correctly property for cast of `DocumentModel` ?

I need change de transition for all documents in the list

Example:

for (DocumentModel response : listDocuments) 
{    if (response.getCurrentLifeCycleState().equals("firmado")) 
    {        response.followTransition("to_tramitado");    
    }
}

Regards! Gabo.

0 votes

0 answers

972 views

ANSWER