Beta
Nuxeo Answers
ask a question

hi,

i m trying to extends all my documents with a new directory item (which looks like Subjects) and get rid of Coverage one.

so, i choose a custom dublincore schema that override default one, making a widget and extends the layout...but i get errors, almost everywhere.
May be it's not as simple as overriding dublincore ?
Do y have to register a new schema and extend all types of documents ?

thanks, jérémie

asked Feb 14 '12 at 01:53 jeremie 66459 jeremie's gravatar image
edited Feb 14 '12 at 15:56 Olivier Grisel ♦ 70159 Olivier%20Grisel's gravatar image

Overriding dublincore is evil :)

Dublincore is the schema that store all the mandatory fields of Nuxeo Document. This is a standard schema, if you want to see a bit more on this point go there.

But that's not only for that. for maintenance of your code, if we update something on this part of our code, you will have to take care of our updates to push them into your code.

And last, but no least your error may happens because when you has overridden the schema you remove some fields but you didn't update the layout that wait for this field...

Anyway I hope, I convince you to not go to this way.

A better way is to:

  • Create your own schema
  • Override File and Folder docType definition to just add this new schema. As all documents extends that docTypes you must have all Doc Type implementing your schema.
  • Override the "dublincore" layout to add your widget (mmmh... ) or create your own layout and add it in all your document presentation definition.

To override the core type definition, I think you just have to do something like:

<require>org.nuxeo.ecm.core.CoreExtensions</require>
<extension target="org.nuxeo.ecm.core.schema.TypeService"
    point="configuration">
<doctype name="Folder" extends="Document">
  <schema name="myschema"/>
</doctype>

<doctype name="File" extends="Document">
  <schema name="myschema"/>
</doctype>
...

To override dublincore layout, you will have something like that:

<require>org.nuxeo.ecm.platform.forms.layouts.webapp</require>
<extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
    point="layouts">
    <layout name="dublincore">

I hope that will help you.

link
answered Feb 14 '12 at 12:26 bjalon ♦♦ 2.9k203258 bjalon's gravatar image
edited Feb 14 '12 at 15:56 Olivier Grisel ♦ 70159 Olivier%20Grisel's gravatar image

ok, you convince me.

for the moment, i try the following registering a schema with one element adding my schema to the doctypes :

<require>org.nuxeo.ecm.core.CoreExtensions</require>
<extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
  <doctype name="Folder" extends="Document">
     <schema name="common"/>            
     <schema name="dublincore"/>
     <schema name="location" />
     etc...
<doctype name="File" extends="Document">
etc...

and, finally, adding a modified dublincore layout. but, i still have errors with workspace (the schema declared in folder was not found).
i think i will try the other method.

by the way, do i need to put the require thing directly above the extension point or in the manifest file ?

(Feb 14 '12 at 18:08) jeremie

Did you define your location schema:

<extension target="org.nuxeo.ecm.core.schema.TypeService"
      point="schema">
    <schema name="location" prefix="location" src="schema/location.xsd"/>
</extension>
(Feb 14 '12 at 18:38) bjalon ♦♦

here is the whole thing :

schema and doctype


<extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
    <schema name="location" src="schemas/location.xsd" prefix="lc"/>
</extension>
<require>org.nuxeo.ecm.core.CoreExtensions</require>
<extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
    <doctype name="Folder" extends="Document">
      <schema name="common"/>         
<schema name="dublincore"/> <schema name="location"/> <facet name="Folderish"/> <subtypes> <type>Folder</type> <type>File</type> <type>Note</type> </subtypes> </doctype>
<doctype name="File" extends="Document"> <schema name="common"/> <schema name="file"/> <schema name="dublincore"/> <schema name="uid"/> <schema name="files"/> <schema name="location"/> <facet name="Downloadable"/> <facet name="Versionable"/> <facet name="Publishable"/> <facet name="Commentable"/> <facet name="HasRelatedText"/> </doctype>

widget :


    <extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager" point="widgets">
        <widget name="location" type="template">
            <labels>
                <label mode="any">Localisation</label>
            </labels>
            <helplabels>
                <label mode="edit">si besoin d'aide</label>
            </helplabels>
            <translated>false</translated>
            <fields>
                <field>lc:locations</field>
            </fields>
            <properties mode="any">
                <property name="template">/widgets/subject_widget.xhtml</property>
            </properties>
        </widget>  
</extension>

and layout :

 
    <require>org.nuxeo.ecm.platform.forms.layouts.webapp</require>
    <extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager" point="layouts">

<layout name="dublincore">
  <templates>
    <template mode="any">/layouts/layout_default_template.xhtml</template>
  </templates>
  <rows>
    <row>
      <widget>nature</widget>
    </row>
    <row>
      <widget>subjects</widget>
    </row>
    <row>
      <widget>location</widget>
    </row>
    <row>
      <widget>rights</widget>
    </row>
    <row>
      <widget>source</widget>
    </row>
    <row>
      <widget>created</widget>
    </row>
    <row>
      <widget>modified</widget>
    </row>
    <row>
      <widget>format</widget>
    </row>
    <row>
      <widget>language</widget>
    </row>
    <row>
      <widget>expired</widget>
    </row>
    <row>
      <widget>author</widget>
    </row>
    <row>
      <widget>contributors</widget>
    </row>
    <row>
      <widget>lastContributor</widget>
    </row>
  </rows>
</layout>        
</extension>

(Feb 14 '12 at 19:29) jeremie

All seems good can you please give us some information of your error. Please refer to this answer item if you don't know how.

(Feb 25 '12 at 19:36) bjalon ♦♦
Your answer
toggle preview

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×65
×13

Asked: Feb 14 '12 at 01:53

Seen: 876 times

Last updated: Feb 25 '12 at 19:36