Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ianj-als/omtc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Johnson <ian.johnson@appliedlanguage.com>2013-02-20 18:52:50 +0400
committerIan Johnson <ian.johnson@appliedlanguage.com>2013-02-20 18:52:50 +0400
commit33b770b1a15c75b0a7ddd3c54656248c7ea01306 (patch)
treebb8f32b1bf02dd8f4c3e28c227910f86fa9789ec
parentf5a86594dfbe31a193175bfc51cd54872ea3ab10 (diff)
Added translation memory and glossary interfaces. Changed users and roles to interfaces.
-rw-r--r--src/main/java/com/capitati/omtc/core/resources/IGlossary.java16
-rw-r--r--src/main/java/com/capitati/omtc/core/resources/ITranslationMemory.java15
-rw-r--r--src/main/java/com/capitati/omtc/core/resources/ITranslationResource.java44
-rw-r--r--src/main/java/com/capitati/omtc/core/scheduling/TranslationTicket.java10
-rw-r--r--src/main/java/com/capitati/omtc/core/security/IRole.java7
-rw-r--r--src/main/java/com/capitati/omtc/core/security/IUser.java2
-rw-r--r--src/main/java/com/capitati/omtc/core/security/Role.java43
-rw-r--r--src/main/java/com/capitati/omtc/core/security/User.java39
-rw-r--r--src/main/java/com/capitati/omtc/core/session/IRoleAssignableSession.java6
-rw-r--r--src/main/java/com/capitati/omtc/core/translation/Translator.java28
10 files changed, 105 insertions, 105 deletions
diff --git a/src/main/java/com/capitati/omtc/core/resources/IGlossary.java b/src/main/java/com/capitati/omtc/core/resources/IGlossary.java
new file mode 100644
index 0000000..da05f07
--- /dev/null
+++ b/src/main/java/com/capitati/omtc/core/resources/IGlossary.java
@@ -0,0 +1,16 @@
+package com.capitati.omtc.core.resources;
+
+
+/**
+ * A glossary.
+ *
+ * @author ian
+ */
+public interface IGlossary extends ITranslationResource {
+ /**
+ * Retrieve the number of glossary entries.
+ *
+ * @return The number of entries.
+ */
+ int getNumberOfEntries();
+}
diff --git a/src/main/java/com/capitati/omtc/core/resources/ITranslationMemory.java b/src/main/java/com/capitati/omtc/core/resources/ITranslationMemory.java
new file mode 100644
index 0000000..c3d8730
--- /dev/null
+++ b/src/main/java/com/capitati/omtc/core/resources/ITranslationMemory.java
@@ -0,0 +1,15 @@
+package com.capitati.omtc.core.resources;
+
+/**
+ * A translation memory.
+ *
+ * @author ian
+ */
+public interface ITranslationMemory extends ITranslationResource {
+ /**
+ * Retrieves the number of segments from the translation memory.
+ *
+ * @return The segment count of the translation memory.
+ */
+ int getNumberOfSegments();
+}
diff --git a/src/main/java/com/capitati/omtc/core/resources/ITranslationResource.java b/src/main/java/com/capitati/omtc/core/resources/ITranslationResource.java
new file mode 100644
index 0000000..430f35b
--- /dev/null
+++ b/src/main/java/com/capitati/omtc/core/resources/ITranslationResource.java
@@ -0,0 +1,44 @@
+package com.capitati.omtc.core.resources;
+
+import java.util.Map;
+
+import com.capitati.omtc.core.resources.IPrimaryResource;
+
+/**
+ * An abstract resource that will be used in some translation operation.
+ *
+ * @author ian
+ */
+public interface ITranslationResource extends IPrimaryResource {
+ /**
+ * Retrieve the source language code.
+ *
+ * @return An implementation defined {@link java.lang.String} object that
+ * shall be the source language code.
+ */
+ String getSourceLanguage();
+
+ /**
+ * Retrieve the target language code.
+ *
+ * @return A {@link java.lang.String} array object that shall list the
+ * implementation target language codes.
+ */
+ String[] getTargetLanguage();
+
+ /**
+ * Retrieve the source language word count.
+ *
+ * @return The number of words in the source language.
+ */
+ int getSourceWordCount();
+
+ /**
+ * Retrieve the target language word counts.
+ *
+ * @return A {@link java.util.Map} object whose keys shall be the target
+ * language codes, returned by {@link ITranslationResource.getTargetLanguage},
+ * and values the word count for the target language.
+ */
+ Map<String, Integer> getTargetWordCounts();
+}
diff --git a/src/main/java/com/capitati/omtc/core/scheduling/TranslationTicket.java b/src/main/java/com/capitati/omtc/core/scheduling/TranslationTicket.java
index aa1a5c7..34d2475 100644
--- a/src/main/java/com/capitati/omtc/core/scheduling/TranslationTicket.java
+++ b/src/main/java/com/capitati/omtc/core/scheduling/TranslationTicket.java
@@ -21,23 +21,25 @@ package com.capitati.omtc.core.scheduling;
import java.util.Date;
import java.util.UUID;
+import com.capitati.omtc.core.resources.IPrimaryResource;
import com.capitati.omtc.core.session.ISession;
import com.capitati.omtc.core.translation.Translator;
-public class TranslationTicket<V> extends Ticket<V> {
- private final Translator<V> translator;
+public class TranslationTicket<V, T extends IPrimaryResource, G extends IPrimaryResource>
+extends Ticket<V> {
+ private final Translator<V, T, G> translator;
public TranslationTicket(
final UUID theIdentifier,
final Date theStartDate,
final ISession theSession,
final V thePriority,
- final Translator<V> theTranslator) {
+ final Translator<V, T, G> theTranslator) {
super(theIdentifier, theStartDate, theSession, thePriority);
translator = theTranslator;
}
- public Translator<V> getTranslator() {
+ public Translator<V, T, G> getTranslator() {
return translator;
}
}
diff --git a/src/main/java/com/capitati/omtc/core/security/IRole.java b/src/main/java/com/capitati/omtc/core/security/IRole.java
new file mode 100644
index 0000000..1fa9c29
--- /dev/null
+++ b/src/main/java/com/capitati/omtc/core/security/IRole.java
@@ -0,0 +1,7 @@
+package com.capitati.omtc.core.security;
+
+public interface IRole {
+ int getCode();
+
+ String getName();
+}
diff --git a/src/main/java/com/capitati/omtc/core/security/IUser.java b/src/main/java/com/capitati/omtc/core/security/IUser.java
index 092cddd..b88b1d0 100644
--- a/src/main/java/com/capitati/omtc/core/security/IUser.java
+++ b/src/main/java/com/capitati/omtc/core/security/IUser.java
@@ -38,5 +38,5 @@ public interface IUser {
*
* @return The roles of the user.
*/
- Role[] getRoles();
+ IRole[] getRoles();
}
diff --git a/src/main/java/com/capitati/omtc/core/security/Role.java b/src/main/java/com/capitati/omtc/core/security/Role.java
deleted file mode 100644
index bf1e3c4..0000000
--- a/src/main/java/com/capitati/omtc/core/security/Role.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright Capita Translation and Interpreting 2013
- *
- * This file is part of OMTC.
- *
- * OMTC is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * OMTC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with OMTC. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.capitati.omtc.core.security;
-
-public enum Role {
- INVALID(-1, "Invalid"),
- TRANSLATOR(1, "Translator"),
- ENGINE_MANAGER(3, "Engine Manager"),
- ADMINISTRATOR(7, "Administrator"),
- SERVICE_ADMINISTRATOR(8, "Service Administrator");
-
- private final int code;
- private final String name;
-
- private Role(final int theCode, final String theName) {
- code = theCode;
- name = theName;
- }
-
- public int getCode() {
- return code;
- }
-
- public String getName() {
- return name;
- }
-}
diff --git a/src/main/java/com/capitati/omtc/core/security/User.java b/src/main/java/com/capitati/omtc/core/security/User.java
deleted file mode 100644
index bca6e0e..0000000
--- a/src/main/java/com/capitati/omtc/core/security/User.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright Capita Translation and Interpreting 2013
- *
- * This file is part of OMTC.
- *
- * OMTC is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * OMTC is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with OMTC. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.capitati.omtc.core.security;
-
-import java.util.UUID;
-
-public abstract class User implements IUser {
- private final UUID userId;
- private final Role role;
-
- protected User(final UUID theUserId, final Role theRole) {
- userId = theUserId;
- role = theRole;
- }
-
- public UUID getIdentifier() {
- return userId;
- }
-
- public Role getRole() {
- return role;
- }
-}
diff --git a/src/main/java/com/capitati/omtc/core/session/IRoleAssignableSession.java b/src/main/java/com/capitati/omtc/core/session/IRoleAssignableSession.java
index 8948634..699bfec 100644
--- a/src/main/java/com/capitati/omtc/core/session/IRoleAssignableSession.java
+++ b/src/main/java/com/capitati/omtc/core/session/IRoleAssignableSession.java
@@ -18,8 +18,8 @@
*/
package com.capitati.omtc.core.session;
+import com.capitati.omtc.core.security.IRole;
import com.capitati.omtc.core.security.IUser;
-import com.capitati.omtc.core.security.Role;
/**
* A mixin for providing a session the ability to grant and revoke roles from
@@ -37,7 +37,7 @@ public interface IRoleAssignableSession extends IUserRetrievableSession {
* @param theUser - the user.
* @throws Exception On any errors that occur during the granting process.
*/
- void grantRoleToUser(Role theRole, IUser theUser) throws Exception;
+ void grantRoleToUser(IRole theRole, IUser theUser) throws Exception;
/**
* Revoke a role from a user.
@@ -46,5 +46,5 @@ public interface IRoleAssignableSession extends IUserRetrievableSession {
* @param theUser - the user.
* @throws Exception On any errors that occur during the revocation process.
*/
- void revokeRoleFromUser(Role theRole, IUser theUser) throws Exception;
+ void revokeRoleFromUser(IRole theRole, IUser theUser) throws Exception;
}
diff --git a/src/main/java/com/capitati/omtc/core/translation/Translator.java b/src/main/java/com/capitati/omtc/core/translation/Translator.java
index a483cdc..f93dbd5 100644
--- a/src/main/java/com/capitati/omtc/core/translation/Translator.java
+++ b/src/main/java/com/capitati/omtc/core/translation/Translator.java
@@ -37,12 +37,10 @@ import com.google.common.base.Predicate;
*
* @param <P> - the type of the priority's value.
*/
-public abstract class Translator<V> {
+public abstract class Translator<V, T extends IPrimaryResource, G extends IPrimaryResource> {
private final IEngine engine;
- private final Set<IPrimaryResource> glossaries =
- new HashSet<IPrimaryResource>();
- private final Set<IPrimaryResource> translationMemories =
- new HashSet<IPrimaryResource>();
+ private final Set<G> glossaries = new HashSet<G>();
+ private final Set<T> translationMemories = new HashSet<T>();
protected Translator(final IEngine theEngine) {
super();
@@ -51,8 +49,8 @@ public abstract class Translator<V> {
protected Translator(
final IEngine theEngine,
- final Set<IPrimaryResource> theGlossaries,
- final Set<IPrimaryResource> theTranslationMemories) {
+ final Set<G> theGlossaries,
+ final Set<T> theTranslationMemories) {
super();
engine = theEngine;
glossaries.addAll(theGlossaries);
@@ -63,11 +61,11 @@ public abstract class Translator<V> {
return engine;
}
- public Set<IPrimaryResource> getGlossaries() {
+ public Set<G> getGlossaries() {
return glossaries;
}
- public Set<IPrimaryResource> getTranslationMemories() {
+ public Set<T> getTranslationMemories() {
return translationMemories;
}
@@ -83,11 +81,11 @@ public abstract class Translator<V> {
* @return A translation ticket.
* @throws Exception On an error.
*/
- public abstract TranslationTicket<V> scheduleTranslation(
+ public abstract TranslationTicket<V, T, G> scheduleTranslation(
ISession session,
IPrimaryResource resourceToTranslate,
IPriority<V> thePriority,
- ITicketObserver<TranslationTicket<V>, V> translationObserver)
+ ITicketObserver<TranslationTicket<V, T, G>, V> translationObserver)
throws Exception;
/**
@@ -101,11 +99,11 @@ public abstract class Translator<V> {
* @return A translation ticket.
* @throws Exception On an error.
*/
- public abstract TranslationTicket<V> scheduleTranslation(
+ public abstract TranslationTicket<V, T, G> scheduleTranslation(
ISession session,
String sourceSentence,
IPriority<V> thePriority,
- ITicketObserver<TranslationTicket<V>, V> translationObserver)
+ ITicketObserver<TranslationTicket<V, T, G>, V> translationObserver)
throws Exception;
/**
@@ -118,7 +116,7 @@ public abstract class Translator<V> {
*
* @throws Exception
*/
- public abstract Set<TranslationTicket<V>> retrieveTranslations(
+ public abstract Set<TranslationTicket<V, T, G>> retrieveTranslations(
ISession session,
- Predicate<TranslationTicket<V>> filter) throws Exception;
+ Predicate<TranslationTicket<V, T, G>> filter) throws Exception;
}