Skip to content

Commit

Permalink
Fix issues with perspectives and naming in tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
PhantomYdn committed May 24, 2022
1 parent b97fac5 commit cbe6c7a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit cbe6c7a

Please sign in to comment.