2

2011 년 Tridion 2011에 저장소 확장을 쓰려고하는데 JPAComponentPresentationDAO을 확장하고 ComponentPresentationDAO을 구현합니다. 위의 예제 코드에서 Component 프레젠테이션 저장소 확장에 Component 개체를 얻는 방법

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); 
} 

나는 내 데이터베이스 테이블에 데이터를 저장할 내 엔티티 클래스에 유용한 내용을 전달할 수 있도록 내가, 구성 요소 ID를 얻을 수 itemToCreate.getComponentId()를 사용하여 구성 요소 개체를 만들고 싶어.

+0

에서 compid 게시자 ID를 통과해야합니다. 이 코드 내에서'Component's에 대한 DAO를 얻는 방법을 알고 싶습니까? –

+0

예, actullay 게시 된 게시되지 않은 구성 요소의 스키마 ID를 얻을 수 있도록 여기에 Component 객체를 가져 오려고 구성 요소 게시 및 게시 취소를 처리하려고합니다. –

답변

6

ItemMeta에서 상속 된 ComponentMeta에서 스키마 ID를 가져올 수 있습니다. 먼저 에서 ItemDAO을 가져온 다음 을 ComponentMeta에 제공해야합니다. 이것은 브로커 db에 구성 요소를 유지해야하는 super.create 이후에만 작동합니다. 이것을 시험해보십시오.

샘플 조각 :

ItemDAO item = (ItemDAO) StorageManagerFactory.getDAO(pubid,StorageTypeMapping.COMPONENT_META); 
ComponentMeta meta = (ComponentMeta) item.findByPrimaryKey(pubid,compid); 
int schemaID = meta.getSchemaId() ; 

참고 : 당신이 요구하는지 조금 불분명 당신 itemToCreate tcmURI

+0

@Ram ... JPAComponentPresentationDAO를 확장하려고합니다. 추가/삭제/구성 요소의 업데이트는이를 확장 할 때 관리 할 수 ​​있습니까? 아니면 다른 클래스를 확장해야합니까? –