ATG customized repository

351 views Asked by At

How to create a customized repository in ATG with certain fields like name id and so on. And how to query the same information according to name ID or any other fields.

1

There are 1 answers

0
Saurabh On
  1. Create testRepository.xml at some path in config (e.g. /com/myproject/content/testRepository.xml) having item descriptor with all custom table.

  2. Create testRepository.properties at same path as -

$class=atg.adapter.gsa.GSARepository $scope=global XMLToolsFactory=/atg/dynamo/service/xml/XMLToolsFactory dataSource=/atg/dynamo/service/jdbc/SwitchingDataSource definitionFiles=/com/myproject/content/testRepository.xml groupContainerPath=/atg/registry/RepositoryGroups idGenerator=/atg/dynamo/service/IdGenerator lockManager=/atg/dynamo/service/ClientLockManager repositoryName=Test Repository transactionManager=/atg/dynamo/transaction/TransactionManager

  1. Now you can refer this component in your droplet or form handler as -

    testRepository=/com/myproject/content/testRepository

  2. create setter and getter for the same in java.

  3. Now you can query as -

private RepositoryItem[] getMyTestItems() {
RepositoryItem[] testItems = null;
try {
RepositoryView repView = getTestRepository().getView("myItemDescriptor");
RqlStatement statement = getRqlQuery(); //your query that can be defined in property file
Object params[] = new Object[1];
params[0] = "anyParam";

testItems = statement.executeQuery(repView, params);
} catch (RepositoryException ex) {
vlogDebug("testItems{0} ", ex);
} finally {
LoadingStrategyContext.popLoadStrategy();
}
return testItems;
}