cancel
Showing results for 
Search instead for 
Did you mean: 

Custom-metadata

rise_mini
Champ in-the-making
Champ in-the-making
Hi,
I have added some custom fields in MS-Word doc and try to upload that file into Alfresco using 'add content' wizard.
I have created custom model and follow the steps that are given in  http://ecmarchitect.com/images/articles/alfresco-content/content-article.pdf.
But the custom properties are showing; their values are not shown.
I have searched a lot but there is no help that i found.
I guess i have to create Custom metadata extractor but what should I write in that java class. There is not a single tutorial regarding that.
Please help.

Thanks
3 REPLIES 3

rise_mini
Champ in-the-making
Champ in-the-making
Hi,
At last i have done what i wanted.  Smiley Very Happy
These are the steps that I have followed.
1- Create Java Project in Eclipse. Project structure should be as-
    /config/alfresco/extension/model
    /lib
    /src/java
   
2- Download sdk of your version of alfresco.

3- Import Sdk AlfrescoEmbedded project into eclipse.

4- Add Sdk AlfrescoEmbedded into your project's build path.

5- Create custom model.xml at /config/alfresco/extension/model.

6- Create all the below files at /config/alfresco/extension
    i- custom context xml -  define path for your model xml file.
    ii- web-client-config-custom.xml - define custom content model at different location like- Action Wizard, Advance Search etc.
    iii- custom extracter xml - define path of custom mapping properties files.
    1v- custom mapping properties file - define mapping of properties.

7- I have to extract custom properties of MS-Doc, i.e. I have written java class.
    i- create package in /src/java.
    ii- good practice is to create package structure as com/<company-name>/extracter.

8- Create property file with the name of your java class and paste the content given below-
  
#
# OfficeMetadataExtracter - default mapping
#
# author: Derek Hulley

# Namespaces
namespace.prefix.cm=http://www.alfresco.org/model/content/1.0


# Mappings
author=cm:author
title=cm:title
subject=cm:description
createDateTime=cm:created
lastSaveDateTime=cm:modified

9- Create build.xml. Sample code can be found from the link given in alfresco developer guide.

<?xml version="1.0" encoding="UTF-8"?>
<project name="Custom Content Model Extensions" default="deploy" basedir=".">
   <property file="build.properties" />

   <property name="label" value="ch4" />
   <property name="project.dir" value="." />
   <property name="build.dir" value="${project.dir}/build" />
   <property name="bin.dir" value="${project.dir}/bin" />
   <property name="lib.dir" value="${project.dir}/lib" />
   <property name="project.name" value="custom-client-extensions" />
   <property name="package.file.zip" value="${build.dir}/${project.name}.zip" />
   <property name="package.file.jar" value="${build.dir}/${project.name}.jar" />
   <property name="project.file.zip" value="${build.dir}/${project.name}-project-${label}.zip" />
    <property name="package.file.amp" value="${build.dir}/${project.name}.amp" />
   <property name="source.dir" value="${project.dir}/src" />
   <property name="config.dir" value="${project.dir}/config" />
   <property name="web.dir" value="${source.dir}/web" />
   <property name="extension.dir" value="/alfresco/extension" />

   <path id="classpath.server">
      <fileset dir="${alfresco.sdk.dir}/server" includes="**/*.jar" />
   </path>

   <path id="classpath.remote">
      <fileset dir="${alfresco.sdk.dir}/remote" includes="**/*.jar" />
   </path>   

   <path id="classpath.local">
      <fileset dir="${project.dir}/lib" includes="**/*.jar" />
   </path>

   <path id="classpath.build">
       <fileset dir="${build.dir}" includes="**/*.jar" />
    </path>
   
   <target name="clean" description="Removes all generated files">
      <delete dir="${build.dir}" />
      <delete dir="${bin.dir}" />      
   </target>

   <target name="clean-tomcat" description="Removes deployed extension directory, lib/someco*.jar, and someco/" >
      <delete dir="${alfresco.web.dir}/WEB-INF/classes/alfresco/extension" />
      <delete dir="${alfresco.web.dir}/WEB-INF/classes/alfresco/module" />
      <delete dir="${alfresco.web.dir}/jsp/extension" />
      <delete dir="${alfresco.web.dir}/someco" />
      <delete file="${alfresco.web.dir}/WEB-INF/lib/someco-alfresco.jar" />
   </target>

   <target name="setup" description="Creates the ${build.dir} and ${bin.dir} directories">
      <mkdir dir="${build.dir}" />
      <mkdir dir="${bin.dir}" />      
   </target>

   <target name="package-extension" depends="setup, package-jar" description="Creates a zip called ${package.file.zip} which can be unzipped on top of an exploded Alfresco web app">
      <delete file="${package.file.zip}" />
      <zip destfile="${package.file.zip}" update="true">
         <zipfileset dir="${config.dir}${extension.dir}" prefix="WEB-INF/classes${extension.dir}" />
         <zipfileset file="${package.file.jar}" prefix="WEB-INF/lib" />
         <zipfileset dir="${lib.dir}" prefix="WEB-INF/lib" />
         <zipfileset dir="${web.dir}" excludes="META-INF/**" />
      </zip>
   </target>
   
   <target name="package-amp" depends="setup, package-jar" description="Packages the customizations as an Alfresco module in ${package.file.amp}">
      <delete file="${package.file.amp}" />
      <zip destfile="${package.file.amp}">
         <zipfileset file="${package.file.jar}" prefix="lib" />
         <zipfileset dir="${web.dir}" prefix="web" />
         <zipfileset dir="${config.dir}${extension.dir}/model" prefix="config${module.dir}/${module.id}/model" />
          <!–<zipfileset file="${config.dir}${extension.dir}/someco-model-context.xml" prefix="config${module.dir}/${module.id}" />–>
         <zipfileset file="${config.dir}${extension.dir}/web-client-config-custom.xml" prefix="config${module.dir}/${module.id}/ui" />         
      </zip>
   </target>
   
   <target name="install-amp" depends="package-amp" description="Uses the Alfresco MMT to install the AMP into ${alfresco.war.path}">
        <java dir="." fork="true" classname="org.alfresco.repo.module.tool.ModuleManagementTool">
         <classpath refid="classpath.server"/>
            <arg line="install ${package.file.amp} ${alfresco.war.path} -force -verbose"/>
        </java>
    </target>
   
    <target name="deploy-amp" depends="install-amp" description="Unzips the AMP'd WAR file into ${alfresco.web.dir}">
         <unzip src="${alfresco.war.path}" dest="${alfresco.web.dir}" />
    </target>

   <target name="deploy" depends="package-extension" description="Unzips the ${package.file.zip} into ${alfresco.web.dir}">
      <unzip src="${package.file.zip}" dest="${alfresco.web.dir}" />
   </target>

   <target name="zip-project" depends="setup" description="Zips the entire Eclipse project as-is into ${project.file.zip}">
      <delete file="${project.file.zip}" />
      <zip destfile="${project.file.zip}">
         <zipfileset dir="${project.dir}" excludes="build/** bin/**" prefix="${project.name}-${label}" />
      </zip>
   </target>   

   <target name="compile" description="Compiles src to ${bin.dir}">
      <mkdir dir="${bin.dir}" />
      <javac srcdir="${source.dir}/java" destdir="${bin.dir}" source="1.5" target="1.5" debug="on" fork="yes" deprecation="on">
         <classpath refid="classpath.server"/>
         <classpath refid="classpath.remote"/>
         <classpath refid="classpath.local"/>         
      </javac>
      <!– copy in non-compiled files like props if needed –>
      <copy todir="${bin.dir}">
         <fileset dir="${source.dir}/java" excludes="**/*.java"/>
      </copy>
   </target>
   
   <target name="package-jar" depends="setup, compile"
      description="Jars up the compiled classes and ${web.dir}/META-INF into ${package.file.jar}">
         <delete file="${package.file.jar}" />
         <jar destfile="${package.file.jar}">
            <fileset dir="${bin.dir}" includes="com/**" />         
         </jar>
   </target>
   
   
   
</project>

10- Create build.properties and define two path-
      i- alfresco.sdk.dir= <path to sdk dir >
      ii- alfresco.web.dir= <path to webapps/alfresco folder of tomcat dir >

11- Right click on build.xml and select run as ant build. This will create jar with name custom-client-extension.jar(as defined in build.xml) and copy it into alfresco lib under tomcat.
It also create model folder and all other file at extension dir inside webapps/alfresco/WEB-INF/classes/alfresco/extension.

12- restart the tomcat and create one space and define rule on that space.
      i- condition
            # item of type or sub-type
      ii- action
           # special type
           # add aspect
           # extract common metadata fields

13- Upload any file into that space and select custom content model from type field and see the result.

Note- Try to read 2nd and 3rd chapter of Alfresco developer guide before starting the work.

ryan007
Champ in-the-making
Champ in-the-making
Hi ,

I want to create a custom metadata in alfresco , so that if document or excel sheet(column)have values , then all such properties with their values should be displayed under properties section of that file.

Is it possible in alfresco?

If yes can you provide me some way to do it.

kaynezhang
World-Class Innovator
World-Class Innovator
You should implemente a custom policy/behavior or an java rule/action,and in your behaviour/action java class,call some entity extraction library to extract property values from your office files ,and save these values into metadata.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.