Fórumok

How To Add Custom Metadata To View As Another Column On Documents And Media

Jonathan Mattox, módosítva 10 év-val korábban

How To Add Custom Metadata To View As Another Column On Documents And Media

New Member Bejegyzések: 13 Csatlakozás dátuma: 2013.11.05. Legújabb bejegyzések
Hello, I am trying to pull values from a custom metadata set and display it as an additional column on the view/gridview along with Title, Size, Created Date. And I am having a hard time figuring out exactly what to do in my hook. I see bits and pieces of code all over the place, but I'm not sure exactly how to extend the classes to add this. I've been able to add a column to be seen on the gridview by adding an entry to the init.jsp file by adding the following around line number 151:

Before:
String defaultEntryColumns = "name,size";

After:
String defaultEntryColumns = "name,size,myNewColumn";

Then I found where you add a condition for it in view_entries.jsp, but when I output fileEntryTypeId in this if statement, I keep getting a "-1"

if (columnName.equals("myNewColumn")) {
//Logic code here
}

Also in view_entries.jsp I see the following code which gets the fileEntryTypeId, which is one of the keys I need to tap into getting the metadata since the DLFileEntry doesn't have a property for this, but I'm not sure how to tap into this to get what I need and post in in the view/gridview:

List results = null;
//List metaDataresults = null;
int total = 0;

if (fileEntryTypeId >= 0) {
Indexer indexer = IndexerRegistryUtil.getIndexer(DLFileEntryConstants.getClassName());

if (fileEntryTypeId > 0) {
DLFileEntryType dlFileEntryType = DLFileEntryTypeLocalServiceUtil.getFileEntryType(fileEntryTypeId);

dlFileEntryTypeName = dlFileEntryType.getName();
}

Also, in edit_file_entry, I see the following code which looks like it pertains, but I don't understand how to use it (starting at line 334):

<%
if (fileEntryTypeId > 0) {
try {
List<DDMStructure> ddmStructures = dlFileEntryType.getDDMStructures();

for (DDMStructure ddmStructure : ddmStructures) {
Fields fields = null;

try {
DLFileEntryMetadata fileEntryMetadata = DLFileEntryMetadataLocalServiceUtil.getFileEntryMetadata(ddmStructure.getStructureId(), fileVersionId);

fields = StorageEngineUtil.getFields(fileEntryMetadata.getDDMStorageId());
}
catch (Exception e) {
}
%>

<%= DDMXSDUtil.getHTML(pageContext, ddmStructure.getXsd(), fields, String.valueOf(ddmStructure.getPrimaryKey()), locale) %>

I also see that the table "DDMContent" gets populated with two rows when you add a document that has metadata fields. One row is for the automatically extracted data, and the other has the custom data from my custom metadata set.

I am trying to implement the following class solutions:

public class MyDLAppLocalService implements DLAppLocalService {}

and

public class MyDLFileEntryMetadataLocalService implements
DLFileEntryMetadataLocalService {}

and

public class MyDLAppLocalServiceImpl extends DLAppLocalServiceWrapper {

public MyDLAppLocalServiceImpl(DLAppLocalService dlAppLocalService) {
super(dlAppLocalService);
// TODO Auto-generated constructor stub
}
}

and

public MyDLAppLocalServiceWrapper(FileEntry fileEntry){
super((DLAppService) fileEntry);
}
}
Here is my liferay-hook.xml:

<?xml version="1.0"?>
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.1.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_1_0.dtd">

<hook>
<custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir>
<service>
<service-type>com.liferay.portlet.documentlibrary.service.DLAppLocalService</service-type>
<service-impl>com.liferay.sample.hook.MyDLAppLocalServiceImpl</service-impl>
</service>
</hook>


I find all this stuff very confusing. I don't know what to do to which class and where. I see a lot of tutorials about modifying the User's classes, but not much about this and what posts I do find, they only give a tiny snippet of code. I have no idea where that snippet came from (which file and where in that file). I'm trying to figure out all this java and liferay stuff. I've been to the liferay training classes and I'm working through the books, along with Liferay In Action. I just don't see a very clear explanation from start to finish of how to do something like this can anyone please help me?

Thanks in advance emoticon
thumbnail
Ankit Kulshrestha, módosítva 10 év-val korábban

RE: How To Add Custom Metadata To View As Another Column On Documents And M

Junior Member Bejegyzések: 28 Csatlakozás dátuma: 2013.05.22. Legújabb bejegyzések
Hi Jon,

I think your problem can be solved if you try to use Custom Field/Attribute feature which helps storing additional data for entities like Documents, Blogs, Roles etc.

You can follow the URL below to understand the concept and then make corresponding changes to the code.

https://www.liferay.com/documentation/liferay-portal/6.1/user-guide/-/ai/lp-6-1-ugen12-custom-fields-0

Thanks,
Ankit Kulshrestha
Senior Consultant,
Dunn Solutions Group.
Jonathan Mattox, módosítva 10 év-val korábban

RE: How To Add Custom Metadata To View As Another Column On Documents And M

New Member Bejegyzések: 13 Csatlakozás dátuma: 2013.11.05. Legújabb bejegyzések
Thanks, but I can't use that because we have many different organizations and organizational sites and each one has to have it's own custom metadata. The values for custom fields persist across the entire portal.

I am trying to extract fields("Data-Type" and "Unit") from my custom metadata set and display it as as a data column along side "Title, Size, Created Date, Modified Date....ect" on the Documents and Media Portlet. I was able to add these two columns and be able to put the data that is in the other columns(for example I am able to put the data that is under the "Size" column under the "Data-Type" and "Unit" columns or I am able to hard-code values (see attached screenshot), but I have be unsuccessful in pulling the fields from the metadata set for these columns.But I don't understand how to make it work. Also, both of my custom metadata fields are selection lists. Can you please explain to me exactly how to do this. I am having a reeeeeeeeeeeeeeeeeeeeeeeeeally hard time understanding how to do this.

Thanks in advance
Sandro Casali, módosítva 9 év-val korábban

RE: How To Add Custom Metadata To View As Another Column On Documents And M

New Member Bejegyzés: 1 Csatlakozás dátuma: 2015.01.29. Legújabb bejegyzések
I have implemented a change to document_library portlet that allows you to add custom metadata in any list view allowing you to use it for sorting.

I attach the file containing the patch for version 6.2-ce-GA3 Liferay
thumbnail
Marco Azzalini, módosítva 8 év-val korábban

RE: How To Add Custom Metadata To View As Another Column On Documents And M

Regular Member Bejegyzések: 146 Csatlakozás dátuma: 2014.11.18. Legújabb bejegyzések
Sandro Casali:
I have implemented a change to document_library portlet that allows you to add custom metadata in any list view allowing you to use it for sorting.

I attach the file containing the patch for version 6.2-ce-GA3 Liferay


Hi Sandro, I'd like to thank you for your fantastic patch! It works like a charm and it saved me a least a couple of days of work.
It should really be included in the Liferay official sources tree (!)

Regards,
Marco
Marwen Rezgui, módosítva 7 év-val korábban

RE: How To Add Custom Metadata To View As Another Column On Documents And M

New Member Bejegyzések: 9 Csatlakozás dátuma: 2015.02.12. Legújabb bejegyzések
Marco Azzalini:
Sandro Casali:
I have implemented a change to document_library portlet that allows you to add custom metadata in any list view allowing you to use it for sorting.

I attach the file containing the patch for version 6.2-ce-GA3 Liferay


Hi Sandro, I'd like to thank you for your fantastic patch! It works like a charm and it saved me a least a couple of days of work.
It should really be included in the Liferay official sources tree (!)

Regards,
Marco


Hi,
please i want to add column(modified-date) in document and media display. this column exist in Portlet Dosument and media but not exist in Document and media display. what can i do???
Thanks in advance