Skip to content

Commit

Permalink
Updated for release 5.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rmraya committed Jun 23, 2024
1 parent 72d5a87 commit ec6f753
Show file tree
Hide file tree
Showing 12 changed files with 2,069 additions and 2,074 deletions.
6 changes: 3 additions & 3 deletions catalog/xliff2.2/matches.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
xmlns:mtc="urn:oasis:names:tc:xliff:matches:2.0"
xmlns:xlf="urn:oasis:names:tc:xliff:document:2.0"
xmlns:xlf="urn:oasis:names:tc:xliff:document:2.2"
xmlns:mda="urn:oasis:names:tc:xliff:metadata:2.0"
targetNamespace="urn:oasis:names:tc:xliff:matches:2.0">

<!-- Import -->

<xs:import namespace="urn:oasis:names:tc:xliff:document:2.0"
schemaLocation="xliff_core_2.0.xsd"/>
<xs:import namespace="urn:oasis:names:tc:xliff:document:2.2"
schemaLocation="xliff_core_2.2.xsd"/>
<xs:import namespace="urn:oasis:names:tc:xliff:metadata:2.0"
schemaLocation="metadata.xsd"/>

Expand Down
7 changes: 4 additions & 3 deletions catalog/xliff2.2/resource_data.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
xmlns:res="urn:oasis:names:tc:xliff:resourcedata:2.0"
xmlns:xlf="urn:oasis:names:tc:xliff:document:2.0"
xmlns:xlf="urn:oasis:names:tc:xliff:document:2.2"
targetNamespace="urn:oasis:names:tc:xliff:resourcedata:2.0">

<!-- Import -->

<xs:import namespace="urn:oasis:names:tc:xliff:document:2.0"
schemaLocation="xliff_core_2.0.xsd"/>
<xs:import namespace="urn:oasis:names:tc:xliff:document:2.2"
schemaLocation="xliff_core_2.2.xsd"/>
<xs:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="informativeCopiesOf3rdPartySchemas/w3c/xml.xsd"/>

Expand All @@ -34,6 +34,7 @@
<xs:element name="resourceItem">
<xs:complexType mixed="false">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" ref="xlf:notes"/>
<xs:element minOccurs="0" maxOccurs="1" ref="res:source"/>
<xs:element minOccurs="0" maxOccurs="1" ref="res:target"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="res:reference"/>
Expand Down
6 changes: 3 additions & 3 deletions catalog/xliff2.2/validation.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
xmlns:val="urn:oasis:names:tc:xliff:validation:2.0"
xmlns:xlf="urn:oasis:names:tc:xliff:document:2.0"
xmlns:xlf="urn:oasis:names:tc:xliff:document:2.2"
targetNamespace="urn:oasis:names:tc:xliff:validation:2.0">

<!-- Import -->

<xs:import namespace="urn:oasis:names:tc:xliff:document:2.0"
schemaLocation="xliff_core_2.0.xsd"/>
<xs:import namespace="urn:oasis:names:tc:xliff:document:2.2"
schemaLocation="xliff_core_2.2.xsd"/>

<!-- Attribute Types -->

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "swordfish",
"productName": "Swordfish",
"version": "5.3.0",
"version": "5.4.0",
"description": "Swordfish Translation Editor",
"main": "js/Swordfish.js",
"scripts": {
Expand All @@ -26,6 +26,6 @@
"dependencies": {
"mtengines": "^1.4.0",
"typesxml": "^1.3.1",
"typesbcp47": "~1.3.2"
"typesbcp47": "^1.4.0"
}
}
}
4 changes: 2 additions & 2 deletions src/com/maxprograms/swordfish/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ private Constants() {
}

public static final String APPNAME = "Swordfish";
public static final String VERSION = "5.3.0";
public static final String BUILD = "20240602_1623";
public static final String VERSION = "5.4.0";
public static final String BUILD = "20240623_1517";

public static final String REASON = "reason";
public static final String STATUS = "status";
Expand Down
2 changes: 1 addition & 1 deletion src/com/maxprograms/swordfish/GlossariesHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private static JSONObject createGlossary(String request) throws IOException, SQL
glossaries.put(mem.getId(), mem);
ServicesHandler.addClient(json.getString("client"));
ServicesHandler.addSubject(json.getString("subject"));
ServicesHandler.addProject(json.getString("project"));
ServicesHandler.addProjectName(json.getString("project"));
saveGlossariesList(glossaries);
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/com/maxprograms/swordfish/MemoriesHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ private static JSONObject createMemory(String request) throws IOException, SQLEx
memories.put(mem.getId(), mem);
ServicesHandler.addClient(json.getString("client"));
ServicesHandler.addSubject(json.getString("subject"));
ServicesHandler.addProject(json.getString("project"));
ServicesHandler.addProjectName(json.getString("project"));
saveMemoriesList(memories);
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/com/maxprograms/swordfish/ProjectsHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ private JSONObject createProject(String request) {
ServicesHandler.addClient(json.getString("client"));
ServicesHandler.addSubject(json.getString("subject"));
if (!p.getDescription().endsWith(sourceFiles.get(0).getFile())) {
ServicesHandler.addProject(p.getDescription());
ServicesHandler.addProjectName(p.getDescription());
}
p.setFiles(sourceFiles);
Map<String, Project> projects = getProjects();
Expand Down
59 changes: 26 additions & 33 deletions src/com/maxprograms/swordfish/ServicesHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ public class ServicesHandler implements HttpHandler {

private static Logger logger = System.getLogger(ServicesHandler.class.getName());

private static JSONObject clients;
private static JSONObject subjects;
private static JSONObject projects;

@Override
public void handle(HttpExchange exchange) throws IOException {
try {
Expand Down Expand Up @@ -110,7 +106,7 @@ private JSONObject processRequest(String url, String request) {
} else if ("/services/getSubjects".equals(url)) {
result = getSubjects();
} else if ("/services/getProjects".equals(url)) {
result = getProjects();
result = getProjectNames();
} else if ("/services/getSpellingLanguages".equals(url)) {
result = getSpellingLanguages(request);
} else if ("/services/remoteDatabases".equals(url)) {
Expand Down Expand Up @@ -478,30 +474,30 @@ private JSONObject getLanguages() {
}

private static JSONObject getClients() throws IOException {
if (clients != null) {
return clients;
}
File clientsFile = new File(TmsServer.getWorkFolder(), "clients.json");
if (!clientsFile.exists()) {
clients = new JSONObject();
JSONObject clients = new JSONObject();
clients.put("clients", new JSONArray());
try (FileOutputStream out = new FileOutputStream(clientsFile)) {
out.write(clients.toString(2).getBytes(StandardCharsets.UTF_8));
}
return clients;
}
clients = TmsServer.readJSON(clientsFile);
JSONObject clients = TmsServer.readJSON(clientsFile);
return clients;
}

private static JSONObject getSubjects() throws IOException {
if (subjects != null) {
return subjects;
}
File subjectsFile = new File(TmsServer.getWorkFolder(), "subjects.json");
if (!subjectsFile.exists()) {
subjects = new JSONObject();
JSONObject subjects = new JSONObject();
subjects.put("subjects", new JSONArray());
try (FileOutputStream out = new FileOutputStream(subjectsFile)) {
out.write(subjects.toString(2).getBytes(StandardCharsets.UTF_8));
}
return subjects;
}
subjects = TmsServer.readJSON(subjectsFile);
JSONObject subjects = TmsServer.readJSON(subjectsFile);
return subjects;
}

Expand All @@ -519,28 +515,25 @@ private static JSONObject getSystemInformation() {
return result;
}

private static JSONObject getProjects() throws IOException {
if (projects != null) {
return projects;
}
private static JSONObject getProjectNames() throws IOException {
File projectsFile = new File(TmsServer.getWorkFolder(), "projects.json");
if (!projectsFile.exists()) {
projects = new JSONObject();
JSONObject projects = new JSONObject();
projects.put("projects", new JSONArray());
try (FileOutputStream out = new FileOutputStream(projectsFile)) {
out.write(projects.toString().getBytes(StandardCharsets.UTF_8));
out.write(projects.toString(2).getBytes(StandardCharsets.UTF_8));
}
return projects;
}
projects = TmsServer.readJSON(projectsFile);
JSONObject projects = TmsServer.readJSON(projectsFile);
return projects;
}

public static void addClient(String client) throws IOException {
if (client == null || client.isEmpty()) {
return;
}
getClients();
JSONObject clients = getClients();
JSONArray array = clients.getJSONArray("clients");
for (int i = 0; i < array.length(); i++) {
if (client.equals(array.getString(i))) {
Expand All @@ -550,15 +543,15 @@ public static void addClient(String client) throws IOException {
clients.put("clients", insertString(client, array));
File clientsFile = new File(TmsServer.getWorkFolder(), "clients.json");
try (FileOutputStream out = new FileOutputStream(clientsFile)) {
out.write(clients.toString().getBytes(StandardCharsets.UTF_8));
out.write(clients.toString(2).getBytes(StandardCharsets.UTF_8));
}
}

public static void addSubject(String subject) throws IOException {
if (subject == null || subject.isEmpty()) {
return;
}
getSubjects();
JSONObject subjects = getSubjects();
JSONArray array = subjects.getJSONArray("subjects");
for (int i = 0; i < array.length(); i++) {
if (subject.equals(array.getString(i))) {
Expand All @@ -568,36 +561,36 @@ public static void addSubject(String subject) throws IOException {
subjects.put("subjects", insertString(subject, array));
File subjectsFile = new File(TmsServer.getWorkFolder(), "subjects.json");
try (FileOutputStream out = new FileOutputStream(subjectsFile)) {
out.write(subjects.toString().getBytes(StandardCharsets.UTF_8));
out.write(subjects.toString(2).getBytes(StandardCharsets.UTF_8));
}
}

public static void addProject(String project) throws IOException {
public static void addProjectName(String project) throws IOException {
if (project == null || project.isEmpty()) {
return;
}
getProjects();
JSONObject projects = getProjectNames();
JSONArray array = projects.getJSONArray("projects");
for (int i = 0; i < array.length(); i++) {
if (project.equals(array.getString(i))) {
return;
}
}
projects.put("projects", insertString(project, array));
File projectsFile = new File(TmsServer.getProjectsFolder(), "projects.json");
File projectsFile = new File(TmsServer.getWorkFolder(), "projects.json");
try (FileOutputStream out = new FileOutputStream(projectsFile)) {
out.write(projects.toString().getBytes(StandardCharsets.UTF_8));
out.write(projects.toString(2).getBytes(StandardCharsets.UTF_8));
}
}

private static JSONArray insertString(String string, JSONArray array) {
private static JSONArray insertString(String projectName, JSONArray array) {
JSONArray result = new JSONArray();
List<String> list = new Vector<>();
list.add(string);
list.add(projectName);
for (int i = 0; i < array.length(); i++) {
list.add(array.getString(i));
}
Collections.sort(list);
Collections.sort(list, (o1, o2) -> o1.toLowerCase().compareTo(o2.toLowerCase()));
Iterator<String> it = list.iterator();
while (it.hasNext()) {
result.put(it.next());
Expand Down
Loading

0 comments on commit ec6f753

Please sign in to comment.