Skip to content
This repository was archived by the owner on Feb 16, 2020. It is now read-only.

3 items

Markus Perndorfer edited this page May 3, 2019 · 2 revisions

Items

Tag
3-items

Things to consider when writing custom item types:

  • Avoid null attributes: If there is a sensible default value, use it and set optional="false" (this is always valid for boolean attributes)

  • It's usually not necessary to define the jaloclass, let the platform generate that for you (packageroot from extensioninfo.xml + .jalo. + <typecode>).
    Commit this file! It is generated exactly once when a new type is introduced and the build never touches that file again. Committing the file avoids build errors when switching branches.

    PITFALL The exception to this rule is when you extend a abstract type, like SimpleCMSComponent. Then you have to define the jaloClass otherwise your new type is also abstract.

  • Always define a <deployment> if the type extends GenericItem, which it does by default

  • If your new type extends a type that already defines a <deployment>, do not add a new deployment for your new type. If you do so, the platform creates very poor SQL if you query for the supertype.

  • Always define unique attributes + a unique database index

  • Heavily prefer <relation> over <collectiontypes>. As a rule of thumb, only use collection types for dynamic attributes.

How to: Add/Modify/Remove custom item types per extension

Technically the build still generates all item types for all extensions, but with this approach you at least avoid rebuilding the whole platform just because you tweaked the item types of a single extension.

Add / modify a type

cd hybris/bin/custom/extension
ant build

This works in 95% of the cases, if something fails (the usual suspect is GeneratedTypeInitializer.java ) use ant clean build

Remove a type

cd hybris/bin/platform
ant clean build

This will fail, because there will be some generated jalo classes are not automatically deleted. To fix, delete the file that doesn't compile, usually the file is hybris/bin/custom/<extension>/src/.../jalo/<typecode>.java).

Unfortunately, the ...Model class for a custom type is generated into platform/bootstrap/gensrc, and this folder is not cleaned / modified if you run the build in the extension folder.

This means to completely get rid of a type, you have to perform a platform rebuild with ant clean build

Clone this wiki locally