Man*_*ngh 2 java tridion tridion-content-delivery tridion-2011 tridion-storage-extension
我正在尝试在Tridion 2011中编写存储扩展,我将在其中进行扩展JPAComponentPresentationDAO和实现ComponentPresentationDAO.
public void create(ComponentPresentation itemToCreate, ComponentPresentationTypeEnum componentPresentationType) throws StorageException
{
super.create(itemToCreate,componentPresentationType);
String tcmURI = Integer.toString(itemToCreate.getComponentId());
Component compObject // I want Component object to get the schema ID
PublishActionDAO publishActionDAO = (PublishActionDAO) StorageManagerFactory.getDefaultDAO("PublishAction");
PublishAction publishAction = new PublishAction();
publishAction.setAction("ADD");
publishAction.setTcmUri(tcmURI);
publishActionDAO.store(publishAction);
}
Run Code Online (Sandbox Code Playgroud)
在上面的示例代码中,我想itemToCreate.getComponentId()在我获取组件ID的地方使用Component对象,这样我就可以将一些有用的细节传递给我的实体类,该实体类将该数据存储在我的数据库表中.
您将能够获得ComponentMeta从ItemMeta继承的Schema Id .首先,你需要得到ItemDAO来自StorageManagerFactory然后findByPrimaryKey将给予ComponentMeta.这仅适用于super.create将组件持久保存到代理db之后.试试吧.
示例代码段:
ItemDAO item = (ItemDAO) StorageManagerFactory.getDAO(pubid,StorageTypeMapping.COMPONENT_META);
ComponentMeta meta = (ComponentMeta) item.findByPrimaryKey(pubid,compid);
int schemaID = meta.getSchemaId() ;
Run Code Online (Sandbox Code Playgroud)
注意:您需要从itemToCreate tcmURI传递pubid,compid