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
Show file tree
Hide file tree
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 initialization for terminology extension preferences
  • Loading branch information
Endre Kovacs committed Jun 10, 2016
commit bad83b681f3bd10416ed36973c3a555840a4e756
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@
terminologyId="UNSPECIFIED"><!-- delightfully meta -->
</serviceConfigJob>
</extension>
<extension
point="com.b2international.snowowl.core.bootstrapFragments">
<bootstrapFragment
class="com.b2international.snowowl.terminologyregistry.core.TerminologyExtensionsBootstrapFragment">
</bootstrapFragment>
</extension>
</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright 2011-2016 B2i Healthcare Pte Ltd, http:https://b2i.sg
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.b2international.snowowl.terminologyregistry.core;

import java.io.File;
import java.util.Collection;

import org.osgi.service.prefs.PreferencesService;

import com.b2international.snowowl.core.ApplicationContext;
import com.b2international.snowowl.core.api.preferences.ConfigNode;
import com.b2international.snowowl.core.api.preferences.PreferenceBase;
import com.b2international.snowowl.core.api.preferences.io.ConfigurationEntrySerializer;
import com.b2international.snowowl.datastore.ICodeSystem;
import com.b2international.snowowl.datastore.TerminologyRegistryService;
import com.b2international.snowowl.datastore.UserBranchPathMap;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Multimaps;

/**
*
* @author endre
*/
public class TerminologyExtensionConfiguration extends PreferenceBase {

private static final String NODE_NAME = "Terminology extensions";

private static final String CODE_SYSTEMS_KEY = "com.b2international.snowowl.terminologyregistry.core.codeSystems";

public ConfigurationEntrySerializer<ConfigNode<String, ICodeSystem>> codeSystemSerializer;

public TerminologyExtensionConfiguration(PreferencesService preferencesService, File defaultsPath) {
super(preferencesService, NODE_NAME);
init(defaultsPath);
}

private void init(File defaultsPath) {

codeSystemSerializer = new ConfigurationEntrySerializer<ConfigNode<String, ICodeSystem>>(preferences, CODE_SYSTEMS_KEY, new File(defaultsPath, "extensions.xml")) {

@Override
protected ConfigNode<String, ICodeSystem> computeDefault() {

ConfigNode<String, ICodeSystem> configNode = new ConfigNode<String, ICodeSystem>(CODE_SYSTEMS_KEY);


Collection<ICodeSystem> codeSystems = ApplicationContext.getInstance().getService(TerminologyRegistryService.class).getCodeSystems(new UserBranchPathMap());
ImmutableListMultimap<String, ICodeSystem> repositoryTocodeSystemMultiMap = Multimaps.index(codeSystems, new Function<ICodeSystem, String>() {
@Override
public String apply(ICodeSystem input) {
return input.getRepositoryUuid();
}
});

ImmutableMap<String, Collection<ICodeSystem>> asMap = repositoryTocodeSystemMultiMap.asMap();
for (String key : asMap.keySet()) {
Collection<ICodeSystem> collection = asMap.get(key);

if (collection.isEmpty())
continue;

configNode.addChild(key, Iterables.getLast(collection));
}

return configNode;
}

};
}

public ConfigurationEntrySerializer<ConfigNode<String, ICodeSystem>> getCodeSystemSerializer() {
return codeSystemSerializer;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2011-2016 B2i Healthcare Pte Ltd, http:https://b2i.sg
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.b2international.snowowl.terminologyregistry.core;

import org.eclipse.core.runtime.IProgressMonitor;

import com.b2international.snowowl.core.config.SnowOwlConfiguration;
import com.b2international.snowowl.core.setup.BootstrapFragment;
import com.b2international.snowowl.core.setup.Environment;

/**
* {@link BootstrapFragment} for creating and registering {@link TerminologyExtensionConfiguration}
* @author endre
*/
public class TerminologyExtensionsBootstrapFragment implements BootstrapFragment {
Copy link
Member

Choose a reason for hiding this comment

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

This should be part of the client, move it to the ext repository.


@Override
public void init(SnowOwlConfiguration configuration, Environment env) throws Exception {
env.services().registerService(TerminologyExtensionConfiguration.class, new TerminologyExtensionConfiguration(env.preferences(), env.getDefaultsDirectory()));
}

@Override
public void run(SnowOwlConfiguration configuration, Environment env, IProgressMonitor monitor) throws Exception {}

}