Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SO-1974 extension terminology selector #103

Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
427fca5
SO-1974 added deprecated annotation
Jun 8, 2016
318c1ef
SO-1974 added comparator for ICodeSystem
Jun 8, 2016
dac97fd
SO-1974 added predicate for selecting active code systems
Jun 10, 2016
bad83b6
SO-1974 initialization for terminology extension preferences
Jun 10, 2016
ebfe47f
SO-1974 moved preference related class to its own package
Jun 10, 2016
1597fc9
SO-1974 clients of code moving
Jun 10, 2016
8280ec7
SO-1974 exporting new package
Jun 10, 2016
8803c54
SO-1974 added POJO for extension selection pref page persistance
Jun 10, 2016
0e9c653
SO-1974 added some util predicates / functions to CodeSystemUtils
Jun 13, 2016
b6b8d9a
SO-1974 static util method for code system guava functional classes
Jun 13, 2016
f86b3d7
SO-1974 replacing anonymous inner class function
Jun 13, 2016
c86c74e
SO-1974 added util method: trying to find a branchPath's version path
Jun 13, 2016
d91cfbe
SO-1974 default extensions preference file added
Jun 14, 2016
ee7e9f9
SO-1974 compile error fix
Jun 14, 2016
faad38b
SO-1974 removing author tags from classes
Jun 15, 2016
130b9f1
SO-1974 remove extensions.xml from server side defaults
Jun 15, 2016
4840e74
SO-1974 moved guavafunctionals to interface for the sake of singletoness
Jun 15, 2016
b96529f
SO-1974 removed overcompliacted guava functional
Jun 15, 2016
56b718c
SO-1974 made field private
Jun 15, 2016
52b350f
SO-1974 ICodeSystem to IBranchPath convenience function
Jun 15, 2016
864aded
SO-1974 moved TerminologyExtensionsBootstrapFragment to UI plugin
Jun 15, 2016
6ab4c58
SO-1974 removing unnecessary preference pojo
Jun 16, 2016
5d03888
SO-1974 terminology extension: preference persistence change
Jun 16, 2016
a89f417
SO-1974 removed method
Jun 16, 2016
92c57f3
SO-1974 moved TerminologyExtensionConfiguration class to client side
Jun 16, 2016
1d594ba
SO-1974 updated manifest after class moving
Jun 16, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
SO-1974 added predicate for selecting active code systems
  • Loading branch information
Endre Kovacs committed Jun 10, 2016
commit dac97fdde634f7be9b022fe1f9b09115b48d2807
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
import com.b2international.snowowl.datastore.cdo.ICDOConnection;
import com.b2international.snowowl.datastore.cdo.ICDOConnectionManager;
import com.b2international.snowowl.datastore.cdo.ICDOManagedItem;
import com.b2international.snowowl.datastore.tasks.TaskManager;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
Expand All @@ -46,6 +48,50 @@
public class CodeSystemUtils {

private static final Logger LOGGER = LoggerFactory.getLogger(CodeSystemUtils.class);

/**
* Predicate for selecting those {@link ICodeSystem}s:
* <li/> that are residing in the repository denoted by the given repositoryUuid
* <li/> whose branch path matches the active branch's path.
*
* Note: if the active branch is a task branch, this predicate will ignore the last segment (task id part) of the active branch path.
* @author endre
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No author tags in the snow-owl repository.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

*/
private static final class ActiveCodeSystemPredicate implements Predicate<ICodeSystem> {

private final IBranchPathMap branchPathMap;
private final String repositoryUuid;

private ActiveCodeSystemPredicate(IBranchPathMap branchPathMap, String repositoryUuid) {
this.branchPathMap = branchPathMap;
this.repositoryUuid = repositoryUuid;
}

@Override
public boolean apply(ICodeSystem input) {
IBranchPath activeBranchPath = branchPathMap.getBranchPath(repositoryUuid);
//ignore last segment if we are on a task branch
if (getServiceForClass(TaskManager.class).hasActiveTask())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This predicate might work correctly only on the client side, please move it to there.

return activeBranchPath.getParentPath().equals(input.getBranchPath());

return activeBranchPath.getPath().equals(input.getBranchPath());
}
}

private static final class SameRepositoryCodeSystemPredicate implements Predicate<ICodeSystem> {

private final String repositoryUUID;

private SameRepositoryCodeSystemPredicate(String repositoryUUID) {
this.repositoryUUID = Preconditions.checkNotNull(repositoryUUID, "repository UUID cannot be null");
}

@Override
public boolean apply(ICodeSystem input) {
return input.getRepositoryUuid().equals(repositoryUUID);
}
}


private static final LoadingCache<String, ICDOManagedItem<?>> TOOLING_ID_MANAGED_ITEM_CACHE = CacheBuilder.newBuilder().build(new CacheLoader<String, ICDOManagedItem<?>>() {
@Override public ICDOManagedItem<?> load(final String toolingId) throws Exception {
Expand Down Expand Up @@ -170,6 +216,14 @@ public static String getSnowOwlToolingId(final String repositoryUuid) {
return getConnection(repositoryUuid).getSnowOwlTerminologyComponentId();
}

public static Predicate<ICodeSystem> sameRepositoryCodeSystemPredicate(final String repositoryUUID) {
return new SameRepositoryCodeSystemPredicate(repositoryUUID);
}

public static Predicate<ICodeSystem> activeCodeSystemPredicate(final IBranchPathMap branchPathMap, final String repositoryUuid) {
return new ActiveCodeSystemPredicate(branchPathMap, repositoryUuid);
}

/*returns with the connection for the given repository UUID*/
private static ICDOConnection getConnection(final String repositoryUuid) {
return getConnectionManager().getByUuid(repositoryUuid);
Expand Down