Skip to content
Snippets Groups Projects

ENH: Add functions for File entities

Merged Florian Spreckelsen requested to merge f-file-entity into dev
All threads resolved!
3 files
+ 37
11
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 13
1
@@ -39,7 +39,7 @@ function _getRoleString(role) {
@@ -39,7 +39,7 @@ function _getRoleString(role) {
case roles.ENTITY_ROLE_FILE:
case roles.ENTITY_ROLE_FILE:
return "FILE";
return "FILE";
default:
default:
throw `Unknown role ${role}.`;
throw new Error(`Unknown role ${role}.`);
}
}
}
}
@@ -53,6 +53,14 @@ export class Entity {
@@ -53,6 +53,14 @@ export class Entity {
return this.wrappedEntity.getDescription();
return this.wrappedEntity.getDescription();
}
}
 
getFilePath() {
 
if (!this.isFile()) {
 
throw new Error(`Only FILE entities can have a file path.`);
 
}
 
const fileDescriptor = this.wrappedEntity.getFileDescriptor();
 
return fileDescriptor.getPath();
 
}
 
getId() {
getId() {
return this.wrappedEntity.getId();
return this.wrappedEntity.getId();
}
}
@@ -90,4 +98,8 @@ export class Entity {
@@ -90,4 +98,8 @@ export class Entity {
isRecord() {
isRecord() {
return this.wrappedEntity.getRole() === api.v1.EntityRole.ENTITY_ROLE_RECORD;
return this.wrappedEntity.getRole() === api.v1.EntityRole.ENTITY_ROLE_RECORD;
}
}
 
 
isFile() {
 
return this.wrappedEntity.getRole() === api.v1.EntityRole.ENTITY_ROLE_FILE;
 
}
}
}
Loading