다음은 DAO의 구성 요소 및 이진을 추적하는 샘플 코드입니다.
구성 요소 : 샘플 코드를 추가하는 방법과 동일하게 업데이트를 진행하고
@Component("JPAComponentDAOExtension")
@Scope("prototype")
public class JPAComponentDAOExtension extends JPAComponentPresentationDAO implements ComponentPresentationDAO
{
public JPAComponentDAOExtension(String storageId, EntityManagerFactory entityManagerFactory, String storageName)
{
super(storageId, entityManagerFactory, storageName);
}
public JPAComponentDAOExtension(String storageId, EntityManagerFactory entityManagerFactory, EntityManager entityManager, String storageName)
{
super(storageId, entityManagerFactory, entityManager, storageName);
}
public void create(ComponentPresentation itemToCreate, ComponentPresentationTypeEnum componentPresentationType) throws StorageException
{
super.create(itemToCreate,componentPresentationType);
String tcmURI = Integer.toString(itemToCreate.getComponentId());
ItemDAO item = (ItemDAO) StorageManagerFactory.getDAO(itemToCreate.getPublicationId(),StorageTypeMapping.COMPONENT_META);
ComponentMeta meta = (ComponentMeta) item.findByPrimaryKey(itemToCreate.getPublicationId(),itemToCreate.getComponentId());
String schemaID = Integer.toString(meta.getSchemaId()) ;
PublishActionDAO publishActionDAO = (PublishActionDAO) StorageManagerFactory.getDefaultDAO("PublishAction");
PublishAction publishAction = new PublishAction();
publishAction.setAction("ADD");
publishAction.setTcmUri(tcmURI);
publishAction.setSchemaID(schemaID);
publishActionDAO.store(publishAction);
}
}
진 삭제 : 샘플 코드 추가와 같은 업데이트를 진행하고
@Component("JPABinaryDAOExtension")
@Scope("prototype")
public class JPABinaryDAOExtension extends JPABinaryContentDAO implements BinaryContentDAO
{
public JPABinaryDAOExtension(String storageId, EntityManagerFactory entityManagerFactory, String storageName)
{
super(storageId, entityManagerFactory, storageName);
}
public JPABinaryDAOExtension(String storageId, EntityManagerFactory entityManagerFactory, EntityManager entityManager, String storageName)
{
super(storageId, entityManagerFactory, entityManager, storageName);
}
public void create(final BinaryContent binaryContent, final String relativePath) throws StorageException
{
super.create(binaryContent, relativePath);
String url = relativePath;
String tcmURI = Integer.toString(binaryContent.getBinaryId());
ItemDAO item = (ItemDAO) StorageManagerFactory.getDAO(binaryContent.getPublicationId(),StorageTypeMapping.BINARY_META);
BinaryMeta binarymeta = (BinaryMeta) item.findBinaryByPrimaryKey(binaryContent.getPublicationId(),binaryContent.getBinaryId());
binarymeta.getBinaryType();//to get the binary type
//You can also check the Relative path as below for specific binary type entries as suggested by Mihai
if (relativePath.toLowerCase().endsWith(".pdf")) //Looking for PDFs only
{
PublishActionDAO publishActionDAO = (PublishActionDAO) StorageManagerFactory.getDefaultDAO("PublishAction");
PublishAction publishAction = new PublishAction();
publishAction.setAction("ADD");
publishAction.setUrl(url);
publishAction.setTcmUri(tcmURI);
publishActionDAO.store(publishAction);
}
}
}
@Nuno을 삭제 .. 답변 감사합니다!! 목표는 이전에 ITEM 테이블에 사용자 정의 트리거를 사용하여 ITEM 테이블에 삽입/업데이트/삭제가있을 때마다 새로운 테이블 PUBLISH_ACTION을 업데이트하여 페이지, 컴포넌트 및 바이너리의 모든 항목을 가져 오는 것이 었습니다. 이것은 올바른 접근 방식으로 지원 계약을 망칠 수 없기 때문에 스토리지 확장을 사용하여 스토리지 확장을 이미 완료했습니다. 이제 DAO 클래스에 값을 추가하기 위해 전개자를 작성했습니다. PAGE가 완료되었습니다. 배포 및 배치 방법 모두, bianry 및 componentm에 대한 고민, 제발 sugest !! –
또한 JPAComponentPresentationDAO를 확장하고 ComponentPresentationDAO를 구현하여 구성 요소 추가/삭제/업데이트 작업을 수행하고 이러한 값을 저장소 확장을 사용하여 새 데이터베이스 테이블에 저장하는 JPAComponentDAOExtension과 같은 사용자 지정 저장소 확장 클래스를 만들 수 있습니까? –