Foros de discusión

Getting Document metadata (Document Type values) in DXP

Harsha Is Working, modificado hace 6 años.

Getting Document metadata (Document Type values) in DXP

New Member Mensajes: 14 Fecha de incorporación: 13/05/14 Mensajes recientes
Hi, I am working on Liferay DXP. I created a document type "My Documents" with field "Language" which is a selection dropdown with values "English", "French" and "Spanish". I uploaded a document and selected Language value as French. Now I am trying to get this Language value for the document but its returning blank. Below is the code I am using.

 DDMStructure ddmStructure = null;
    List<ddmstructure> structures = dLFileEntryType.getDDMStructures();
    mainloop:
    for (DDMStructure struct : structures) {
    	if (struct.getName((Locale.ROOT)).equalsIgnoreCase("My Documents")) {
    		ddmStructure = struct;
    		break mainloop;
    	}
    }
    
    DLFileEntryMetadata fileEntryMetadata = null;
    try {
    	fileEntryMetadata = DLFileEntryMetadataLocalServiceUtil.getFileEntryMetadata(ddmStructure.getStructureId(), dlFileEntry.getFileVersion().getFileVersionId());
    	if(Validator.isNotNull(fileEntryMetadata)) {
    		ServiceContext serviceContextDLFile = new ServiceContext();
    		serviceContextDLFile.setCompanyId(companyId);
    		serviceContextDLFile.setAttribute("fileEntryTypeId", fileEntryTypeId);
    		serviceContextDLFile.setAttribute("fileEntryMetadataId", fileEntryMetadata.getFileEntryMetadataId());
    		serviceContextDLFile.setAttribute("DDMStorageId", fileEntryMetadata.getDDMStorageId());
    		serviceContextDLFile.setAttribute("fileEntryId", fileEntryMetadata.getFileEntryId());
    		serviceContextDLFile.setAttribute("fileVersionId", fileEntryMetadata.getFileVersionId());

    		DDMFormValues ddmFormValues = StorageEngineManagerUtil.getDDMFormValues(fileEntryMetadata.getDDMStructureId(), null, serviceContextDLFile);
    		List<ddmformfieldvalue> ddmFormFieldValues =  ddmFormValues.getDDMFormFieldValues();
    		if(Validator.isNotNull(ddmFormFieldValues) &amp;&amp; !ddmFormFieldValues.isEmpty()) {
    			for(DDMFormFieldValue formfieldValue : ddmFormFieldValues) {
    				if(formfieldValue.getName().equalsIgnoreCase("Language")) {
    					String languageRawName = formfieldValue.getValue().getString(Locale.US);
    					String language = languageRawName.replace("[\"", "").replace("\"]", "");
    				}
    			}
    		}
    	}					
    } catch (NoSuchFileEntryMetadataException nsfene) {
    //	LOGGER.error("ERROR:: ", nsfene);
    } catch(PortalException portalException) {
    //	LOGGER.error("ERROR:: " , portalException);
    }
</ddmformfieldvalue></ddmstructure>

I have not given any predefined value for Language field while creating Document Type. When I am giving any predefined value for Language field, the above code is returning that predefined value.
Please tell if I am missing something or there is any other approach do achieve this.
thumbnail
Olaf Kock, modificado hace 6 años.

RE: Getting Document metadata (Document Type values) in DXP

Liferay Legend Mensajes: 6400 Fecha de incorporación: 23/09/08 Mensajes recientes
Harsha Is Working:
Please tell if I am missing something or there is any other approach do achieve this.


You missed linking your crossposts
Harsha Is Working, modificado hace 6 años.

RE: Getting Document metadata (Document Type values) in DXP

New Member Mensajes: 14 Fecha de incorporación: 13/05/14 Mensajes recientes
Olaf Kock:

You missed linking your crossposts


Yes, I realize the importance and apologize for that. I asked exactly the same question here . I did not get any answer which suited my requirement and hence this post.

Thanks,
Ashwini.