...
 
......@@ -9,6 +9,7 @@ import java.util.Map.Entry;
import java.util.Properties;
import org.apache.log4j.Logger;
import org.ihtsdo.otf.refset.DefinitionClause;
import org.ihtsdo.otf.refset.Project;
import org.ihtsdo.otf.refset.Refset;
import org.ihtsdo.otf.refset.Translation;
......@@ -83,6 +84,7 @@ public class ValidationServiceJpa extends RootServiceJpa implements
result.merge(validationHandlersMap.get(key).validate(concept, service));
}
}
return result;
}
......@@ -127,7 +129,19 @@ public class ValidationServiceJpa extends RootServiceJpa implements
result.merge(validationHandlersMap.get(key).validate(refset, service));
}
}
// service.close();
if (refset.getDefinitionClauses() != null && refset.getDefinitionClauses().size() > 0) {
for (DefinitionClause definition : refset.getDefinitionClauses()) {
int ct = service.countExpression(project, refset.getTerminology(),
refset.getVersion(), definition.getValue());
if (ct > 40000) {
result.addError("Definition clause " + definition.getValue() + " resolves to more than 40000 results: " +
" This tool cannot manage refsets of that size reliably. Please revise your definition clause.");
} else if (ct > 20000) {
result.addWarning("Definition clause " + definition.getValue() + " resolves to more than 20000 results: " +
" Continuing with " + ct + " members may make the user experience inconsistent or unusable.");
}
}
}
return result;
}
......
......@@ -67,7 +67,7 @@
 
<i ng-show="value == 'ASSIGNED' && isWarning(clause.value)"
uib-tooltip="{{warnings[clause.value]}}"
class="noul material-icons md-18">info_outline</i>
class="noul material-icons md-18" style="color: red;">info_outline</i>
</td>
</tr>
<tr ng-show="value == 'ASSIGNED'">
......
......@@ -1239,9 +1239,13 @@ tsApp
// Success - count expression
function(data) {
var count = data;
if (count >= 20000) {
if (count >= 40000) {
$scope.errors[0] = 'Submitted definition clause is invalid. Definition clause resolves to '
+ count + ' members. Refsets of this size are not allowed as they can lead to an inconsistent user experience.';
return;
} else if (count >= 20000) {
$scope.warnings[$scope.newClauses[i].value] = 'Definition clause resolves to '
+ count + ' members.';
+ count + ' members. Refsets of this size are discouraged and can lead to an inconsistent user experience.';
$scope.warningFlag = true;
}
},
......@@ -1291,9 +1295,13 @@ tsApp
// Success - count expression
function(data) {
var count = data;
if (count >= 20000) {
if (count >= 40000) {
$scope.errors[0] = 'Submitted definition clause is invalid. Definition clause resolves to '
+ count + ' members. Refsets of this size are not allowed as they can lead to an inconsistent user experience.';
return;
} else if (count >= 20000) {
$scope.warnings[$scope.newClauses[i].value] = 'Definition clause resolves to '
+ count + ' members.';
+ count + ' members. Refsets of this size are discouraged and can lead to an inconsistent user experience.';
$scope.warningFlag = true;
}
},
......@@ -1314,6 +1322,11 @@ tsApp
// Save refset
$scope.save = function(refset) {
if ($scope.errors.length > 0) {
$uibModalInstance.close(refset);
handleError($scope.errors, $scope.errors[0]);
return;
}
refset.definitionClauses = $scope.newClauses;
$scope.warnings = [];
refsetService.updateRefset(refset).then(
......