cancel
Showing results for 
Search instead for 
Did you mean: 

Mass metadata update

bpil
Champ in-the-making
Champ in-the-making
Hello,

I need to update a metadata for a lot of document.
Somebody knows how i can do that ?

Bye,
Ben.

Alfresco Enterprise 2.1
Windows Server 2003
Oracle 10g
WebSphere 6.1
JDK 1.5
7 REPLIES 7

invictus9
Champ in-the-making
Champ in-the-making
Your requirements are vague, but I will take a stab at it. For instance, you don't say where the new metadata values are coming from. I will assume it's a fixed value. I will also assume that each document that we look at is of the correct content type.

First off, you would create a script to put into Data Dictionary/Scripts space that would be invoked on a single document.

doc.properties["my:prop1"] = "new constant value";
doc.properties["my:prop2"] = "new other constant value"';
/* more stuff */
doc.save();  /* to save the properties just set */
This will perform the change to the metadata.

The tougher part is how to select the documents you want to make the change to. If you need to do it manually. I suggest you create a folder that will invoke the script for each incoming document, and cut and paste your documents into the folder. As each document arrives, the script runs, setting the appropriate metadata.

If you can do a search, it may be best to have the script do the search and apply the changes to each document that it finds.

boutch55555
Champ in-the-making
Champ in-the-making
Hi !

I would like to do something similar, but I need to add a user ID to a custom metadata field. The users are using a shared account and need to add their ID to the pictures they upload. I was thinking about making a space for each user and then adding the space name to the pictures's metadata. Would this be possible ? I also looked to prompt the user for his ID, but it woudn't work from CIFS. Any ideas ?

Thanks

boutch55555
Champ in-the-making
Champ in-the-making
I found out :
var parent = space.name
document.properties["cm:author"]= (parent);
document.save();  /* to save the properties just set */
hope this helps someone else…

jk3us
Champ in-the-making
Champ in-the-making
This is a big weak spot in Alfresco for us.  We need it to be easy for a user (not a programmer) to be able to say, for all files in this entire space/folder set this property to this value.  That is, doing mass update without needing to know how to write a script.  Is there any way that this can be done?

invictus9
Champ in-the-making
Champ in-the-making
This is a big weak spot in Alfresco for us.  We need it to be easy for a user (not a programmer) to be able to say, for all files in this entire space/folder set this property to this value.  That is, doing mass update without needing to know how to write a script.  Is there any way that this can be done?

I would suggest looking at a web script to do this. You would provide a path to the folder, the property name, and the new property value, and the web script would apply the value to the property. The most general form of this web script is probably too powerful: you would want to hide its capabilities behind a user interface.

boutch55555
Champ in-the-making
Champ in-the-making
you could also call the said script from the menu by adding something like :

<config>
    <actions>
     <action id="export_pictures">
        <permissions>
          <permission allow="true">Write</permission>
        </permissions>
   <label>Exporter vers la photothèque</label>
   <tooltip>Runs the specified JavaScript</tooltip>
   <show-link>true</show-link>
   <style>padding:4px</style>
        <style-class>inlineAction</style-class>
        <image>/images/icons/CheckIn_icon.gif</image>
        <script>/Company Home/Data Dictionary/Scripts/export.js</script>
        <params>
           <param name="id">#{actionContext.id}</param>
           <param name="noderef">#{actionContext.nodeRef}</param>
        </params>
      </action>
     <action-group id="browse_actions_menu">
        <action idref="export_pictures" />
      </action-group>
    </actions>
  </config>


to the web-client-config-custom.xml (in tomcat/shared/classes/alfresco/extension/)

Or, as invictus9 said, just use the webscripts, in which case you would use :


<config>
   <actions>
      <action id="deletealbum">
         <label>Supprimer un album</label>
         <image>/images/icons/delete.gif</image>
        <href>/wcservice/albums/deletealbum</href>
        <params>
           <param name="id">#{actionContext.id}</param>
           <param name="noderef">#{actionContext.nodeRef}</param>
        </params>
        <onclick>window.open('/wcservice/albums/deletealbum'); return false;</onclick>
         <target>/wcservice/albums/deletealbum</target>
      </action>
     <action-group id="browse_actions_menu">
        <action idref="deletealbum" />
      </action-group>
   </actions>
</config>

to call the webscript from the more actions menu.

ps : In the 2nd example, the wcservice in the path is used not to have to login again. If you want enforce login for the said webscript, just use service instead of wcservice.
pps : In the 2nd example, I don't know if it's the onclick, target or href that works, but it works 😉

jk3us
Champ in-the-making
Champ in-the-making
Ok, this looks like it might be what I'm looking for, I had thought that Web Scripts were just ways of exposing Alfresco functionality to external services via REST.

So, I guess what I want is an "action" for spaces that would display a form for the user to enter which fields were needed, submitting that form would set the provided properties in all children.  I see how to add an action and have it call a webscript, but I'm not sure how that webscript can display a form for user input.  Would there be two webscripts in this scenario (one to display the form, one to complete the action)?  Are there any examples or documentation out there for this sort of thing?

EDIT:  I'm starting to get there now… I'm using the "file upload" example as my template for the form/submission steps and the "folder" example for building the url for the space I want to manipulate (http://wiki.alfresco.com/wiki/Web_Scripts_Examples).  Is there a way in the .html.ftl files to output the complex form fields from the built in "Modify Content Properties" form?  I need to embed a tagger, date fields, drop downs w/ proper options for multiple choice fields from my custom aspect.  Is it possible in the WebScripts to use alfresco's nice javascript widgets?