Friday, November 23, 2012

Scheduler with ATG StartSQLRepository

I was struggling to identify that how can I reuse the components that used by startSQLRepository batch file to import data to a repository using an ATG scheduler. After doing so much of research I found that it is very simple.

ATG internally uses TemplateParser component to load the repository. This class file has several static methods, here our interest would be on runParser() method which accepts a String[] and PrintWriter object. The String[] should pass the exactly same arguments as StartSQLRepository command without -m. Instead of -m, we need to pass -configPath (you can get the configPath using this.getNucleus.getConfigPath(String serverName)).

Example

String[] args = new String[5];
args[0]="-repository";
args[1]=getRepository();
args[2]="-outputSQL";
args[3]="-configPath";
args[4]=configPath;

int temp = TemplateParser.runParser(args, new PrintWriter(System.out, true));

This works!

Reference - http://www.oracle.com/technetwork/indexes/documentation/atgwebcommerce-393465.html

Inconsistent datatypes: expected CHAR got NUMBER

Did you ever get the following exception while deploying projects in BCC especially in case of an automated load or bulk load using importRepository or startSQLRepository utilities?


CONTAINER:atg.deployment.manifest.ManifestException; SOURCE:atg.versionmanager.exceptions.VersionException: Unable to check in workspace testProject.
        at atg.deployment.loader.RepositoryDataLoader.addError(RepositoryDataLoader.java:2069)
        at atg.deployment.loader.RepositoryDataLoader.doImport(RepositoryDataLoader.java:2722)
        at atg.deployment.loader.RepositoryDataLoader.execute(RepositoryDataLoader.java:1529)
        at atg.deployment.loader.RepositoryDataLoader.main(RepositoryDataLoader.java:1484)
Caused by: atg.versionmanager.exceptions.VersionException: Unable to check in workspace gopicheckin5.
        at atg.versionmanager.impl.WorkspaceRepositoryImpl.checkInAll(WorkspaceRepositoryImpl.java:1166)
        at atg.deployment.loader.RepositoryDataLoader.checkIn(RepositoryDataLoader.java:2977)
        at atg.deployment.loader.RepositoryDataLoader.doImport(RepositoryDataLoader.java:2718)
        ... 2 more
Caused by: CONTAINER:atg.repository.RepositoryException; SOURCE:java.sql.SQLException: ORA-00932: inconsistent datatypes: expected CHAR got NUMBER

        at atg.adapter.version.VersionItemDescriptor.isAnyOutOfDate(VersionItemDescriptor.java:7288)
        at atg.adapter.version.VersionRepository.checkInInternalOptimized(VersionRepository.java:3188)
        at atg.adapter.version.VersionRepository.checkIn(VersionRepository.java:3120)
        at atg.versionmanager.impl.WorkspaceRepositoryImpl.checkInAll(WorkspaceRepositoryImpl.java:1143)
        ... 4 more
Caused by: java.sql.SQLException: ORA-00932: inconsistent datatypes: expected CHAR got NUMBER

If anybody got this error, I am sure that you must have spent lot of time to figuring out whats the issue, indeed I had spent lot of time :)

Anyway there is no direct mapping between the error message displayed on the logs and the actual issue. The error logs must be misguiding you to look into your DB logs since the error had thrown from the DB (SQLException).

So what is the actual issue here? It is very simple, most of the time you will get this error when the number of assets in the project is more than configured (Strange indeed, why can't ATG give a proper error message- no idea on that ).

To resolve this issue, we need to update the total asset allowed in the project using the below component.

/atg/epub/version/VersionManagerService.workspaceOptimizationThresholdAssetCount

Monday, October 15, 2012

How to Add Custom Repositories into Merchandising UI in ATG 10.x BCC


Upon releasing ATG 10, the ATG BCC has been changed from its predecessors drastically by adding Flex UI enhancements into it. Now by default you will be able to see the following repositories using Merchandising UI.
  • Catalog
  • Promotions and Coupons
  • Media

If you are adding any custom repository, then you need to edit it through Content Administration Project, but of course the UE is not that great.
Then how can we get our custom repository to Merchandising UE? Is there any way to do that?
Yes, there is a way. ATG documentation doesn’t talk about that, but as we know ATG BCC, everything is run by configuration XMLs and components; you need to spend some time and identify which file you have to modify.
The following configuration changes will help you to bring your custom repository into Merchandiser UI.
Check the /atg/remote/commerce/browse/MerchandisingBrowseHierarchy.xml available in the DCS-UI module.
This XML defines the Browse Hierarchy of the Merchandising UE. This will have a root element called <browse-hierarchy> and this will define a root called home
Home is nothing but another browse-item element and this will define other browse items coming under the Home.
Consider the below example, Home will have Catalog and Catalog will have Product etc.
Home à Catalog à Product à SKU.
If you want to add your Custom Repository under home, then you need to add a browse-item reference over here. Don’t forget that ATG’s XML-COMBINE method is applicable here as well.
<browse-item reference-id="MyCustom"/>
Ok, I have added a link to my repository under the Home link. What I need to do now, how my items will come over there.
Create a new browse-item called MyCustom(the name I have given under home page>
<browse-item id=" MyCustom"
    label-resource=" MyCustom"
    is-root="true"
    icon-resource=" ">
      <browse-item reference-id="MyCustomItem1"/>
      <browse-item reference-id="MyCustomItem2"/>
     
     </browse-item>
Create other browse-items for each of my items.
<browse-item id=" MyCustomItem1"
               label-resource=" MyCustomItem1"
               is-root="true"
               icon-resource=" ">
    <list-definition id="Item1" retriever="query" child-type="/test/MyCustom/ MyCustomRepository:MyCustomItem1">
      <retriever-parameter name="query" value="ALL"/>
    </list-definition>
  </browse-item>
<browse-item id=" MyCustomItem2"
               label-resource=" MyCustomItem2"
               is-root="true"
               icon-resource=" ">
    <list-definition id="Item1" retriever="query" child-type="/test/MyCustom/ MyCustomRepository:MyCustomItem2">
      <retriever-parameter name="query" value="ALL"/>
    </list-definition>
  </browse-item>
This will add your items into the browse view of Merchandising UI. If you want this in the Find view also, then you have to use another configuration XML file, i.e. \atg\remote\commerce\find\MerchandisingFindConfiguration.xml.
<find-configuration site-filtering="true">
   
    <asset-family id=" MyCustomItem1" site-filtering="false">
    <display-name-resource> MyCustomItem1</display-name-resource>
    <enable-default-query>true</enable-default-query>
    <enable-filter-as-you-type>true</enable-filter-as-you-type>
    <result-list page-size="500"/>
    <default-asset-type> MyCustomItem1</default-asset-type>
    <asset-type
      id=" MyCustomItem1"
      site-filtering="false">
      <enable-default-query>true</enable-default-query>
      <enable-filter-as-you-type>true</enable-filter-as-you-type>
      <repository-path="/test/MyCustom/ MyCustomRepository </repository-path>
      <repository-item-type> MyCustomItem1</repository-item-type>
    </asset-type>

  </asset-family>
</ find-configuration>
This will bring the MyCustomItem1 in you Find view of Merchandising UI.
Along with this, you may need to check the /atg/remote/commerce/toolbar/MerchandisingToolbar.xml for defining the scope etc. for your custom repository in Merchandising UE.

Friday, March 30, 2012

Merchandising Deployment and Derived Catalogs Issue

When your application is in a standalone mode, and you have configured your Publishing, Staging and Production servers, it is quite often that you will end up in a situation where the Products/SKUs are not getting displayed on the page because of 'no catalog found' issue.

I was facing this issue and identified that, CatalogMaintatenenceService (CMS) is responsible for deriving this relationship. This will happen based one how you have configured your CMS. If you have configured CMS to run immediately after deploying a project with Product Catalog changes then it will get derived and all goes well.

Sometimes you need to manually run the CMS. In that case you need to execute the CMS from the below location,

In your staging/production, go to dyn/admin

atg/commerce/catalog/custom/CatalogMaintenanceService and click on performMaintenence.

The below tables store the derived catalogs relation ship.

DCS_SKU_CATALOGS
DCS_PROD_CATALOGS.

cheers!

Refer - http://www.oracle.com/technetwork/indexes/documentation/atgwebcommerce-393465.html