Document id reference desn't work for impex - sap

I have a problem with impex which contains document id reference.
From docs:
"Especially for importing partOf item values it is necessary to reference these items by means other than the usual unique column technique because partOf items often do not provide a unique key but only hold their enclosing parent as foreign key."
Items from *items.xml (only the most important parts)
<itemtype code="A" autocreate="true" generate="true" abstract="true"/>
<itemtype code="B" autocreate="true" generate="true" extends="A">
<deployment table="btable" typecode="20115" />
<attributes>
<attribute qualifier="code" type="java.lang.Integer" autocreate="true" generate="true">
<persistence type="property"/>
<modifiers optional="false"/>
</attribute>
</attributes>
</itemtype>
<itemtype code="C" autocreate="true" generate="true">
<deployment table="ctable" typecode="20117" />
<attributes>
<attribute qualifier="code" type="java.lang.String" autocreate="true" generate="true">
<persistence type="property"/>
<modifiers optional="false" unique="true"/>
</attribute>
<attribute qualifier="test" type="A" autocreate="true" generate="true">
<persistence type="property"/>
<modifiers optional="false" partof="true"/>
</attribute>
</attributes>
</itemtype>
Impex code:
INSERT B;code;&docIdRef
;1;docId
INSERT_UPDATE C;code[unique=true];test(&docIdRef)
;uniqueCode;docId
Error message:
cannot create C with values ItemAttributeMap[ registry: null, type: <null>, (...) due to [de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator#3b777877]:missing values for [test] in model C
When I removed 'partof' modifier from 'test' attribute (C class) everything worked fine.
I wonder how impex should looks like if i want to keep 'partof' modifier.

When you use partOf you must reference the partOf using the owner.
So it does :
INSERT B;owner(C.code);&docIdRef
;uniqueCode;docId
INSERT_UPDATE C;code[unique=true];test(&docIdRef)
;uniqueCode;docId
You don't need to assign B an identifier, you just need to reference the owner.

If you know for sure that your data is correct you can use [forceWrite=true] modifier or legacy mode to skip service layer validation.
You should also make sure that this configuration is what you really need. Setting either optional to true or partOf to false or providing default value should fix the issue as well.

Since you have mentioned partof="true" you can not assign a reference of type A. You can only create a new entity.
Check the OOTB AbstractOrder2AbstractOrderEntry relationship, they have mentioned partof="true" for AbstractOrderEntry means you can't reference any other AbstractOrderEntry to Order. You can always create new entry.
Have a look at HMC site as well
You can see here there is no + Add Entry button available here. The reciprocal can be possible.

Related

Shibboleth Attributes not Mapping

We are having an issue with Shibboleth and Apache Server. I am integrating with an SSO portal for a Tomcat application. I have the integration with the SSO portal figured out, but we are having an issue with the mapping of the attributes. We are obtaining a NameID which is the email address. I don’t know what I am missing. I can see the email in the Shibd.log, but I cannot see any attributes in the Shibboleth.sso/Session
Here is my configuration for the attribute-map:
<Attributes xmlns="urn:mace:shibboleth:2.0:attribute-map" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Attribute name="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent" id="persistent-id">
<AttributeDecoder xsi:type="NameIDAttributeDecoder" formatter="$NameQualifier!$SPNameQualifier!$Name" defaultQualifiers="true"/>
</Attribute>
<Attribute name="emailAddress" nameFormat="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" id="emailAddress">
<AttributeDecoder xsi:type="NameIDAttributeDecoder" formatter="$Name" defaultQualifiers="true" />
</Attribute>
<Attribute name="mail" nameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" id="mail">
<AttributeDecoder xsi:type="NameIDAttributeDecoder" formatter="$Name" defaultQualifiers="true" />
</Attribute>
</Attributes>
Here is what I have in the Attribute-Policy:
<afp:AttributeFilterPolicyGroup
xmlns="urn:mace:shibboleth:2.0:afp:mf:basic"
xmlns:saml="urn:mace:shibboleth:2.0:afp:mf:saml"
xmlns:basic="urn:mace:shibboleth:2.0:afp:mf:basic"
xmlns:afp="urn:mace:shibboleth:2.0:afp"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<afp:AttributeFilterPolicy>
<!-- This policy is in effect in all cases. -->
<afp:PolicyRequirementRule xsi:type="ANY"/>
<!-- Catch-all that passes everything else through unmolested. -->
<afp:AttributeRule attributeID="*" permitAny="true"/>
</afp:AttributeFilterPolicy>
</afp:AttributeFilterPolicyGroup>
The Shibd.log has the following verbiage:
019-12-16 16:48:23 INFO Shibboleth.AttributeExtractor.XML : creating mapping for Attribute urn:oasis:names:tc:SAML:2.0:nameid-format:persistent
2019-12-16 16:48:23 INFO Shibboleth.AttributeExtractor.XML : creating mapping for Attribute emailAddress, Format/Namespace:urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress
2019-12-16 16:48:23 INFO Shibboleth.AttributeExtractor.XML : creating mapping for Attribute mail, Format/Namespace:urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified
However, as previously mentioned we cannot see any attributes in Shibboleth.sso/Session
Am I missing anything?
This was fixed by adding the attributes:
<Attribute name="urn:mace:dir:attribute-def:mail" id="SHIB_MAIL"/>
<Attribute name="urn:oid:0.9.2342.19200300.100.1.3" id="SHIB_MAIL"/>
This was the only attribute that showed up in the attribute portion of the SP Session.

How to define cascade delete in the Hybris items.xml?

I want to remove child objects automatically on removable of the Parent object.
For instance, I have types Car and Engine. The car has an attribute Engine. When Car object is removed, Engine object that is bound to this Car should be removed automatically.
Thanks in advance, guys
Use the "partOf" modifier:
<itemtype code="Car" ...>
...
<attributes>
...
<attribute qualifier="engine" type="Engine">
<persistence type="property" />
<modifiers partof="true" />
</attribute>
</attributes>
</itemtype>
Can also be used with relations:
<relation code="CarToEngineRelation"...>
<sourceElement type="Car" ...>
</sourceElement>
<targetElement type="Engine" ...>
<modifiers partof="true"/>
</targetElement>
</relation>
#Johannes very well set the example.
Let me elaborate more on
What is PartOf?
PartOf modifier is used to define the aggregation relationship between Parent and Child objects. To explain it better I would say PartOf is used to defining cascade delete. When we delete Parent object then all its child objects(partOf) will be deleted automatically.
You can define it at attribute or relation with help of modifiers tag. Like
<itemtype code="User"
extends="Principal"
jaloclass="de.hybris.platform.jalo.user.User"
autocreate="true"
generate="true">
<deployment table="Users" typecode="4" propertytable="UserProps"/>
<attributes>
...
...
<attribute autocreate="true" qualifier="addresses" type="AddressCollection">
<modifiers partof="true"/>
</attribute>
<attribute autocreate="true" qualifier="carts" type="CartCollection">
<modifiers partof="true"/>
</attribute>
</attributes>
</itemtype>
If we remove a user, its all addresses & carts will be removed.
find the detailed post here

MDX Attribute Value Key

I've faced such a problem:
I have a dimension [Project_sales] with one hierarchy [Default] in my cube [Sales_planning_RP].
I've created a custom property for this dimension and named it "Object".
When I created it I was asked for:
1)Property Key
2)Property value
Now I Have Source-table for this dimension with 2 additional fields:
1) [Object_code] ex:('O01') <-This is what I need (see question below)
2) [Object_name] ex: ('Object # 3213, editable') <-This is What I get
But I see only one property in OLAP:
[Project_sales].[Default].CurrentMember.Properties("Object")
Which gives me just Object_name.
So my question is how can I get the key of my property "Object" with MDX?
My dimension properties:
http://i.stack.imgur.com/N2Aej.png
My dimension has the following "parent_child" hierarchy:
Project->Object->Element_of_area
Every element of this hierarchy has as attribute "Object", which can be called in such a way:
[Project_sales].[Default].CurrentMember.Properties("Object")
In the properties window (in my picture) of the attribute "Object" there are 2 properties:
1)keyColumns
2)NameColumns
I repeat: "Object" here is not a member of dimension, it's an attribute!
And it has its own key and name.
I can get its name, but can't understand how to get its key, which is also loaded into cube.
Look at my member_properties list:
image_2
And here is a part of XMLA-code of my dimension to makes things clear:
<Attribute>
<Annotations>
<Annotation>
<Name>TypeOfInformation</Name>
<Value>1</Value>
</Annotation>
<Annotation>
<Name>TypeOfNameInformation</Name>
<Value>1</Value>
</Annotation>
<Annotation>
<Name>P4SSAMOVersion</Name>
<Value>2</Value>
</Annotation>
</Annotations>
<ID>Object</ID>
<Name>Object</Name>
<KeyColumns>
<KeyColumn>
<DataType>WChar</DataType>
<DataSize>40</DataSize>
<Source xsi:type="ColumnBinding">
<TableID>_x0036_Project_sales</TableID>
<ColumnID>Object_code</ColumnID>
</Source>
</KeyColumn>
</KeyColumns>
<NameColumn>
<DataType>WChar</DataType>
<DataSize>255</DataSize>
<Source xsi:type="ColumnBinding">
<TableID>_x0036_Project_sales</TableID>
<ColumnID>Object_name</ColumnID>
</Source>
</NameColumn>
<OrderBy>Key</OrderBy>
<MembersWithData>NonLeafDataHidden</MembersWithData>
<AttributeHierarchyVisible>false</AttributeHierarchyVisible>
</Attribute>
Ok, now it's clear!
There are 3 properties of an Attribute that may contain data:
1)Key
2)Name
3)Value
If Name is not empty and Key is not empty, you get Name when call .Properties() function.
If Name is empty and Key is not empty, you get Key.
Here is the source: https://www.mssqltips.com/sqlservertip/3271/sql-server-analysis-server-ssas-keycolumn-vs-namecolumn-vs-valuecolumn/

How to add Link to Story via VersionOne REST API?

I'm able to create new Story via POST to /VersionOne/rest-1.v1/Data/Story with corresponding XML payload. Setting all attributes (including relational) works like a charm. However I'm unable to figure out how to add a Link asset to the Story asset.
When I try POSTing to /VersionOne/rest-1.v1/Data/Link with following XML payload:
<Asset href='/VersionOne/rest-1.v1/New/Link'>
<Attribute name='AssetType' act='set'>Link</Attribute>
<Relation name='Asset' act='set'>
<Asset href='/VersionOne/rest-1.v1/Data/Story/123' idref='Story:123'/>
</Relation>
<Attribute name='OnMenu' act='set'>true</Attribute>
<Attribute name='URL' act='set'>http://my.example.com</Attribute>
<Attribute name='Name' act='set'>My Link Title</Attribute>
</Asset>
The server however returns:
<Error href="/VersionOne/rest-1.v1/Data/Link">
<Message>Violation'Readonly'Link.AssetType</Message>
<Exception class="VersionOne.DataException">
<Message>Violation'Readonly'Link.AssetType</Message>
</Exception>
</Error>
Seems like adding links is prohibited but actually I can add Links via the standard web interface without issues.
My original idea was to create Link asset first and then update the Story with respective relational attribute pointing to that Link asset.
Any ideas anyone?
Thanks!
(I'm using JavaScript/jQuery)
My bad. The <Attribute name='AssetType' act='set'>Link</Attribute> attribute in the POST payload is obviously wrong - it is trying to set the asset's type (link) which does not make sense since I'm stating the type in URL already. It works perfectly without the attribute (as expected).

In VersionOne REST API how does one use multiple “with” statements with multiple “Where” clauses?

With the following query:
Base-URL/rest-1.v1/Data/Epic?sel=Category.Name,Custom_RoadmapInOut&where=Number=$numbers&with=$numbers=E-05322%2CE-05280%2CE-05616%2CE-04942%2CE-04921
I am getting the following response:
<Assets total="5" pageSize="2147483647" pageStart="0">
<Asset href="End-of-Base-URL/rest-1.v1/Data/Epic/138904" id="Epic:138904">
<Attribute name="Category.Name">Business Objective</Attribute>
<Attribute name="Custom_RoadmapInOut">2</Attribute>
</Asset>
<Asset href="End-of-Base-URL/rest-1.v1/Data/Epic/139078" id="Epic:139078">
<Attribute name="Category.Name">Initiative</Attribute>
<Attribute name="Custom_RoadmapInOut">1</Attribute>
</Asset>
<Asset href="End-of-Base-URL/rest-1.v1/Data/Epic/147147" id="Epic:147147">
<Attribute name="Category.Name">Parent Story</Attribute>
<Attribute name="Custom_RoadmapInOut"/>
</Asset>
<Asset href="End-of-Base-URL/rest-1.v1/Data/Epic/148702" id="Epic:148702">
<Attribute name="Category.Name">Parent Story</Attribute>
<Attribute name="Custom_RoadmapInOut"/>
</Asset>
<Asset href="End-of-Base-URL/rest-1.v1/Data/Epic/156961" id="Epic:156961">
<Attribute name="Category.Name">Milestone</Attribute>
<Attribute name="Custom_RoadmapInOut"/>
</Asset>
</Assets>
I want to limit the results to only return those assets that have a "Category.Name" of either "Business Objective" or "Initiative" and from those types to only return the ones that have a "Custom_RoadmapInOut" set to between 1 and 99.
What do I need to add to the query to have VersionOne do the heavy lifting and return only the desired items?
I am thinking I should be able to also add:
Category.Names=$names&with=$names=Business+Objective%2CInitiative
to the query and another where part to check the Custom_RoadmapInOut but I am not sure how to do this.
Currently I am making multiple queries and then using my own code to go through the results and keep only the ones that I desire to see.
Thanks for any help that can be provided.
Doug
Multiple with values can be separated by | (pipe). If you need more details than are shown in the documentation, you can try reading the grammar.
Multiple where filter tokens must be joined by logical operators. Logical and is ; (semicolon). Logical or is | (pipe). Again, the documentation can be a little sparse so you might try reading the grammar.
If you still find yourself still needing to run multiple queries to get what you need, you may find it advantageous to convert to the query.v1 endpoint.