-
Notifications
You must be signed in to change notification settings - Fork 27
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
ekovacs
merged 26 commits into
SO-1972-terminology-registry-dialog-additions
from
SO-1974-extension-terminology-selector
Jun 16, 2016
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
318c1ef
SO-1974 added comparator for ICodeSystem
dac97fd
SO-1974 added predicate for selecting active code systems
bad83b6
SO-1974 initialization for terminology extension preferences
ebfe47f
SO-1974 moved preference related class to its own package
1597fc9
SO-1974 clients of code moving
8280ec7
SO-1974 exporting new package
8803c54
SO-1974 added POJO for extension selection pref page persistance
0e9c653
SO-1974 added some util predicates / functions to CodeSystemUtils
b6b8d9a
SO-1974 static util method for code system guava functional classes
f86b3d7
SO-1974 replacing anonymous inner class function
c86c74e
SO-1974 added util method: trying to find a branchPath's version path
d91cfbe
SO-1974 default extensions preference file added
ee7e9f9
SO-1974 compile error fix
faad38b
SO-1974 removing author tags from classes
130b9f1
SO-1974 remove extensions.xml from server side defaults
4840e74
SO-1974 moved guavafunctionals to interface for the sake of singletoness
b96529f
SO-1974 removed overcompliacted guava functional
56b718c
SO-1974 made field private
52b350f
SO-1974 ICodeSystem to IBranchPath convenience function
864aded
SO-1974 moved TerminologyExtensionsBootstrapFragment to UI plugin
6ab4c58
SO-1974 removing unnecessary preference pojo
5d03888
SO-1974 terminology extension: preference persistence change
a89f417
SO-1974 removed method
92c57f3
SO-1974 moved TerminologyExtensionConfiguration class to client side
1d594ba
SO-1974 updated manifest after class moving
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
SO-1974 added predicate for selecting active code systems
- Loading branch information
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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 | ||
*/ | ||
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()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 { | ||
|
@@ -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); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍