Tuesday 4 November 2014

ATG Interview Questions

Interview Questions related to ATG :
Q)How to create Component?
A) we can create it in 2 ways,
I) using ACC
II)by creating java+properties file in our module/Eclipse

Q)how to create custom Repository?
a)we have to create component/properties file
$class=atg.adapter.gsa.GSARepository
$scope=global
XMLToolsFactory=/atg/dynamo/service/xml/XMLToolsFactory
dataSource=/atg/dynamo/service/jdbc/JTDataSource
definitionFiles=/com/my/myRepository.xml
idGenerator=/atg/dynamo/service/IdGenerator
transactionManager=/atg/dynamo/transaction/TransactionM
anager

Explanantion : have to tell all the properties in our component
Class is GSARepository OOTB it will do all oprations getitem, getiteforupdate

XMLToolsFactory : for parsing xml
definitionFiles : items info will keep here

idGenerator : for generating unique ids

transactionManager : for transation purpose either to commit or roll back i particular transaction/task

Q)How the module dependency happened in ATG ?
A)DAS DPS DSS DCS : from left to right
We maintained it in MANIFEST.MF file
Manifest-Version: 1.0
ATG-Config-Path: config/
ATG-Required: DAS DPS DSS DCS DAS
ATG-J2EE: j2ee-apps/testJ2ee
ATG-EAR-Module: j2ee-apps/testJ2ee
ATG-Class-Path: bin

Q)how the ATG will understand/initialize the components mean from which
path?
in MANIFEST.MF file we have to mention the ATG-Config-Path from here
ATG will pick the components and it will initialize.

Q)Scopes in ATG?
A) mainly we have 3 types of Scopes

1. Request

2. Session

3. Global

Global is the default scope

Every Nucleus component has a $scope property that controls the number of instances of the bean. You can specify scope (global, session, or request) when you create or edit a component 

Global :If a component has a global scope, there is one instance of the component for all users. (This means that the state of the component is the same for all users of the application.)

Session :If a component has a session scope, then every user gets a separate copy of the component that persists for the duration of that user's session. 

Request:If a component has a request scope, then simultaneous requests will each see a different copy of the component. This is true even if two requests from the same session come in at the same time.


Q)what is Nucleus?
A)first as component it will act then after its initialization over
it will act as Container to initialize all the components

Q)Differences between the item-type and Component-item-type in
definition(xml)file?
A)
i)When your property in the item-descriptor needs
to hold only one value which is of type of any other repository
item, use 'item-type=”item name”' attribute.

ii)when your property needs to hold a collection
(set/array/map/list) of items of type of any other repository item,
use data-type = "set/array/map/list" and
component-item-type=”another Item name” to specify what type each
one of the element in the collection

Ex : 

i)<item name=”student” >
        <propety name=”std name” item-type=”name” />
     </item>
<item name=”name”>
     <proeprty name=”student name”/>
</item>

ii)<item name=”student” >
    <propety name=”std classes” data-type=”set”component-item-type=”classes”/>
   </item>
  <item name=”classes”>
<proeprty name=”class name”/>
<proeprty name=”section name”/>
<proeprty name=”teachers name”/>
   </item>

Q)How connection will give from ATG module to DB
A)/atg/dynamo/service/jdbc/JTDataSource.properties
Using JTDataSource component will maintain the Schema/DB connection

Q)What are all the OOTB formhandlers you used in your application tell me 6?
A)mainly i used in my application level
i)CartModifierFormHandler
ii)PaymentGroupFormHandler
iii)ShippingGroupFormHandler
iv)CommitOrderFormHandler
v)GenericFormHandler
vi)ProfileFormHandler

Q)To write custom Droplet which OOTB class you will extend?
A) DynamoServlet we have to extend as a super class.

Q)How to write a Simple component not a droplet and from handler?
A)We have to write properties file and respective Java class.that class
will contain only fields and getters&setters,it should extends
GenericService

Q)How you will get a parameter in droplet which you give/assign it
in Jsp level.
A)by using getparameter() method

Q)which class will extend by every class in our ATG layer like object
class in Java.
A)here also Object class is the super most class, and every class will
extends GenericService

Q)How can i resolve/initialize a particular component with out
injecting in any component.
A)ATG provides one method resolveName(component name we have to provide)
in GenericService class using it we can initialse the componenet.


Q)What are all the input parameters for ForEach Droplet?
A)array,elementName,indexName....

Q)How we can achive Inheritence in ATG Repository level?
A)
sub-type-property="type"
super-type=”super item”

Ex : <item-descriptor name="shippingGroup" sub-type-property="type" />
<item-descriptor name="hardgoodShippingGroup" super-type="shippingGroup" />

Here hardgoodShippingGroup is the subitem(like class) shippingGroup is the super Item(class)
Hence all the features/properties of shippingGroup we can get it in hardgoodShippingGroup
item also.

Q)when or in which scenario i will go for ItemLookupDroplet?
A)to get complete item by providing id as a input parameter to that
droplet
ex : 
mylookup.properties
$class=atg.repository.servlet.ItemLookupDroplet
itemDescriptor=stdinfo
repository=/com/my/MyForm1Repository

Mylookup.jsp

<dsp:droplet name="/com/my/StudentLookUp">
       <dsp:param name="id" param="stdid"/>
               <dsp:param name="element" name="stdInfo"/>
                   <dsp:oparam name="output">
                             student id : <dsp:valueof param="element.stdid" />
                             student name : <dsp:valueof param="element.studentname" />
                  </dsp:oparam>
</dsp:droplet>

Here by passing id(studentid) as input parameter i am getting student
item(what ever i mentioned in component level
itemDescriptor=stdinfo)here stdinfo is an item which is having other
properties stdid and studentname.

Q)If i want to make one repository property as no Not Null what i have
to do?
A)To make it one property as a Not NULL in repository level i will
make it as required=true
ex:
<property name="textKey" column-name="text_key" data-type="string" required="true" />

Q)if i want to make a relation multi how many table i have to create
in repository level?
A)we have to make sure that, three tables are required
i)one is primary table
a)it will contain multi table
ii)reference for the multi table

ex :
<item-descriptor name="state">
    <table name="stateInfo" id-column-name="stateid" type="primary">
     <property name="stateid" column-name="STATE_ID"
    <property name="statename" column-name="STATE_NAME" data-type="String">
    </table>

    <table name="state_cities" id-column-name="stateid" type="multi">
     <property name="cities" column-name="CITIES" data-type="set" component-item-type="city"/>
   </table>

</item-descriptor>


<item-descriptor name="city" >
     <table name="cityInfo" id-column-name="cityid" type="primary">
        <property name="cityid" column-name="CITY_ID"   data-type="String"/>
       <property name="cityname" column-name="CITY_NAME" data-type="String"/>
    </table>
</item-descriptor>

Explanation : here i am doing state contain multiple cities,to achive
this i am using multi table concept by creating 3 table

Q)I created my repository but i am unable to see it in ACC/BCC to
create/modify/remove a particular item in my Repository,to achieve
this what i have to do?
A)in ContentRepositories.properties component we have to map/add our own custom repositor
to the property initialRepositories then only we can able to do see/create/update/remove
our items which are presented in our custom repository.

ex: ContentRepositories.properties
initialRepositories+=/com/myown/MyRepository,


Q)When Nucleus started/initialize that time i want to initialize some
of my custom components how we can do it?
in Initial.properties component we have to mention/map/add our custom component to
initialServices property
Ex : 
/atg/dynamo/Initial.properties
initialServices+=/atg/dynamo/service/ServerLockManager,\

Commerce Questions:
Q)when the order object will create?
A) when ever we calling ShoppingCart.current the will get current
order

Q)How to create our own/custom CommerceItem?
A)
Explanation : orderrepository.xml
Step 1
 have to customize in item in orderrepository.xml
<item-descriptor name="commerceItem" >
     <table name="my_commerce_item" type="auxiliary" id-column-         name="commerce_item_id">
            <property name="myproperty1" column-name="MYPROPERTY1" data-type=”String” />
            <property name="myproperty2" column-name="MYPROPERTY2"
data-type=”String” />
      </table>
<item-descriptor>

commerceItem item is there in OOTB level the same we are using but
we are creating auxiliary table(to add our custom properties) by giving
reference of OOTB primary table id using
id-column-name=commerce_item_id

Step2 : 
Mapping is required in /atg/commerce/order/OrderTools.properties

OrderTools.properties

beanNameToItemDescriptorMap+=com.common.commerce.order.MyCommerce
ItemImpl\=commerceItem
commerceItemTypeClassMap+=default\=com.common.commerce.order.MyCo
mmerceItemImpl

In OrderTools component we have to mapping item what ever we did in repository level with the JavaBean class.
beanNameToItemDescriptorMap : javaBean to ItemDescriptor mapping
commerceItemTypeClassMap : commerceItemType(commerceItem we did
in repository) to Class Mapping

Step3 :
 the JavaBean class what ever we created it must Extend the
CommerceItemImpl OOTB class

public class MyCommerceItemImpl extends CommerceItemImpl{
Fields(myproperty1,myproperty2) and respective getters/setters.
}

What ever the values we are setting to myproperty1,myproperty2 it will
set in CommerceItem level in order.

Step4 : How to set values to our custom CommerceItem
MyCartModifierFormHandler.java
             List<CommerceItem> commerceItems = order.getCommerceItems();
            for (CommerceItem commerceItem : commerceItems) {
                         if (commerceItem instanceof CommerceItemImpl){
                               commerceItemImpl = (MyCommerceItemImpl)commerceItem;
                               commerceItemImpl.setproperty(“myproperty1”,”some”);
                               commerceItemImpl.setproperty(“myproperty1”,”some”);
                         }
             }

Step5 : check the CommerceItem property in order level we will find
these two properties(in repository/DB level) also.
The same way we have to fallow for custom ConfigurableCommerceItem
and subSkuCommerceItem.

Q)Adding more items to CommerceItem is it possible?
A)No we can add only one type item(with more quantity) to order in
CommerceItem level, to achieve this mean add more items to order we
will go for ConfigurableCommerceItem concept instead of CommerceItem.

Q)How can i have to add an item as configurableCommerceItem to order?
A)have to call AddConfigurableItemToOrder() will use to add an item
to Order as a ConfigurableCommerceItem.
if you want to add an item as a commerceItem means will go for
AddItemToOrder() method in CartModifierFormHandler these methods are
available.

Q)How you can add subskuitem to order?
A)As a commerceItem we cant add more than one type of item,same type
of items we can add any number of items, but if we want to add different
type of items we have to go for ConfigurableCommerceItem.
For ConfigurableCommerceItem will add subskuitem.

EX :

 as a commerceItem :Computer(all peripherals from same vendor) is the CommerceItem
I can add to any number of items of type Computer
Ex: 

as a configurable commerce item :Computer(all peripherals from diff vendor) is the
ConfigurableCommerceItem,mean mouse is one item,keyboard is another
item(/Repository Item)
Code Snippet :

MyConfigurableCommerceItem configurableCommerceItem=MyConfigurableCommerceItem)
    getOrder.getCommerceItem(getconfigurableCommerceItemId());
    MySubSkuCommerceItem subSkuCommerceItem = (MySubSkuCommerceItem)
 getCommerceItemManager().createCommerceItem(“mousepointer”,“skuid”,null,”prod id”,null, “quantity”, null, null,null);

getCommerceItemManager().addSubItemToConfigurableItem(configurabl
eCommerceItem, subSkuCommerceItem);

Then the same configurable item will add to order by calling
AddConfigurableItemToOrder().

getconfigurableCommerceItemId() : will get it from jsp,by iterating
all commerceitems(mean we added configurableCommerceItem) from the
order level and will set it.

Q)How to add our own paymentGroup to order?
A)i will explain by taking GiftCard as a new PaymentMethod
Step1 : orderrepository.xml

<item-descriptor name="paymentGroup" xml-combine="append">
        <table name="dcspp_pay_group" type="primary">
        <property name="type" xml-combine="append" data-type="enumerated">
             <option value="giftCard" code="4" />
        </property>
        </table>
</item-descriptor>

<item-descriptor name="giftCard" super-type="paymentGroup" sub-type-value="giftCard">
         <table name="giftcardInfo" id-column-name="payment_group_id">
               <property name="giftcardNumber" column-name="gift_card_number"
                 display-name-resource="giftcardNumber" data-type="string"/>
               <property name="giftcardPin" column-name="gift_card_pin"
                display-name-resource="giftcardPin" data-type="string"/>
        </table>
</item-descriptor>

 Explanation : for the enumerated property of payment type i am adding one more
type using xml-combine="append",hence we added one more item of type
paymentGroup.
For that item/paymentgroup we added our required properties(numbr and
pin).

Step2 : OrderTools.proeprties
beanNameToItemDescriptorMap+=com.payment.GiftCard\=giftCard
paymentTypeClassMap+=\giftCard\=com.payment.GiftCard

Step3 : our custom payemnt method must extends PaymentGroupImpl

public class GiftCard extends PaymentGroupImpl{
public String mGiftcardNumber;
public String mGiftcardPin;
public String getGiftcardNumber() {
return (String) getPropertyValue("giftcardNumber");
} public void setGiftcardNumber(String pGiftcardNumber) {
setPropertyValue("giftcardNumber", pGiftcardNumber);
} public String getGiftcardPin() {
return (String) getPropertyValue("giftcardPin");
} public void setGiftcardPin(String pGiftcardPin) {
setPropertyValue("giftcardPin", pGiftcardPin);
}
}

PaymentGroupFormHandler.properties
MyPaymentGroupFormHandler.java
Maintain getters/setters for number and pin

handleGiftCardPayment(req,res){
        getPaymentGroupManager().removeEmptyPaymentGroups(getOrder());
        PaymentGroup paymentGroup =
                                        getPaymentGroupManager().createPaymentGroup("giftCard");
         paymentGroup.setPaymentMethod("giftCard");
        GiftCard giftcard = null;
         getPaymentGroupManager().addPaymentGroupToOrder(getOrder(), paymentGroup);
         List<PaymentGroup> paymentgroups = getOrder().getPaymentGroups();
                   for (PaymentGroup paymentGroup2 : paymentgroups) {
                            if(paymentGroup2 instanceof GiftCard){
                                   giftcard = (GiftCard) paymentGroup2;
                                   giftcard.setPropertyValue("giftcardNumber", getGiftcardNumber());
                                   giftcard.setPropertyValue("giftcardPin",getGiftcardPin());
                            }
                   }
     }


Mygiftcard.jsp

giftcardNumber:<dsp:inputbean="PaymentGroupFormHandler.giftcardNumber" type="text" />
giftCardPin:
<dsp:inputbean="PaymentGroupFormHandler.giftcardPin"/>
<dsp:inputbean="PaymentGroupFormHandler.giftCardPayment" type="submit"/>

Explanation : 
what ever we added(number and pin)in jsp as a input parameter we are setting to
PaymentGroupFormHandler,using getter method we get and setting into our payment
Method(giftcard),addPaymentGroupToOrder() using this method we are adding
custom payment method to Order.
The same way he have to fallow for adding custom Shipping Method also.


Q)Purchase process flow in ATG?
A)Home Page-->PDP Page--->Cart Page ---> shipping Page --> Payment Page --> Order View P Page --> Order Confirmation Page.


Q)What is CommerceItem?
A)CommerceItem is one of teh Repository Item in ATG,it will hold CatalogRefId,Quantity,PriceInfo,Auxiliary Data(ProdcutRef,CatalogRef,Product Id) of the item.

Q)What is Shipping Group?
A)ShippingGroup is one of the repository item(in Order Repository),it will hold the data Actual Ship Date,Description,Ship On Date,Shipping Group Class Type,Shipping Method, State,Submitted Date.

Mainly Contain,where the user want to ship the item what ever he purchased atg will maintain it in ShippingGroup.

Q)What is Payment Group?
Payment group is one of the repository Item in atg, it will hold data of Authorisation Status,Amount Credited||Debited||Authorised.

Q)How do you add an item to cart? 
Using addItemToOrder method of CartModifierFormHandler by passing catalogRefId, quantity and productId in the product details page. 

Q)How do you display items in the cart page? 
We will get the current order from the ShoppingCart component. We will pass the ShoppingCart.current.commerceItems to the ForEach droplet.

Q)How do you update the quantity of a commerce item in the cart page? 
we will call handleSetOrder method of CartModifierFormHandler to update the quantity


Q)How do u remove items from cart ? 
We will set the removalCommerceIds
To remove single item handleRemoveItemFromOrder method of CartModifierFormHandler.

Q)How do u proceed to checkout page? 
We will call to moveToPurchaseInfo method of the CartModifierFormHandler which will execute the moveToPurchaseInfo pipeline chain and check the order and commerce items and validates them.

Q)How do you set the shipping address to the order or shipping group?
 +We use the ShippingGroupDroplet to display all the available shipping addresses. 
+The ShipingGroupDroplet will get the available addresses from the Profile’s shipingAddress and secondaryAddresses properties.
 +Then the user will select the shippingAddress from the list. Then the selected address will be set the current shipping group by calling the handleApplyShippingGroups method of ShippingGroupFormHandler. 
+We can create a shipping group manually by using the ShippingGroupManager.createShippingGroup by passing the address. After that we call ShippingGroupManager.addShippingGroupToOrder method. +And we can get the available shippingGroup by order.getShippingGroups() 
The user will also select the shipping method and set to the shipping group such as NextDay , Two Day or Ground. 
+We will use AvailableShippingMethods droplet which fetches all the shipping methos names from the Shipping calculators. Each Shipping Calculator has a property called shiipingMethod.




No comments:

Post a Comment