use of org.pentaho.platform.api.repository2.unified.RepositoryFile in project pentaho-kettle by pentaho.
the class PurRepositoryMetaStore method createElementType.
// The element types
@Override
public void createElementType(String namespace, IMetaStoreElementType elementType) throws MetaStoreException {
RepositoryFile namespaceFile = validateNamespace(namespace);
IMetaStoreElementType existingType = getElementTypeByName(namespace, elementType.getName());
if (existingType != null) {
throw new MetaStoreElementTypeExistsException(Collections.singletonList(existingType), "Can not create element type with id '" + elementType.getId() + "' because it already exists");
}
RepositoryFile elementTypeFile = new RepositoryFile.Builder(elementType.getName()).folder(true).versioned(false).build();
RepositoryFile folder = pur.createFolder(namespaceFile.getId(), elementTypeFile, null);
elementType.setId(folder.getId().toString());
// In this folder there is a hidden file which contains the description
// and the other future properties of the element type
//
RepositoryFile detailsFile = new RepositoryFile.Builder(ELEMENT_TYPE_DETAILS_FILENAME).folder(false).title(ELEMENT_TYPE_DETAILS_FILENAME).description(elementType.getDescription()).hidden(true).build();
DataNode dataNode = getElementTypeDataNode(elementType);
pur.createFile(folder.getId(), detailsFile, new NodeRepositoryFileData(dataNode), null);
elementType.setMetaStoreName(getName());
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFile in project pentaho-kettle by pentaho.
the class PurRepositoryMetaStore method getElements.
@Override
public List<IMetaStoreElement> getElements(String namespace, IMetaStoreElementType elementType) throws MetaStoreException {
List<IMetaStoreElement> elements = new ArrayList<IMetaStoreElement>();
RepositoryFile typeFolder = validateElementTypeRepositoryFolder(namespace, elementType);
List<RepositoryFile> children = getChildren(typeFolder.getId());
removeHiddenFilesFromList(children);
for (RepositoryFile child : children) {
IMetaStoreElement element = getElement(namespace, elementType, child.getId().toString());
elements.add(element);
}
return elements;
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFile in project pentaho-kettle by pentaho.
the class PurRepositoryMetaStore method getMetaStoreFolders.
private String getMetaStoreFolders(StringBuilder builder, RepositoryFile folder, int level) {
String spaces = Const.rightPad(" ", level * 2);
builder.append(spaces);
if (folder.isFolder()) {
builder.append("/");
}
builder.append(folder.getName()).append(Const.CR);
for (RepositoryFile file : getChildren(folder.getId())) {
getMetaStoreFolders(builder, file, level + 1);
}
return builder.toString();
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFile in project pentaho-kettle by pentaho.
the class PurRepositoryMetaStore method getElementIds.
@Override
public List<String> getElementIds(String namespace, IMetaStoreElementType elementType) throws MetaStoreException {
RepositoryFile folder = validateElementTypeRepositoryFolder(namespace, elementType);
List<RepositoryFile> children = getChildren(folder.getId());
removeHiddenFilesFromList(children);
List<String> ids = new ArrayList<String>();
for (RepositoryFile child : children) {
ids.add(child.getId().toString());
}
return ids;
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFile in project pentaho-kettle by pentaho.
the class PurRepositoryMetaStore method createElement.
// The elements
public void createElement(String namespace, IMetaStoreElementType elementType, IMetaStoreElement element) throws MetaStoreException {
RepositoryFile elementTypeFolder = validateElementTypeRepositoryFolder(namespace, elementType);
RepositoryFile elementFile = new RepositoryFile.Builder(PurRepository.checkAndSanitize(element.getName())).title(element.getName()).versioned(false).build();
DataNode elementDataNode = new DataNode(PurRepository.checkAndSanitize(element.getName()));
elementToDataNode(element, elementDataNode);
RepositoryFile createdFile = pur.createFile(elementTypeFolder.getId(), elementFile, new NodeRepositoryFileData(elementDataNode), null);
element.setId(createdFile.getId().toString());
// Verify existence.
if (pur.getFileById(createdFile.getId()) == null) {
throw new RuntimeException("Unable to verify creation of element '" + element.getName() + "' in folder: " + elementTypeFolder.getPath());
}
}
Aggregations