deas / contentreich-alfresco-datalists

Datalist Extensions for Alfresco Share
16 stars 26 forks source link

The export to xls function doesn't work for custom datalist #31

Closed douglascrp closed 9 years ago

douglascrp commented 9 years ago

There is a condition in the OOTB code that avoids any custom namespace different from dl: to be exported. I think it will be needed to recover the original fme-extended-datalist's code from at https://code.google.com/p/fme-alfresco-extensions/source/browse/branches/pre-4.x/fme%20extended%20Datalist%20-%20Repository/src/java/de/fme/alfresco/repo/web/scripts/datalist/DataListDownloadWebScript.java

deas commented 9 years ago

I do not see that limitation in the ootb code.

In fact, I'd say that you should override the following bean to export whatever properties you want to see in the sheet.

    <!-- Download a datalist as Excel XLS / XLSX -->
    <bean id="webscript.org.alfresco.slingshot.datalists.list.get"
          class="org.alfresco.repo.web.scripts.datalist.DataListDownloadWebScript"
          parent="declarativeSpreadsheetWebScript">
        <property name="nodeService" ref="NodeService"/>
        <property name="siteService" ref="SiteService"/>
        <property name="namespaceService" ref="namespaceService"/>
        <property name="dictionaryService" ref="dictionaryService"/>
        <property name="modelOrder">
           <!-- These are taken from the forms config for now -->
           <map>
              <entry key="dl:todoList">
                <value>dl:todoTitle,dl:todoDueDate,dl:todoPriority,dl:todoStatus,dl:todoNotes,dl:assignee,dl:attachments</value>
              </entry>
              <entry key="dl:task">
                <value>cm:title,cm:description,dl:ganttStartDate,dl:ganttEndDate,dl:taskAssignee,dl:taskPriority,dl:taskStatus,dl:ganttPercentComplete,dl:taskComments,cm:attachments</value>
              </entry>
              <entry key="dl:simpletask">
                <value>cm:title,cm:description,dl:simpletaskDueDate,dl:simpletaskPriority,dl:simpletaskStatus,dl:simpletaskComments</value>
              </entry>
              <entry key="dl:contact">
                <value>dl:contactFirstName,dl:contactLastName,dl:contactEmail,dl:contactCompany,dl:contactJobTitle,dl:contactPhoneOffice,dl:contactPhoneMobile,dl:contactNotes</value>
              </entry>
              <entry key="dl:issue">
                <value>dl:issueID,cm:title,dl:issueAssignedTo,dl:issueStatus,dl:issuePriority,cm:description,dl:issueDueDate,dl:issueComments,cm:attachments</value>
              </entry>
              <entry key="dl:event">
                <value>cm:title,cm:description,dl:eventLocation,dl:eventStartDate,dl:eventEndDate,dl:eventRegistrations,cm:attachments,dl:eventNote</value>
              </entry>
              <entry key="dl:location">
                <value>cm:title,dl:locationAddress1,dl:locationAddress2,dl:locationAddress3,dl:locationZip,dl:locationState,dl:locationCountry,cm:description,cm:attachments</value>
              </entry>
              <entry key="dl:meetingAgenda">
                <value>dl:meetingAgendaRef,cm:title,cm:description,dl:meetingAgendaTime,dl:meetingAgendaOwner,cm:attachments</value>
              </entry>
              <entry key="dl:eventAgenda">
                <value>dl:eventAgendaRef,dl:eventAgendaStartTime,dl:eventAgendaEndTime,dl:eventAgendaSessionName,dl:eventAgendaPresenter,dl:eventAgendaAudience,cm:attachments,dl:eventAgendaNotes</value>
              </entry>
           </map>
        </property>
    </bean>
douglascrp commented 9 years ago

Well, at least on 4.2.f and 5.0.d, I found the code bellow inside root/projects/remote-api/source/java/org/alfresco/repo/web/scripts/datalist/DataListDownloadWebScript.java, line 248:

    private QName buildType(NodeRef list)
    {
       String typeS = (String)nodeService.getProperty(list, DATA_LIST_ITEM_TYPE);
       if(! typeS.startsWith(NamespaceService.DATALIST_MODEL_PREFIX + ":"))
       {
          throw new WebScriptException(Status.STATUS_NOT_IMPLEMENTED, "Unexpected list type " + typeS);
       }
       QName type = QName.createQName(NamespaceService.DATALIST_MODEL_1_0_URI, typeS.substring(typeS.indexOf(':')+1));
       return type;
    }

As my custom namespace is "lab:", it fais with the message "Unexpected list type lab:customDataListType"