Search in sources :

Example 16 with Configuration

use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.Configuration in project webanno by webanno.

the class AgreementUtils method dumpAgreementConfigurationSets.

private static void dumpAgreementConfigurationSets(PrintStream aOut, AgreementResult aAgreement, List<ConfigurationSet> aSets) {
    for (ConfigurationSet cfgSet : aSets) {
        StringBuilder sb = new StringBuilder();
        sb.append(cfgSet.getPosition());
        for (Configuration cfg : cfgSet.getConfigurations()) {
            if (sb.length() > 0) {
                sb.append(" \t");
            }
            sb.append(cfg.toString());
        }
        aOut.println(sb);
    }
}
Also used : ConfigurationSet(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.ConfigurationSet) Configuration(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.Configuration)

Example 17 with Configuration

use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.Configuration in project webanno by webanno.

the class SuggestionViewPanel method addSuggestionColor.

/**
 * For each {@link ConfigurationSet}, where there are some differences in users annotation and
 * the curation annotation.
 */
private void addSuggestionColor(Project aProject, Mode aMode, Map<String, JCas> aCasMap, Map<String, Map<VID, AnnotationState>> aSuggestionColors, Collection<ConfigurationSet> aCfgSet, boolean aI, boolean aAgree) {
    for (ConfigurationSet cs : aCfgSet) {
        boolean use = false;
        for (String u : cs.getCasGroupIds()) {
            Map<VID, AnnotationState> colors = aSuggestionColors.get(u);
            if (colors == null) {
                colors = new HashMap<>();
                aSuggestionColors.put(u, colors);
            }
            for (Configuration c : cs.getConfigurations(u)) {
                FeatureStructure fs = c.getFs(u, aCasMap);
                AnnotationLayer layer = annotationService.getLayer(fs.getType().getName(), aProject);
                TypeAdapter typeAdapter = annotationService.getAdapter(layer);
                VID vid;
                // link FS
                if (c.getPosition().getFeature() != null) {
                    int fi = 0;
                    for (AnnotationFeature f : typeAdapter.listFeatures()) {
                        if (f.getName().equals(c.getPosition().getFeature())) {
                            break;
                        }
                        fi++;
                    }
                    vid = new VID(WebAnnoCasUtil.getAddr(fs), fi, c.getAID(u).index);
                } else {
                    vid = new VID(WebAnnoCasUtil.getAddr(fs));
                }
                if (aAgree) {
                    colors.put(vid, AnnotationState.AGREE);
                    continue;
                }
                // automation and correction projects
                if (!aMode.equals(Mode.CURATION) && !aAgree) {
                    if (cs.getCasGroupIds().size() == 2) {
                        colors.put(vid, AnnotationState.DO_NOT_USE);
                    } else {
                        colors.put(vid, AnnotationState.DISAGREE);
                    }
                    continue;
                }
                // this set agree with the curation annotation
                if (c.getCasGroupIds().contains(CURATION_USER)) {
                    use = true;
                } else {
                    use = false;
                }
                // this curation view
                if (u.equals(CURATION_USER)) {
                    continue;
                }
                if (aAgree) {
                    colors.put(vid, AnnotationState.AGREE);
                } else if (use) {
                    colors.put(vid, AnnotationState.USE);
                } else if (aI) {
                    colors.put(vid, AnnotationState.DISAGREE);
                } else if (!cs.getCasGroupIds().contains(CURATION_USER)) {
                    colors.put(vid, AnnotationState.DISAGREE);
                } else {
                    colors.put(vid, AnnotationState.DO_NOT_USE);
                }
            }
        }
    }
}
Also used : Configuration(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.Configuration) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) VID(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.VID) FeatureStructure(org.apache.uima.cas.FeatureStructure) ConfigurationSet(de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.ConfigurationSet) TypeAdapter(de.tudarmstadt.ukp.clarin.webanno.api.annotation.adapter.TypeAdapter) AnnotationState(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.AnnotationState) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)

Example 18 with Configuration

use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.Configuration in project batfish by batfish.

the class Version method getVersion.

/**
 * Returns the version of the current build of Batfish, or {@link #UNKNOWN_VERSION} if the version
 * could not be detected.
 */
public static String getVersion() {
    try {
        Configuration config = new Configurations().properties(PROPERTIES_PATH);
        String version = config.getString("batfish_version");
        if (version.contains("project.version")) {
            // For whatever reason, resource filtering didn't work.
            return UNKNOWN_VERSION;
        }
        return version;
    } catch (Exception e) {
        return UNKNOWN_VERSION;
    }
}
Also used : Configuration(org.apache.commons.configuration2.Configuration) Configurations(org.apache.commons.configuration2.builder.fluent.Configurations)

Example 19 with Configuration

use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.Configuration in project graylog2-server by Graylog2.

the class UserServiceImplTest method testGetPermissionsForUser.

@Test
public void testGetPermissionsForUser() throws Exception {
    final InMemoryRolePermissionResolver permissionResolver = mock(InMemoryRolePermissionResolver.class);
    final UserService userService = new UserServiceImpl(mongoConnection, configuration, roleService, userFactory, permissionResolver);
    final UserImplFactory factory = new UserImplFactory(new Configuration());
    final UserImpl user = factory.create(new HashMap<>());
    user.setName("user");
    final Role role = createRole("Foo");
    user.setRoleIds(Collections.singleton(role.getId()));
    user.setPermissions(Collections.singletonList("hello:world"));
    when(permissionResolver.resolveStringPermission(role.getId())).thenReturn(Collections.singleton("foo:bar"));
    assertThat(userService.getPermissionsForUser(user)).containsOnly("users:passwordchange:user", "users:edit:user", "foo:bar", "hello:world");
}
Also used : Role(org.graylog2.shared.users.Role) Configuration(org.graylog2.Configuration) UserService(org.graylog2.shared.users.UserService) InMemoryRolePermissionResolver(org.graylog2.security.InMemoryRolePermissionResolver) Test(org.junit.Test)

Example 20 with Configuration

use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.Configuration in project graylog2-server by Graylog2.

the class UserServiceImplTest method testGetRoleNames.

@Test
public void testGetRoleNames() throws Exception {
    final UserImplFactory factory = new UserImplFactory(new Configuration());
    final UserImpl user = factory.create(new HashMap<>());
    final Role role = createRole("Foo");
    final ImmutableMap<String, Role> map = ImmutableMap.<String, Role>builder().put(role.getId(), role).build();
    when(roleService.loadAllIdMap()).thenReturn(map);
    assertThat(userService.getRoleNames(user)).isEmpty();
    user.setRoleIds(Sets.newHashSet(role.getId()));
    assertThat(userService.getRoleNames(user)).containsOnly("Foo");
    when(roleService.loadAllIdMap()).thenReturn(new HashMap<>());
    assertThat(userService.getRoleNames(user)).isEmpty();
}
Also used : Role(org.graylog2.shared.users.Role) Configuration(org.graylog2.Configuration) Test(org.junit.Test)

Aggregations

Configuration (org.apache.commons.configuration2.Configuration)18 Configuration (org.graylog2.Configuration)10 Test (org.junit.Test)7 Configurations (org.apache.commons.configuration2.builder.fluent.Configurations)5 Before (org.junit.Before)5 Test (org.testng.annotations.Test)5 Configuration (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.Configuration)4 ConfigurationSet (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.ConfigurationSet)4 ArrayList (java.util.ArrayList)3 MetricRegistry (com.codahale.metrics.MetricRegistry)2 DiffResult (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult)2 IOException (java.io.IOException)2 Map (java.util.Map)2 BaseConfiguration (org.apache.commons.configuration2.BaseConfiguration)2 HierarchicalConfiguration (org.apache.commons.configuration2.HierarchicalConfiguration)2 JCas (org.apache.uima.jcas.JCas)2 Role (org.graylog2.shared.users.Role)2 UserService (org.graylog2.shared.users.UserService)2 EventBus (com.google.common.eventbus.EventBus)1 Gson (com.google.gson.Gson)1