<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to compute a metadata on a document according to a metadata of its children with automation ? in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-compute-a-metadata-on-a-document-according-to-a-metadata/m-p/322635#M9636</link>
    <description>&lt;P&gt;I can think of mainly three ways to do this, but none I know exactly how to implement, because I myself is very green in Nuxeo development and am trying to figure out how to do simple things.&lt;/P&gt;</description>
    <pubDate>Sat, 19 Oct 2013 08:02:13 GMT</pubDate>
    <dc:creator>Bing_Ren</dc:creator>
    <dc:date>2013-10-19T08:02:13Z</dc:date>
    <item>
      <title>How to compute a metadata on a document according to a metadata of its children with automation ?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-compute-a-metadata-on-a-document-according-to-a-metadata/m-p/322631#M9632</link>
      <description>&lt;P&gt;I have a metadata called "total" on a document. This document can have a variable number of children documents, all having a metadata called "amount".&lt;/P&gt;
&lt;P&gt;How can I parameter an automation chain to calculate the "total" from the parent document which must be equal to the sum of the "amount" of its children documents ?&lt;/P&gt;
&lt;P&gt;Thanks for your help !&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2013 22:18:59 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/how-to-compute-a-metadata-on-a-document-according-to-a-metadata/m-p/322631#M9632</guid>
      <dc:creator>Christophe_</dc:creator>
      <dc:date>2013-10-17T22:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to compute a metadata on a document according to a metadata of its children with automation ?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-compute-a-metadata-on-a-document-according-to-a-metadata/m-p/322632#M9633</link>
      <description>&lt;P&gt;It seems to me the best bet is to implement somekind of event handler, listening change event on child document. Then child document get its parent to recalculate the total.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2013 08:38:30 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/how-to-compute-a-metadata-on-a-document-according-to-a-metadata/m-p/322632#M9633</guid>
      <dc:creator>Bing_Ren</dc:creator>
      <dc:date>2013-10-18T08:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to compute a metadata on a document according to a metadata of its children with automation ?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-compute-a-metadata-on-a-document-according-to-a-metadata/m-p/322633#M9634</link>
      <description>&lt;P&gt;Thanks for your reply&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2013 10:11:14 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/how-to-compute-a-metadata-on-a-document-according-to-a-metadata/m-p/322633#M9634</guid>
      <dc:creator>Christophe_</dc:creator>
      <dc:date>2013-10-18T10:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to compute a metadata on a document according to a metadata of its children with automation ?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-compute-a-metadata-on-a-document-according-to-a-metadata/m-p/322634#M9635</link>
      <description>&lt;P&gt;not the solution, but it can helps :&lt;/P&gt;
&lt;P&gt;I did a groovy script for Nuxeo Shell, similar to your needs
Hope it can inspire you&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;import org.nuxeo.ecm.core.api.IdRef;
import org.nuxeo.ecm.core.api.PathRef;

def ref = Context["ref"];
def docRoot = null;

if (ref == null || ref == "") { return "Context execution variable not set : ref"; }

try {   
  if (ref.startsWith("/")) {
    docRoot = Session.getDocument(new PathRef(ref));
  } else {
    docRoot = Session.getDocument(new IdRef(ref));
  }
} catch (Exception e) {
  return "Exception: ${e.getMessage()}.";
}

def docRootAndChildren = [];
docRootAndChildren = Session.query("SELECT * FROM Folder WHERE ecm:path STARTSWITH '${docRoot.getPath()}'");

def total = 0;
for (doc in docRootAndChildren) {
  total += Integer.parseInt(doc.getProperty("dublincore", "source"));
}

return  "total = ${total}";
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Oct 2013 14:08:24 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/how-to-compute-a-metadata-on-a-document-according-to-a-metadata/m-p/322634#M9635</guid>
      <dc:creator>sdenef_</dc:creator>
      <dc:date>2013-10-18T14:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to compute a metadata on a document according to a metadata of its children with automation ?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-compute-a-metadata-on-a-document-according-to-a-metadata/m-p/322635#M9636</link>
      <description>&lt;P&gt;I can think of mainly three ways to do this, but none I know exactly how to implement, because I myself is very green in Nuxeo development and am trying to figure out how to do simple things.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Oct 2013 08:02:13 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/how-to-compute-a-metadata-on-a-document-according-to-a-metadata/m-p/322635#M9636</guid>
      <dc:creator>Bing_Ren</dc:creator>
      <dc:date>2013-10-19T08:02:13Z</dc:date>
    </item>
  </channel>
</rss>

