diff --git a/orienteer-core/src/main/java/org/orienteer/core/module/PerspectivesModule.java b/orienteer-core/src/main/java/org/orienteer/core/module/PerspectivesModule.java index c946ea7f..27b47136 100644 --- a/orienteer-core/src/main/java/org/orienteer/core/module/PerspectivesModule.java +++ b/orienteer-core/src/main/java/org/orienteer/core/module/PerspectivesModule.java @@ -219,16 +219,17 @@ public ODocument getDefaultPerspective(OSecurityUser user) { } public ODocument getPerspectiveForORole(OSecurityRole role) { - if (role == null) { + ODocument roleDoc = role.getDocument(); + if (roleDoc==null) { return null; } - if (role.getDocument().field(PROP_PERSPECTIVE) != null) { - return ((OIdentifiable) role.getDocument().field(PROP_PERSPECTIVE)).getRecord(); + if (roleDoc.field(PROP_PERSPECTIVE) != null) { + return ((OIdentifiable) roleDoc.field(PROP_PERSPECTIVE)).getRecord(); } OSecurityRole parentRole = role.getParentRole(); - return parentRole != null && !parentRole.equals(role) ? getPerspectiveForORole(role) : null; + return parentRole != null && !parentRole.equals(role) ? getPerspectiveForORole(parentRole) : null; } public void updateUserPerspective(ODocument user, ODocument perspective) { diff --git a/orienteer-core/src/main/java/org/orienteer/core/module/TaskManagerModule.java b/orienteer-core/src/main/java/org/orienteer/core/module/TaskManagerModule.java index 97aa01e0..88efbe00 100644 --- a/orienteer-core/src/main/java/org/orienteer/core/module/TaskManagerModule.java +++ b/orienteer-core/src/main/java/org/orienteer/core/module/TaskManagerModule.java @@ -11,6 +11,8 @@ import org.orienteer.core.util.OSchemaHelper; import com.orientechnologies.orient.core.db.ODatabaseSession; +import com.orientechnologies.orient.core.metadata.schema.OClass; +import com.orientechnologies.orient.core.metadata.schema.OProperty; import com.orientechnologies.orient.core.metadata.schema.OSchema; import com.orientechnologies.orient.core.metadata.schema.OType; import com.orientechnologies.orient.core.record.impl.ODocument; @@ -22,7 +24,7 @@ public class TaskManagerModule extends AbstractOrienteerModule { public static final String NAME = "task-manager"; - public static final int VERSION = 3; + public static final int VERSION = 4; TaskManagerModule(){ super(NAME, VERSION); @@ -44,5 +46,15 @@ public void onUpdate(OrienteerWebApplication app, ODatabaseSession db, if(schema.getClass("OConsoleTaskSession")!=null) schema.dropClass("OConsoleTaskSession"); } onInstall(app, db); + if(oldVersion<=4) { + OSchema schema = db.getMetadata().getSchema(); + OClass taskSessionClass = schema.getClass(IOTaskSessionPersisted.CLASS_NAME); + OProperty toDelete = taskSessionClass.getProperty("isStopable"); + OProperty toKeep = taskSessionClass.getProperty("stopable"); + if(toDelete!=null && toKeep!=null) { + db.execute("sql", "update "+IOTaskSessionPersisted.CLASS_NAME+" set stopable = isStopable").close(); + taskSessionClass.dropProperty("isStopable"); + } + } } } diff --git a/orienteer-core/src/main/java/org/orienteer/core/tasks/IOTaskSessionPersisted.java b/orienteer-core/src/main/java/org/orienteer/core/tasks/IOTaskSessionPersisted.java index b7789d63..02b6992d 100644 --- a/orienteer-core/src/main/java/org/orienteer/core/tasks/IOTaskSessionPersisted.java +++ b/orienteer-core/src/main/java/org/orienteer/core/tasks/IOTaskSessionPersisted.java @@ -83,7 +83,6 @@ public interface IOTaskSessionPersisted extends ITaskSession, IODocumentWrapper @OrientDBProperty(notNull = false) public IOTaskSessionPersisted setFinalProgress(double value); - @EntityProperty("isStoppable") @OrientDBProperty(notNull = false) @DefaultValue("false") public boolean isStopable(); @@ -115,7 +114,7 @@ public default IOTaskSessionPersisted appendOutput(String add) { public default IOTaskSessionPersisted appendError(String add) { String error = getError(); - setOutput(error!=null?error+"\n"+add:add); + setError(error!=null?error+"\n"+add:add); return this; }