本文整理汇总了Java中de.espirit.firstspirit.access.store.Store类的典型用法代码示例。如果您正苦于以下问题:Java Store类的具体用法?Java Store怎么用?Java Store使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Store类属于de.espirit.firstspirit.access.store包,在下文中一共展示了Store类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addToExportOperation
import de.espirit.firstspirit.access.store.Store; //导入依赖的package包/类
@Override
public void addToExportOperation(StoreAgent storeAgent, boolean useReleaseState, ExportOperation exportOperation) {
ContentStoreRoot store = (ContentStoreRoot) storeAgent.getStore(Store.Type.CONTENTSTORE, useReleaseState);
final Content2 content2 = store.getContent2ByName(uid);
if(content2 == null) {
throw new IllegalStateException("Content2 with uid '" + uid + "' couldn't be found.");
}
Schema schema = content2.getSchema();
if(schema == null) {
throw new IllegalStateException("Schema for content2 object with uid " + uid + " couldn't be found.");
}
final ExportOperation.SchemaOptions schemaOptions = exportOperation.addSchema(schema);
for (Dataset dataset : content2.getDatasets()) {
schemaOptions.addEntity(dataset.getEntity());
}
}
示例2: createProblem
import de.espirit.firstspirit.access.store.Store; //导入依赖的package包/类
private ImportOperation.Problem createProblem(final Store.Type storeType, final long nodeId, final String message) {
return new ImportOperation.Problem() {
@Override
public Store.Type getStoreType() {
return storeType;
}
@Override
public long getNodeId() {
return nodeId;
}
@Override
public String getMessage() {
return message;
}
};
}
示例3: testDeleteMediaStoreElement
import de.espirit.firstspirit.access.store.Store; //导入依赖的package包/类
@Test
public void testDeleteMediaStoreElement() {
when(store.getType()).thenReturn(Store.Type.MEDIASTORE);
Task task = mock(Task.class);
elementToBeDeleted = mock(Media.class);
when(elementToBeDeleted.getStore()).thenReturn(store);
workflowScriptContext = mock(WorkflowScriptContext.class);
when(workflowScriptContext.getWorkflowable()).thenReturn(null);
when(workflowScriptContext.getElement()).thenReturn(elementToBeDeleted);
when(workflowScriptContext.getTask()).thenReturn(task);
when(workflowScriptContext.is(BaseContext.Env.WEBEDIT)).thenReturn(Boolean.TRUE);
runDelete();
verify(workflowScriptContext, atLeastOnce()).is(BaseContext.Env.WEBEDIT);
//deletion of empty parent folder
verify(elementToBeDeleted, atLeastOnce()).getParent();
}
示例4: data
import de.espirit.firstspirit.access.store.Store; //导入依赖的package包/类
@Parameterized.Parameters(name = "{0}/execute:{2}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[]{Store.Type.PAGESTORE, mock(Page.class), Boolean.TRUE},
new Object[]{Store.Type.PAGESTORE, mock(PageFolder.class), Boolean.FALSE},
new Object[]{Store.Type.SITESTORE, mock(PageRef.class), Boolean.FALSE},
new Object[]{Store.Type.MEDIASTORE, mock(Media.class), Boolean.FALSE},
new Object[]{Store.Type.CONTENTSTORE, mock(Content2.class), Boolean.FALSE},
new Object[]{Store.Type.TEMPLATESTORE, mock(Template.class), Boolean.FALSE});
}
示例5: setUp
import de.espirit.firstspirit.access.store.Store; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
Connection connection = parameters.getConnection();
when(connection.getProjectByName(PROJECT)).thenReturn(project);
when(html.getUid()).thenReturn("html");
when(project.getUserService()).thenReturn(userService);
when(project.getTemplateSets()).thenReturn(Arrays.asList(html));
when(userService.getStore(anyObject(), eq(false))).then(new Answer<Store>() {
@Override
public Store answer(InvocationOnMock invocation) throws Throwable {
Store.Type storeType = (Store.Type) invocation.getArguments()[0];
switch (storeType){
case PAGESTORE:
return pageStore;
case SITESTORE:
return siteStore;
case TEMPLATESTORE:
when(templateStore.getFormatTemplates()).thenReturn(formatTemplates);
when(formatTemplates.createFormatTemplate(parameters.getName())).thenReturn(formatTemplate);
when(templateStore.getScripts()).thenReturn(scriptes);
when(scriptes.createScript(parameters.getName(), "")).thenReturn(script);
when(templateStore.getStoreElement(parameters.getName(),
IDProvider.UidType.TEMPLATESTORE_FORMATTEMPLATE)).thenReturn(formatTemplate);
when(templateStore.getStoreElement(parameters.getName(), IDProvider.UidType.TEMPLATESTORE)).thenReturn(template);
return templateStore;
}
return null;
}
});
}
示例6: setUp
import de.espirit.firstspirit.access.store.Store; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
fillZipWithContent();
final Connection connection = parameters.getConnection();
final String projectName = parameters.getProjectName();
when(connection.getProjectByName(projectName)).thenReturn(project);
when(project.getUserService()).thenReturn(userService);
when(userService.getStore(Store.Type.TEMPLATESTORE, false)).thenReturn(templateStoreRoot);
when(userService.getStore(Store.Type.MEDIASTORE, false)).thenReturn(mediaStoreRoot);
when(templateStoreRoot.getFormatTemplates()).thenReturn(formatTemplates);
when(templateStoreRoot.getPageTemplates()).thenReturn(pageTemplates);
when(templateStoreRoot.getLinkTemplates()).thenReturn(linkTemplates);
when(templateStoreRoot.getWorkflows()).thenReturn(workflows);
when(templateStoreRoot.getScripts()).thenReturn(scriptes);
when(mediaStoreRoot.getStore()).thenReturn(mediaStore);
when(formatTemplates.importStoreElements(any(ZipFile.class), any(ModuleImportHandler.class))).thenReturn(elements);
when(pageTemplates.importStoreElements(any(ZipFile.class), any(ModuleImportHandler.class))).thenReturn(elements);
when(linkTemplates.importStoreElements(any(ZipFile.class), any(ModuleImportHandler.class))).thenReturn(elements);
when(workflows.importStoreElements(any(ZipFile.class), any(ModuleImportHandler.class))).thenReturn(elements);
when(mediaStore.importStoreElements(any(ZipFile.class), any(ModuleImportHandler.class))).thenReturn(elements);
when(scriptes.importStoreElements(any(ZipFile.class), any(ModuleImportHandler.class))).thenReturn(elements);
when(elements.iterator()).thenReturn(Collections.emptyIterator());
}
示例7: exportCurrentState
import de.espirit.firstspirit.access.store.Store; //导入依赖的package包/类
@Test
public void exportCurrentState() throws Exception {
ExportCommand command = new ExportCommand();
command.setProject(PROJECT_NAME_WITH_DB);
initContextWithDefaultConfiguration(command);
// make some changes to page 'imprint' which is based on pagetemplate 'default' of integration test project
final Page page = (Page) command.getContext().requireSpecialist(StoreAgent.TYPE).getStore(Store.Type.PAGESTORE).getStoreElement("imprint", Page.UID_TYPE);
changeDisplayName(page, command.getContext().getProject().getMasterLanguage(), "new displayname");
command.addIdentifier("pagetemplate:default");
command.addIdentifier("page:imprint");
ExportResult result = command.call();
final File syncFolder = getFirstSpiritFileSyncFolder(testFolder.getRoot());
Assert.assertTrue("Export folder TemplateStore not found.", containsSubDirectory(syncFolder, "TemplateStore"));
Assert.assertTrue("Export folder PageStore not found.", containsSubDirectory(syncFolder, "PageStore"));
// check content of storeelement.xml
final Set<FileHandle> createdFiles = result.get().getCreatedFiles();
// search imprint storeelement.xml
FileHandle imprintStoreElementXmlFileHandle = null;
for (final FileHandle createdFile : createdFiles) {
if ("/PageStore/imprint_1/imprint/StoreElement.xml".equals(createdFile.getPath())) {
imprintStoreElementXmlFileHandle = createdFile;
break;
}
}
Assert.assertNotNull("imprint storeelement.xml should be created", imprintStoreElementXmlFileHandle);
// check content of StoreElement.xml --> should contain displayname of current state
final ByteArrayOutputStream bout = new ByteArrayOutputStream((int) imprintStoreElementXmlFileHandle.getSize());
IoUtil.copyStream(imprintStoreElementXmlFileHandle.load(), bout, true);
final String xmlContent = new String(bout.toByteArray(), "UTF-8");
Assert.assertTrue("displayname of currentstate missing", xmlContent.contains("new displayname"));
}
示例8: exportReleaseState
import de.espirit.firstspirit.access.store.Store; //导入依赖的package包/类
@Test
public void exportReleaseState() throws Exception {
ExportCommand command = new ExportCommand();
command.setProject(PROJECT_NAME_WITH_DB);
initContextWithDefaultConfiguration(command);
// make some changes to page 'imprint' which is based on pagetemplate 'default' of integration test project
final Page page = (Page) command.getContext().requireSpecialist(StoreAgent.TYPE).getStore(Store.Type.PAGESTORE).getStoreElement("imprint", Page.UID_TYPE);
changeDisplayName(page, command.getContext().getProject().getMasterLanguage(), "new displayname");
command.addIdentifier("pagetemplate:default");
command.addIdentifier("page:imprint");
command.setExportReleaseState(true);
ExportResult result = command.call();
final File syncFolder = getFirstSpiritFileSyncFolder(testFolder.getRoot());
Assert.assertTrue("Export folder TemplateStore not found.", containsSubDirectory(syncFolder, "TemplateStore"));
Assert.assertTrue("Export folder PageStore not found.", containsSubDirectory(syncFolder, "PageStore"));
// check content of storeelement.xml
final Set<FileHandle> createdFiles = result.get().getCreatedFiles();
// search imprint storeelement.xml
FileHandle imprintStoreElementXmlFileHandle = null;
for (final FileHandle createdFile : createdFiles) {
if ("/PageStore/imprint_1/imprint/StoreElement.xml".equals(createdFile.getPath())) {
imprintStoreElementXmlFileHandle = createdFile;
break;
}
}
Assert.assertNotNull("imprint storeelement.xml should be created", imprintStoreElementXmlFileHandle);
// check content of StoreElement.xml --> should contain displayname of current state
final ByteArrayOutputStream bout = new ByteArrayOutputStream((int) imprintStoreElementXmlFileHandle.getSize());
IoUtil.copyStream(imprintStoreElementXmlFileHandle.load(), bout, true);
final String xmlContent = new String(bout.toByteArray(), "UTF-8");
Assert.assertFalse("displayname of currentstate should not be available in export", xmlContent.contains("new displayname"));
}
示例9: createMediaElementAndExportItWithGivenUidMappingUidType
import de.espirit.firstspirit.access.store.Store; //导入依赖的package包/类
/**
* Mocks a MediaStore and adds a dummy object X of type Media to it. Afterwards creates an ExportOperation
* and adds an identifier matching X's uid to it, but uses the passed uidMappings uidType.
* @param uidMapping the mapping from which the uidType is retrieved that is used for adding an element to
* the export operation
* @return the created ExportOperation mock
*/
private ExportOperation createMediaElementAndExportItWithGivenUidMappingUidType(UidMapping uidMapping) {
String uidString = "reference_name";
UidIdentifier uid = new UidIdentifier(uidMapping, uidString);
StoreAgent storeAgent = mock(StoreAgent.class);
ExportOperation exportOperation = mock(ExportOperation.class);
Store mediaStoreRoot = mock(MediaStoreRoot.class);
Store.Type storeType = uidMapping.getStoreType();
when(storeAgent.getStore(storeType, false)).thenReturn(mediaStoreRoot);
IDProvider storeElement = mock(Media.class);
when(mediaStoreRoot.getStoreElement(uidString, uidMapping.getUidType())).thenReturn(storeElement);
uid.addToExportOperation(storeAgent, false, exportOperation);
return exportOperation;
}
示例10: testLogEmptyImportResult
import de.espirit.firstspirit.access.store.Store; //导入依赖的package包/类
@Test
public void testLogEmptyImportResult() throws Exception {
{
final MockLogger logger = new MockLogger(true);
final MockedStoreAgent storeAgent = new MockedStoreAgent();
storeAgent.addStore(Store.Type.PAGESTORE, new MockedStore(Store.Type.PAGESTORE));
AdvancedLogger.logImportResult(logger, null, new MockedImportResult(false));
// @formatter:off
final String expected =
"[INFO] Import done." + NEW_LINE +
"[INFO] == DETAILS ==" + NEW_LINE +
"[INFO] Created elements: 0" + NEW_LINE +
"[INFO] Updated elements: 0" + NEW_LINE +
"[INFO] Deleted elements: 0" + NEW_LINE +
"[INFO] Moved elements: 0" + NEW_LINE +
"[INFO] L&Found elements: 0" + NEW_LINE +
"[INFO] Problems: 0" + NEW_LINE +
"[INFO] == SUMMARY ==" + NEW_LINE +
"[INFO] Created elements: 0" + NEW_LINE +
"[INFO] Updated elements: 0" + NEW_LINE +
"[INFO] Deleted elements: 0" + NEW_LINE +
"[INFO] Moved elements: 0" + NEW_LINE +
"[INFO] L&Found elements: 0" + NEW_LINE +
"[INFO] Problems: 0" + NEW_LINE;
// @formatter:on
assertEquals("Result does not match.", expected, logger.toString());
}
}
示例11: getStore
import de.espirit.firstspirit.access.store.Store; //导入依赖的package包/类
@Override
public Store getStore(final Store.Type type) {
Store store = _stores.get(type);
if (store == null) {
store = new MockedStore(type);
addStore(type, store);
}
return store;
}
示例12: MockedElementExportInfo
import de.espirit.firstspirit.access.store.Store; //导入依赖的package包/类
MockedElementExportInfo(final Store.Type storeType, final String name, final String nodeTag, final ExportStatus exportStatus) {
super(Type.ELEMENT, name, exportStatus);
_basicElementInfo = new BasicElementInfoImpl(storeType, nodeTag, -1, name, -1);
setCreatedFileHandles(createFileHandleCollection(this, 1));
setUpdatedFileHandles(createFileHandleCollection(this, 2));
setDeletedFileHandles(createFileHandleCollection(this, 3));
setMovedFileHandles(createMovedFileHandleCollection(this, 4));
}
示例13: fillCollection
import de.espirit.firstspirit.access.store.Store; //导入依赖的package包/类
private void fillCollection(final Set<BasicElementInfo> set, final String description) {
set.add(createElementInfo(4, Store.Type.TEMPLATESTORE, TagNames.PAGETEMPLATES, description));
set.add(createElementInfo(3, Store.Type.MEDIASTORE, TagNames.MEDIUM, description));
set.add(createElementInfo(1, Store.Type.PAGESTORE, TagNames.PAGE, description));
set.add(createElementInfo(5, Store.Type.TEMPLATESTORE, TagNames.LINKTEMPLATE, description));
set.add(createElementInfo(2, Store.Type.MEDIASTORE, TagNames.MEDIUM, description));
set.add(createElementInfo(6, Store.Type.TEMPLATESTORE, TagNames.FORMATTEMPLATE, description));
set.add(createElementInfo(7, Store.Type.TEMPLATESTORE, TagNames.FORMATTEMPLATE, description));
}
示例14: MockedEntityTypeExportInfo
import de.espirit.firstspirit.access.store.Store; //导入依赖的package包/类
MockedEntityTypeExportInfo(final String entityType, final String schemaName, final int entityCount) {
super(Type.ENTITY_TYPE);
_entityType = entityType;
_schemaElementInfo = new BasicElementInfoImpl(Store.Type.TEMPLATESTORE, schemaName, -1, schemaName, -1);
_entities = new ArrayList<>();
for (int index = 0; index < entityCount; index++) {
_entities.add(new BasicEntityInfoImpl(UUID.nameUUIDFromBytes(("entity_" + index).getBytes()), entityType, schemaName));
}
setCreatedFileHandles(createFileHandleCollection(this, 1));
setUpdatedFileHandles(createFileHandleCollection(this, 2));
setDeletedFileHandles(createFileHandleCollection(this, 3));
setMovedFileHandles(createMovedFileHandleCollection(this, 4));
}
示例15: getContent2ObjectsForEntity
import de.espirit.firstspirit.access.store.Store; //导入依赖的package包/类
private Listable<Content2> getContent2ObjectsForEntity(final Entity entityFromReference) {
StoreAgent storeAgent = workflowScriptContext.requireSpecialist(StoreAgent.TYPE);
ContentStoreRoot contentStoreRoot = (ContentStoreRoot) storeAgent.getStore(Store.Type.CONTENTSTORE);
return contentStoreRoot.getChildren(new TypedFilter<Content2>(Content2.class) {
@Override
public boolean accept(Content2 storeElement) {
return (storeElement.getEntityType().equals(entityFromReference.getEntityType())) && storeElement.getEntity(entityFromReference.getKeyValue()) != null;
}
}, true);
}