@@ -0,0 +1,2738 @@
+/*%0A * Copyright 2018 B2i Healthcare Pte Ltd, http://b2i.sg%0A * %0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.b2international.snowowl.snomed.reasoner.classification;%0A%0Aimport java.util.Objects;%0A%0Aimport org.eclipse.core.runtime.jobs.ISchedulingRule;%0A%0Aimport com.b2international.snowowl.datastore.remotejobs.SerializableSchedulingRule;%0A%0A/**%0A * @since 7.0%0A */%0Apublic final class ClassificationSchedulingRule implements SerializableSchedulingRule %7B%0A%0A%09private static int nextId = 0;%0A%0A%09private final int id;%0A%09private final String repositoryId;%0A%09private final String branch;%0A%0A%09public static ClassificationSchedulingRule create(final int concurrentClassifications, final String repositoryId, final String branch) %7B%0A%09%09return new ClassificationSchedulingRule((++nextId %25 concurrentClassifications), repositoryId, branch);%0A%09%7D%0A%0A%09private ClassificationSchedulingRule(final int id, final String repositoryId, final String branch) %7B%0A%09%09this.id = id;%0A%09%09this.repositoryId = repositoryId;%0A%09%09this.branch = branch;%0A%09%7D%0A%0A%09@Override%0A%09public boolean contains(final ISchedulingRule rule) %7B%0A%09%09return equals(rule);%0A%09%7D%0A%0A%09@Override%0A%09public boolean isConflicting(final ISchedulingRule rule) %7B%0A%09%09if (getClass() != rule.getClass()) %7B return false; %7D%0A%09%09final ClassificationSchedulingRule other = (ClassificationSchedulingRule) rule;%0A%0A%09%09// If the IDs are the same, the number of concurrent classifications limit has been reached%0A%09%09if (id == other.id) %7B return true; %7D%0A%0A%09%09// Otherwise, both branch and repositoryId must match for a conflict%0A%09%09if (!Objects.equals(branch, other.branch)) %7B return false; %7D%0A%09%09if (!Objects.equals(repositoryId, other.repositoryId)) %7B return false; %7D%0A%0A%09%09return true;%0A%09%7D%0A%0A%09@Override%0A%09public int hashCode() %7B%0A%09%09return Objects.hash(id, branch, repositoryId);%0A%09%7D%0A%0A%09@Override%0A%09public boolean equals(final Object obj) %7B%0A%09%09if (this == obj) %7B return true; %7D%0A%09%09if (obj == null) %7B return false; %7D%0A%09%09if (getClass() != obj.getClass()) %7B return false; %7D%0A%0A%09%09final ClassificationSchedulingRule other = (ClassificationSchedulingRule) obj;%0A%09%09if (id != other.id) %7B return false; %7D%0A%09%09if (!Objects.equals(branch, other.branch)) %7B return false; %7D%0A%09%09if (!Objects.equals(repositoryId, other.repositoryId)) %7B return false; %7D%0A%0A%09%09return true;%0A%09%7D%0A%7D%0A

Add scheduling rule implementation for classification jobs