Skip to content
Snippets Groups Projects
Verified Commit 6eb95628 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Update changelog, introduce EXT_STATE_ENTITY server property

parent b9ed3d14
No related branches found
No related tags found
3 merge requests!21Release v0.4.0,!7F fsm,!6Draft: F acm permissions2
...@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
* New EntityState plug-in. The plug-in disabled by default and can be enabled
by setting the server property `EXT_ENTITY_STATE=ENABLED`. See
[!62](https://gitlab.com/caosdb/caosdb-server/-/merge_requests/62) for more
information.
* New server property `SERVER_SIDE_SCRIPTING_BIN_DIRS` which accepts a comma or * New server property `SERVER_SIDE_SCRIPTING_BIN_DIRS` which accepts a comma or
space separated list as values. The server looks for scripts in all space separated list as values. The server looks for scripts in all
directories in the order or the list and uses the first matching file. directories in the order or the list and uses the first matching file.
......
...@@ -13,10 +13,7 @@ import org.caosdb.server.transaction.WriteTransaction; ...@@ -13,10 +13,7 @@ import org.caosdb.server.transaction.WriteTransaction;
* *
* @author Timm Fitschen (t.fitschen@indiscale.com) * @author Timm Fitschen (t.fitschen@indiscale.com)
*/ */
@JobAnnotation( @JobAnnotation(time = JobExecutionTime.CHECK, transaction = WriteTransaction.class)
time = JobExecutionTime.CHECK,
transaction = WriteTransaction.class,
loadAlways = true)
public class CheckStateTransition extends EntityStateJob { public class CheckStateTransition extends EntityStateJob {
private static final Message TRANSITION_NOT_ALLOWED = private static final Message TRANSITION_NOT_ALLOWED =
......
...@@ -49,6 +49,8 @@ import org.jdom2.Element; ...@@ -49,6 +49,8 @@ import org.jdom2.Element;
*/ */
public abstract class EntityStateJob extends EntityJob { public abstract class EntityStateJob extends EntityJob {
protected static final String SERVER_PROPERTY_EXT_ENTITY_STATE = "EXT_ENTITY_STATE";
public static final String TO_STATE_PROPERTY_NAME = "to"; public static final String TO_STATE_PROPERTY_NAME = "to";
public static final String FROM_STATE_PROPERTY_NAME = "from"; public static final String FROM_STATE_PROPERTY_NAME = "from";
public static final String FINAL_STATE_PROPERTY_NAME = "final"; public static final String FINAL_STATE_PROPERTY_NAME = "final";
......
...@@ -3,6 +3,7 @@ package org.caosdb.server.jobs.core; ...@@ -3,6 +3,7 @@ package org.caosdb.server.jobs.core;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import org.caosdb.server.CaosDBServer;
import org.caosdb.server.entity.ClientMessage; import org.caosdb.server.entity.ClientMessage;
import org.caosdb.server.entity.Entity; import org.caosdb.server.entity.Entity;
import org.caosdb.server.entity.EntityInterface; import org.caosdb.server.entity.EntityInterface;
...@@ -35,8 +36,15 @@ public class InitEntityStateJobs extends EntityStateJob implements Observer { ...@@ -35,8 +36,15 @@ public class InitEntityStateJobs extends EntityStateJob implements Observer {
@Override @Override
protected void run() { protected void run() {
if ("ENABLED".equals(CaosDBServer.getServerProperty(SERVER_PROPERTY_EXT_ENTITY_STATE))) {
State newState = handleNewState(); State newState = handleNewState();
handleOldState(newState); State oldState = handleOldState(newState);
if (newState != null || oldState != null) {
appendJob(CheckStateTransition.class);
appendJob(MakeStateProperty.class);
appendJob(MakeStateMessage.class);
}
}
} }
/** /**
...@@ -49,12 +57,14 @@ public class InitEntityStateJobs extends EntityStateJob implements Observer { ...@@ -49,12 +57,14 @@ public class InitEntityStateJobs extends EntityStateJob implements Observer {
* that to happen and changes the {@EntityStatus} back to normal. * that to happen and changes the {@EntityStatus} back to normal.
* *
* @param newState * @param newState
* @return The old state or null.
*/ */
private void handleOldState(State newState) { private State handleOldState(State newState) {
State oldState = null;
try { try {
if (getEntity() instanceof UpdateEntity) { if (getEntity() instanceof UpdateEntity) {
List<State> states = initStateMessage(((UpdateEntity) getEntity()).getOriginal()); List<State> states = initStateMessage(((UpdateEntity) getEntity()).getOriginal());
State oldState = null; oldState = null;
if (states.size() == 1) { if (states.size() == 1) {
oldState = states.get(0); oldState = states.get(0);
} }
...@@ -65,12 +75,13 @@ public class InitEntityStateJobs extends EntityStateJob implements Observer { ...@@ -65,12 +75,13 @@ public class InitEntityStateJobs extends EntityStateJob implements Observer {
} catch (Message m) { } catch (Message m) {
getEntity().addWarning(STATE_ERROR_IN_ORIGINAL_ENTITY(m)); getEntity().addWarning(STATE_ERROR_IN_ORIGINAL_ENTITY(m));
} }
return oldState;
} }
/** /**
* Converts the state property of this entity into a state message. * Converts the state property of this entity into a state message.
* *
* @return The new state. * @return The new state or null.
*/ */
private State handleNewState() { private State handleNewState() {
State newState = null; State newState = null;
......
package org.caosdb.server.jobs.core; package org.caosdb.server.jobs.core;
import java.util.List; import java.util.List;
import org.caosdb.server.CaosDBServer;
import org.caosdb.server.entity.Message; import org.caosdb.server.entity.Message;
import org.caosdb.server.entity.wrapper.Property; import org.caosdb.server.entity.wrapper.Property;
import org.caosdb.server.jobs.JobAnnotation; import org.caosdb.server.jobs.JobAnnotation;
...@@ -16,11 +17,16 @@ import org.caosdb.server.transaction.Retrieve; ...@@ -16,11 +17,16 @@ import org.caosdb.server.transaction.Retrieve;
* *
* @author Timm Fitschen (t.fitschen@indiscale.com) * @author Timm Fitschen (t.fitschen@indiscale.com)
*/ */
@JobAnnotation(loadAlways = true, time = JobExecutionTime.POST_TRANSACTION) @JobAnnotation(
loadAlways = true,
transaction = Retrieve.class,
time = JobExecutionTime.POST_TRANSACTION)
public class MakeStateMessage extends EntityStateJob { public class MakeStateMessage extends EntityStateJob {
@Override @Override
protected void run() { protected void run() {
if ("ENABLED".equals(CaosDBServer.getServerProperty(SERVER_PROPERTY_EXT_ENTITY_STATE))) {
try { try {
// fetch all state properties and remove them from the entity (indicated by "true") // fetch all state properties and remove them from the entity (indicated by "true")
List<Property> stateProperties = getStateProperties(true); List<Property> stateProperties = getStateProperties(true);
...@@ -37,3 +43,4 @@ public class MakeStateMessage extends EntityStateJob { ...@@ -37,3 +43,4 @@ public class MakeStateMessage extends EntityStateJob {
} }
} }
} }
}
...@@ -5,10 +5,7 @@ import org.caosdb.server.jobs.JobAnnotation; ...@@ -5,10 +5,7 @@ import org.caosdb.server.jobs.JobAnnotation;
import org.caosdb.server.jobs.JobExecutionTime; import org.caosdb.server.jobs.JobExecutionTime;
import org.caosdb.server.transaction.WriteTransaction; import org.caosdb.server.transaction.WriteTransaction;
@JobAnnotation( @JobAnnotation(transaction = WriteTransaction.class, time = JobExecutionTime.PRE_TRANSACTION)
loadAlways = true,
transaction = WriteTransaction.class,
time = JobExecutionTime.PRE_TRANSACTION)
public class MakeStateProperty extends EntityStateJob { public class MakeStateProperty extends EntityStateJob {
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment