【发布时间】:2015-09-14 04:00:50
【问题描述】:
如何在 ATG 中创建具有特定字段(如名称 id 等)的自定义存储库。以及如何根据姓名ID或任何其他字段查询相同的信息。
【问题讨论】:
标签: atg atg-dynamo atg-droplet atg-dust
如何在 ATG 中创建具有特定字段(如名称 id 等)的自定义存储库。以及如何根据姓名ID或任何其他字段查询相同的信息。
【问题讨论】:
标签: atg atg-dynamo atg-droplet atg-dust
在配置中的某个路径(例如 /com/myproject/content/testRepository.xml)创建 testRepository.xml,其中包含所有自定义表的项目描述符。
在与 - 相同的路径下创建 testRepository.properties -
$class=atg.adapter.gsa.GSARepository $范围=全局 XMLToolsFactory=/atg/dynamo/service/xml/XMLToolsFactory dataSource=/atg/dynamo/service/jdbc/SwitchingDataSource 定义文件=/com/myproject/content/testRepository.xml groupContainerPath=/atg/registry/RepositoryGroups idGenerator=/atg/dynamo/service/IdGenerator lockManager=/atg/dynamo/service/ClientLockManager repositoryName=测试存储库 transactionManager=/atg/dynamo/transaction/TransactionManager
现在您可以在您的 droplet 或表单处理程序中将此组件称为 -
testRepository=/com/myproject/content/testRepository
在 java 中创建相同的 setter 和 getter。
现在您可以查询为 -
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; }
【讨论】: