use of org.structr.core.entity.AbstractSchemaNode in project structr by structr.
the class StructrSchemaMethodPath method move.
@Override
public void move(final Path target, final CopyOption... options) throws IOException {
if (target instanceof StructrSchemaMethodPath) {
final App app = StructrApp.getInstance(fs.getSecurityContext());
final StructrSchemaMethodPath other = (StructrSchemaMethodPath) target;
final AbstractSchemaNode otherNode = other.getSchemaNode();
final SchemaMethod method = getSchemaMethodNode();
final String targetName = target.getFileName().toString();
try (final Tx tx = app.tx()) {
if (otherNode.getUuid().equals(schemaNode.getUuid())) {
// move from node to same node
method.setProperty(SchemaMethod.name, normalizeFileNameForJavaIdentifier(targetName));
method.setProperty(SchemaMethod.virtualFileName, targetName);
}
tx.success();
} catch (FrameworkException fex) {
logger.warn("", fex);
}
}
}
use of org.structr.core.entity.AbstractSchemaNode in project structr by structr.
the class StructrSchemaNodePath method getAttributes.
@Override
public <T extends BasicFileAttributes> T getAttributes(Class<T> type, LinkOption... options) throws IOException {
final AbstractSchemaNode schemaNode = getSchemaNode();
if (schemaNode != null) {
final App app = StructrApp.getInstance(fs.getSecurityContext());
String name = null;
try (final Tx tx = app.tx()) {
name = schemaNode.getName();
tx.success();
} catch (FrameworkException fex) {
logger.warn("", fex);
}
return (T) new StructrToplevelAttributes(name);
}
throw new NoSuchFileException(toString());
}
use of org.structr.core.entity.AbstractSchemaNode in project structr by structr.
the class StructrSchemaNodePath method getSchemaNode.
public AbstractSchemaNode getSchemaNode() {
if (cachedSchemaNode == null) {
final App app = StructrApp.getInstance(fs.getSecurityContext());
try (final Tx tx = app.tx()) {
// remove /files from path since it is a virtual directory
cachedSchemaNode = app.nodeQuery(AbstractSchemaNode.class).and(AbstractNode.name, name).getFirst();
tx.success();
} catch (FrameworkException fex) {
logger.warn("Unable to load actual file for path {}: {}", new Object[] { toString(), fex.getMessage() });
}
}
return cachedSchemaNode;
}
use of org.structr.core.entity.AbstractSchemaNode in project structr by structr.
the class StructrSchemaNodePath method getDirectoryStream.
@Override
public DirectoryStream<Path> getDirectoryStream(DirectoryStream.Filter<? super Path> filter) {
final AbstractSchemaNode schemaNode = getSchemaNode();
if (schemaNode != null) {
return new DirectoryStream() {
boolean closed = false;
@Override
public Iterator iterator() {
if (!closed) {
final List<StructrPath> children = new LinkedList<>();
// children.add(new StructrSchemaPropertiesPath(fs, StructrSchemaNodePath.this, schemaNode));
// children.add(new StructrSchemaViewsPath(fs, StructrSchemaNodePath.this, schemaNode));
children.add(new StructrSchemaMethodsPath(fs, StructrSchemaNodePath.this, schemaNode));
children.add(resolveStructrPath("extendsClass"));
return children.iterator();
}
return Collections.emptyIterator();
}
@Override
public void close() throws IOException {
closed = true;
}
};
}
return null;
}
use of org.structr.core.entity.AbstractSchemaNode in project structr by structr.
the class StructrSchemaViewPath method getSchemaNode.
public AbstractSchemaNode getSchemaNode() {
if (schemaNode == null) {
final App app = StructrApp.getInstance(fs.getSecurityContext());
try (final Tx tx = app.tx()) {
// remove /files from path since it is a virtual directory
schemaNode = app.nodeQuery(AbstractSchemaNode.class).and(AbstractNode.name, name).getFirst();
tx.success();
} catch (FrameworkException fex) {
logger.warn("Unable to load actual file for path {}: {}", new Object[] { toString(), fex.getMessage() });
}
}
return schemaNode;
}
Aggregations