on ‎2020 Mar 02 6:33 PM
I am trying to follow some documentation that talks about creating a book store within SAP Commerce. The model calls for there to be an Author ItemType with a many-to-many (Book2Author) relationship with the books. In the diagram I am looking at, it appears this should be the differentiation of the Author:
<itemtype code="Author" extends="User" generate="true" autocreate="true" jaloclass="com.site.demo.core.jalo.Author">
</itemtype>
Q1: I am not a fan of the fact that Author is extending a User. I think it is more from a business perspective, the author isn't really a user, or... would they be a user? Would you want to design a system such that Authors are able to log in and do regarding their books, maybe reply to comments or something?
Q2: I tried to have Author extend the same thing User extends, Principal, so it looked like this:
<itemtype code="Author" extends="Principal" generate="true" autocreate="true" jaloclass="com.cnbssoftware.demo.core.jalo.Author">
</itemtype>
But when I compile the code (after deleting the auto generated java files) I get this error:
[testClassesScanner] Found 57 chdfulfilmentprocess testclasses in 1.406 ms
[touch] Creating /Users/sam/hybris/CD1904P10/hybris/temp/hybris/touch/chdfulfilmentprocess_testsrctouch
[echo] building extension 'chdcore'...
[copy] Copying 1 file to /Users/sam/dev/work/hybrisdemo/core-customize/hybris/bin/custom/chd/chdcore
[copy] Copying 1 file to /Users/sam/dev/work/hybrisdemo/core-customize/hybris/bin/custom/chd/chdcore
[mkdir] Created dir: /Users/sam/dev/work/hybrisdemo/core-customize/hybris/bin/custom/chd/chdcore/classes
[yjavac] Compiling 76 source files to /Users/sam/dev/work/hybrisdemo/core-customize/hybris/bin/custom/chd/chdcore/classes
[yjavac] ----------
[yjavac] 1. ERROR in /Users/sam/dev/work/hybrisdemo/core-customize/hybris/bin/custom/chd/chdcore/src/com/site/demo/core/jalo/Author.java (at line 9)
[yjavac] public class Author extends GeneratedAuthor
[yjavac] ^^^^^^
[yjavac] The type Author must implement the inherited abstract method Principal.isAdmin()
[yjavac] ----------
[yjavac] 2. ERROR in /Users/sam/dev/work/hybrisdemo/core-customize/hybris/bin/custom/chd/chdcore/src/com/site/demo/core/jalo/Author.java (at line 9)
[yjavac] public class Author extends GeneratedAuthor
[yjavac] ^^^^^^
[yjavac] The type Author must implement the inherited abstract method Principal.getAllDisplayName(SessionContext)
[yjavac] ----------
[yjavac] 3. ERROR in /Users/sam/dev/work/hybrisdemo/core-customize/hybris/bin/custom/chd/chdcore/src/com/site/demo/core/jalo/Author.java (at line 9)
[yjavac] public class Author extends GeneratedAuthor
[yjavac] ^^^^^^
[yjavac] The type Author must implement the inherited abstract method Principal.checkSystemPrincipal()
[yjavac] ----------
[yjavac] 4. ERROR in /Users/sam/dev/work/hybrisdemo/core-customize/hybris/bin/custom/chd/chdcore/src/com/site/demo/core/jalo/Author.java (at line 9)
[yjavac] public class Author extends GeneratedAuthor
[yjavac] ^^^^^^
[yjavac] The type Author must implement the inherited abstract method Principal.getDisplayName(SessionContext)
[yjavac] ----------
[yjavac] 4 problems (4 errors)
BUILD FAILED
/Users/sam/hybris/CD1904P10/hybris/bin/platform/build.xml:20: The following error occurred while executing this line:
/Users/sam/hybris/CD1904P10/hybris/bin/platform/resources/ant/compiling.xml:90: The following error occurred while executing this line:
/Users/sam/hybris/CD1904P10/hybris/bin/platform/resources/ant/compiling.xml:148: The following error occurred while executing this line:
/Users/sam/hybris/CD1904P10/hybris/bin/platform/resources/ant/util.xml:20: The following error occurred while executing this line:
/Users/sam/hybris/CD1904P10/hybris/bin/platform/resources/ant/compiling.xml:155: The following error occurred while executing this line:
/Users/sam/hybris/CD1904P10/hybris/bin/platform/resources/ant/compiling.xml:328: The following error occurred while executing this line:
/Users/sam/hybris/CD1904P10/hybris/bin/platform/resources/ant/compiling.xml:533: The following error occurred while executing this line:
/Users/sam/hybris/CD1904P10/hybris/bin/platform/resources/ant/compiling.xml:595: The following error occurred while executing this line:
/Users/sam/hybris/CD1904P10/hybris/bin/platform/resources/ant/util.xml:91: Compile failed; see the compiler error output for details.
This leads me to believe there is something in the definition of the User to implement these methods, either that or I should not be extending a Principal. Any thoughts?
Request clarification before answering.
Good Morning,
I agree with you that Author should not be an instance of User if the Auther is not really a user of the System.
In this case I would create a dedicated ItemType for Author like this:
<itemtype code="Author" extends="GenericItem" jaloclass="com.site.demo.core.jalo.Author">
<description>My Author ItemType</description>
<deployment table="Author" typecode="123456798"/>
<attributes>
<attribute qualifier="name" type="java.lang.String">
<persistence type="property"/>
<modifiers read="true" write="true" search="true" initial="true" optional="false" unique="true"/>
</attribute>
</attributse>
</itemtype>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Principial is the Supergroup of UserGroup, Users, Employee, Authorities, etc.
It is part of the User Right System in Hybris and therefore is not an simple ItemType.
The Services to check User Rights (CRUD) also make use of the Principal ItemType to check if the Principal has the necessary rights or not.
As I do not think you want to have such a complicated ItemType just for the purpose to provide an Author with a limited number of Information, I designed the Author to extend the GenericItem ItemType.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.