8 Replies Latest reply on Nov 12, 2020 9:54 PM by Markus Wurzinger

    New field for Product-Medias

    Markus Wurzinger Active Member

      Hello everyone,

       

      i want to add a string field to the product-media-map but there are no res-fields on that entity-type.

       

      I have already that i need to add my field to the Entity "MediaAssetDocument", because the "Product2GMediaAssetDocument" is just like a proxy.

       

      I can see the field from MediaAssetDocument on rich-client and everything works fine, but i also need this field when i import product-medias and via rest-api.

       

      So my question is: Is there a way i can create a new field on "Product2GMediaAssetDocument" that is just a proxy to my new field from "MediaAssetDocument" ?

      I know there are Transition-Fields but they do not support import and rest-api right ?

       

      Greetings

      Markus

        • 1. Re: New field for Product-Medias
          Sai Narasimha Prasad Rebba Guru

          Hi Markus,

           

          Rest List Read API supports transitions fields.

           

          An example would be the object "Article" and it's field "Article.Status". Each item has a quality status, whose content resides in the "QualityStatus" object. If we want to obtain the quality status of a certain item for a specific data quality rule, we need to use a transition field with target "QualityStatusEntry.Status" and proper qualification for the "rule" logical key.

           

          Syntax

          Transition field: <Fully qualified field> -> ... -> <n-Fully qualified field>

           

          The quality status of an item of rule "CheckValidGTIN":

          Article.Status -> QualityStatusEntry.Status(CheckValidGTIN)

           

          Thank you

          Sai Prasad

          • 2. Re: New field for Product-Medias
            Markus Wurzinger Active Member

            Hey Sai,

             

            so if i understand you right, i have to create a transition field for each quality and language combination ?

             

            I would prefer to have a field "Product2GMediaAssetDocument.MyNewField" and then write into it via Rest api qualified -> "Product2GMediaAssetDocument.MyNewField(type,quality,language)".

            This field would be a proxy for "MediaAssetDocument.MyNewField" which relies on "Res_Text_001".

             

            Is this possible ?

             

            Thank you

            Markus Wurzinger

            • 3. Re: New field for Product-Medias
              Markus Wurzinger Active Member

              Hey Sai,

               

              so i found out what you mean. In my example i would request the following field with the rest-api:

              "Product2GMediaAssetMap.MediaAsset(MEDIATYPE) -> MediaAssetDocument.MyNewField(LANGUAGE, TYPE)"

              And this works!! For everyone "Product2GMediaAssetMap.MediaAsset" does not support Rest-Api by default, you have to enable it in the repository.

               

              My Problem is now, that i also want to write to this field and i think the Rest List Write Api does not support this, right ?

               

              When i write to the field i get the error: "Root entity of field 'Product2GMediaAssetMap.MediaAsset(TYPE) -> MediaAssetDocument.MyNewField(LANGUAGE, TYPE)' is not 'Product2G'". I also have tried to post to "rest/V1.0/list/Product2G/Product2GMediaAssetMap" but with the same result.

               

              Greetings

              Markus

              • 4. Re: New field for Product-Medias
                Sai Narasimha Prasad Rebba Guru

                Hi Markus,

                 

                As mentioned earlier Rest List Read API supports transitions fields. I think we can't write data in that fields through Rest API.

                 

                I think customization required for this.

                Add new MediaAsset field

                Let us assume that a text field is desired, then the reversed field type "MediaAssetType.Res_Text100_01" can be take for it.

                Active the desired MediaAsset field type

                active the reserved MediaAssetType.Res_Text100_01 in the repository

                Add a new MediaAsset field for the activated field type:

                create then a new field MediaAsset.Res_Text100_01 which has the field type MediaAssetType.Res_Text100_01

                 

                MediaAsset.Res_Text100f_01 Collapse source

                 

                 

                <field identifier="MediaAsset.Res_Text100_01" category-ref="master-data" field-type-ref="MediaAssetType.Res_Text100_01">

                 

                  <name>%field.MediaAsset.Res_Text100_01.name</name>

                  <description>%field.MediaAsset.Res_Text100_01.description</description>

                  <max-length>260</max-length>

                  <visible-from-top>true</visible-from-top>

                  <display-by-default>true</display-by-default>

                  <display-by-default-from-top>true</display-by-default-from-top>

                  <average-length>25</average-length>

                  <purpose>1</purpose>

                  <importPurpose>1</importPurpose>

                  <exportPurpose>51</exportPurpose>

                </field>

                Map MediaAsset field to the objects of the field type "ArticleType" (optional)

                 

                It is only necessary, if customer need the similar case like importing Item/Product2G/Variant with the above defined MediaAsset.Res_Text100_01 field value. Otherwise this step can be ignored, since the user can edit this field value in Desktop UI and Web UI.

                 

                Add mapped field type and field

                Add a mapped ArticleMediaAssetMapType field type

                add a new field type ArticleMediaAssetMapType.Res_Text100_01 which will be mapped to MediaAssetType.Res_Text100_01:

                 

                ArticleMediaAssetMapType.Res_Text100_01 Collapse source

                 

                 

                <field-type identifier="ArticleMediaAssetMapType.Res_Text100_01">

                 

                  <object-name>res_Text100_01</object-name>

                  <class-name>java.lang.String</class-name>

                  <persistence-class-name>java.lang.String</persistence-class-name>

                  <fragment-column-access>MediaAsset.Res_Text100_01</fragment-column-access>

                  <max-length>2000</max-length>

                </field-type>

                Add a corresponding ArticleMediaAssetMap field

                add a new field ArticleMediaAssetMap.Res_Text100_01

                 

                ArticleMediaAssetMap.Res_Text100_01 Expand source

                 

                Add a corresponding field for other objects

                Add such field under Product2GMediaAssetMap, and also under VariantMediaAssetMap if  3ppd is activated.

                It is similar to the ArticleMediaAssetMap.Res_Text100_01, e.g. a Product2GMediaAssetMap.Res_Text100_01 which has the same field type "ArticleMediaAssetMapType.Res_Text100_01".

                Complete map logic with code

                Set a NullPropertyMediator for the mapped field type

                 

                NullPropertyMediator for ArticleMediaAssetMapType.Res_Text100_01

                 

                 

                <extension

                 

                        point="com.heiler.ppm.persistence.server.persister"

                        ...

                        <propertyMediator

                            class="com.heiler.ppm.persistence.server.mediator.impl.NullPropertyMediator"

                            description="Null Property Mediator for ArticleMediaAssetMapType.Res_Text100_01"

                            fieldTypeIdentifier="ArticleMediaAssetMapType.Res_Text100_01"

                            id="hpm.article.AMAM.Res_Text100_01">

                        </propertyMediator>

                        ...

                </extension>

                Contribute own PropertyMediator to replace the standard one for the mapped MediaAssetProxy field

                 

                Property Mediator for ArticleMediaAssetMapType.MediaAssetProxy

                 

                 

                <extension

                 

                        point="com.heiler.ppm.persistence.server.persister"

                        ...

                        <propertyMediator

                            class="custom.mediaasset.core.mediator.CustomAMAMMediaAssetProxyPropertyMediator"

                            description="Custom Property Mediator for ArticleMediaAssetMapType.MediaAssetProxy"

                            fieldTypeIdentifier="ArticleMediaAssetMapType.MediaAssetProxy"

                            id="hpm.custom.article.AMAM.MediaAssetProxy"

                            target-id="hpm.article.AMAM.MediaAssetProxy">

                        </propertyMediator>

                        ...

                </extension>

                The contributed class CustomAMAMMediaAssetProxyPropertyMediator should implement the interface methods like following:

                • read( MediatorSession session, PropertyData propertyData ): extend the similar logic also for the reserved fields. As a rapid solution it can copy the code from AMAMMediaAssetProxyPropertyMediator and its super class EntityMAMMediaAssetProxyPropertyMediator, then call own JPQL(similar to the com.heiler.ppm.mediaasset.db.query.MediaAssetJPQL.QUERY_SEL_MEDIAASSET_FIELDS_BY_ID) to read the corresponding value for all standard fields and also for the reserved fields, and store them in the business object(see  EntityMAMMediaAssetProxyPropertyMediator.setMediaAssetFields(...)).
                • write( MediatorSession context, PropertyData propertyData, AttributeChange attributeChange ): same as the one of the standard AMAMMediaAssetProxyPropertyMediator, just copy it.

                Add a PropertyPostSetter to transfer the field change

                The field change should be transferred from mapped field type ArticleMediaAssetMapType.Res_Text100_01 to the field type MediaAssetType.Res_Text100_01.

                 

                PropertyPostSetter for ArticleMediaAssetMapType.Res_Text100_01

                 

                 

                <operator

                 

                        class="custom.mediaasset.core.command.CustomArticleMediaAssetMapPostSetter"

                        description="Mirrors the custom ArticleMediaAssetMap fields in the MediaAssetProxy"

                        id="CustomAMAMPostSetter"

                        name="CustomAMAMPostSetter"

                        type="PropertyPostSetter">    

                        ...

                        <repository-identifier

                               identifier="ArticleMediaAssetMapType.Res_Text100_01"

                               type="FIELD_TYPE">

                        </repository-identifier>

                        <target-command type="PutCommand"/>

                        ...

                </operator>

                The class CustomArticleMediaAssetMapPostSetter should be an implement of the interface PropertyPostSetter and transfer the field change from the mapped field type ArticleMediaAssetMapType.Res_Text100_01 to the MediaAsset field type MediaAssetType.Res_Text100_01. As a concrete example please visit the standard source code com.heiler.ppm.mediaasset.core.internal.command.ArticleMediaAssetMapPostSetter.

                 

                Thank you

                Sai Prasad

                2 of 2 people found this helpful
                • 5. Re: New field for Product-Medias
                  Markus Wurzinger Active Member

                  Hello Sai,

                   

                  thats the answer is was looking for. Thank you. Sadly i can not see all of the pictures in your post, because i don't have access to octa, but i think i now what to do.

                   

                  Thank you

                  Markus

                  • 6. Re: New field for Product-Medias
                    Sai Narasimha Prasad Rebba Guru

                    Sure Markus. Please try and let me know if you face any issue while working.

                     

                    Thank you!

                    Sai Prasad

                    • 7. Re: New field for Product-Medias
                      Daniel Molinski Guru

                      Hi Markus,

                       

                      Were you able to get this working?  We have the same requirement and getting stuck after the repository configuration.

                       

                      We can see, edit, and export the values on our new articlemediaassetmap fields, but cannot import values to them - which we need to be able to do.  I'm guessing this is why Sai is saying we need to complete map logic with code...

                      • 8. Re: New field for Product-Medias
                        Markus Wurzinger Active Member

                        Hi Daniel,

                         

                        to be honest we decided to not build a customizing for this. Our Field is only filled automatically by values from an other system, so we have teached our interface to first add the medias to the products and then write the additional information directly to the media -> "MediaAssetDocument.???"

                        That was the best and easiest way for us.