Reputation: 1
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.
Upvotes: 0
Views: 350
Reputation: 2472
Create testRepository.xml at some path in config (e.g. /com/myproject/content/testRepository.xml) having item descriptor with all custom table.
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
Now you can refer this component in your droplet or form handler as -
testRepository=/com/myproject/content/testRepository
create setter and getter for the same in java.
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; }
Upvotes: 1