Skip to content
Snippets Groups Projects
Commit ad6b46de authored by anttil's avatar anttil
Browse files

BIS-153 / SP-258: Disallow setting an entity a validation script meant for another entity kind.

SVN: 26454
parent f0cafb30
No related branches found
No related tags found
No related merge requests found
...@@ -82,7 +82,8 @@ public final class EntityTypeBO extends AbstractBusinessObject implements IEntit ...@@ -82,7 +82,8 @@ public final class EntityTypeBO extends AbstractBusinessObject implements IEntit
{ {
ScriptPE script = getScriptDAO() ScriptPE script = getScriptDAO()
.tryFindByName(entityType.getValidationScript().getName()); .tryFindByName(entityType.getValidationScript().getName());
if (script != null)
if (script != null && entityType.isEntityKind(script.getEntityKind()))
{ {
return script; return script;
} else } else
......
...@@ -97,4 +97,10 @@ public class DataSetType extends EntityType ...@@ -97,4 +97,10 @@ public class DataSetType extends EntityType
this.deletionDisallow = deletionDisallow; this.deletionDisallow = deletionDisallow;
} }
@Override
public boolean isEntityKind(EntityKind kind)
{
return kind == null || kind == EntityKind.DATA_SET;
}
} }
...@@ -68,4 +68,9 @@ abstract public class EntityType extends BasicEntityType ...@@ -68,4 +68,9 @@ abstract public class EntityType extends BasicEntityType
}); });
return etpts; return etpts;
} }
/**
* return true if this entity type is of given kind, or if the kind is null
*/
public abstract boolean isEntityKind(EntityKind kind);
} }
...@@ -40,4 +40,10 @@ public class ExperimentType extends EntityType ...@@ -40,4 +40,10 @@ public class ExperimentType extends EntityType
{ {
this.experimentTypePropertyTypes = experimentTypePropertyTypes; this.experimentTypePropertyTypes = experimentTypePropertyTypes;
} }
@Override
public boolean isEntityKind(EntityKind kind)
{
return kind == null || kind == EntityKind.EXPERIMENT;
}
} }
...@@ -53,4 +53,10 @@ public class MaterialType extends EntityType ...@@ -53,4 +53,10 @@ public class MaterialType extends EntityType
this.materialTypePropertyTypes = materialTypePropertyTypes; this.materialTypePropertyTypes = materialTypePropertyTypes;
} }
@Override
public boolean isEntityKind(EntityKind kind)
{
return kind == null || kind == EntityKind.MATERIAL;
}
} }
...@@ -260,4 +260,10 @@ public final class SampleType extends EntityType implements Serializable ...@@ -260,4 +260,10 @@ public final class SampleType extends EntityType implements Serializable
allPropertyTypes)); allPropertyTypes));
} }
@Override
public boolean isEntityKind(EntityKind kind)
{
return kind == null || kind == EntityKind.SAMPLE;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment