Skip to content

Commit

Permalink
Docs little upgrade.
Browse files Browse the repository at this point in the history
  • Loading branch information
Serg-Maximchuk committed Dec 30, 2015
1 parent bda95b0 commit 80dd09e
Show file tree
Hide file tree
Showing 9 changed files with 1,218 additions and 1,120 deletions.
1 change: 1 addition & 0 deletions docs/fundamental/advanced-configuration/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ Advanced Configuration
image-processing
solr
language
properties

21 changes: 19 additions & 2 deletions docs/fundamental/advanced-configuration/language.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
Language
========

General actions with language (the java-code):
get default language
General actions with language (the java-code)
"""""""""""""""""""""""""""""""""""""""""""""

* get default language:

.. code-block:: java
Imcms.getServices().getDocumentLanguages().getDefault();
* set language by creating new:

.. code-block:: java
Imcms.getUser().getDocGetterCallback().setLanguage(new DocumentLanguage(String code, String name, String nativeName), boolean isDefaultLang);
where ``code`` is language ISO-639-1 code.
* @param name language name
* @param nativeName language native name
*/
public DocumentLanguage(String code, String name, String nativeName) {
this.code = code;
this.name = name;
this.nativeName = nativeName;
}
Imcms.getServices().getDocumentMapper().getDocument(---id---).getMeta().getEnabledLanguages();
Imcms.getServices().getDocumentMapper().getDocument(---id---).setLanguage(---DocumentLanguage--);

3 changes: 3 additions & 0 deletions docs/fundamental/advanced-configuration/properties.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Properties
==========

112 changes: 53 additions & 59 deletions src/main/java/com/imcode/imcms/api/DocumentLanguage.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,70 +6,22 @@

public final class DocumentLanguage implements Serializable {

public static Builder builder() {
return new Builder();
}

public static Builder builder(DocumentLanguage documentLanguage) {
return new Builder(documentLanguage);
}

public static final class Builder {
private String code;
private String name;
private String nativeName;

public Builder() {
public static Comparator<DocumentLanguage> NATIVE_NAME_COMPARATOR = (d1, d2) -> {
String n1 = d1.getNativeName();
String n2 = d2.getNativeName();

if (n1 == null && n2 == null) {
return 0;
} else if (n1 == null) {
return 1;
} else if (n2 == null) {
return -1;
}

public Builder(DocumentLanguage language) {
this.code = language.code;
this.name = language.name;
this.nativeName = language.nativeName;
}

public Builder code(String code) {
this.code = code;
return this;
}

public Builder name(String name) {
this.name = name;
return this;
}

public Builder nativeName(String nativeName) {
this.nativeName = nativeName;
return this;
}

public DocumentLanguage build() {
return new DocumentLanguage(code, name, nativeName);
}
}

public static Comparator<DocumentLanguage> NATIVE_NAME_COMPARATOR = new Comparator<DocumentLanguage>() {
@Override
public int compare(DocumentLanguage d1, DocumentLanguage d2) {
String n1 = d1.getNativeName();
String n2 = d2.getNativeName();

if (n1 == null && n2 == null) {
return 0;
} else if (n1 == null && n2 != null) {
return 1;
} else if (n1 != null && n2 == null) {
return -1;
}

return n1.compareToIgnoreCase(n2);
}
return n1.compareToIgnoreCase(n2);
};

private final String code;

private final String name;

private final String nativeName;

/**
Expand All @@ -83,6 +35,14 @@ public DocumentLanguage(String code, String name, String nativeName) {
this.nativeName = nativeName;
}

public static Builder builder() {
return new Builder();
}

public static Builder builder(DocumentLanguage documentLanguage) {
return new Builder(documentLanguage);
}

@Override
public boolean equals(Object o) {
return o == this || (o instanceof DocumentLanguage && equals((DocumentLanguage) o));
Expand Down Expand Up @@ -127,4 +87,38 @@ public String getName() {
public String getNativeName() {
return nativeName != null ? nativeName : name;
}

public static final class Builder {
private String code;
private String name;
private String nativeName;

public Builder() {
}

public Builder(DocumentLanguage language) {
this.code = language.code;
this.name = language.name;
this.nativeName = language.nativeName;
}

public Builder code(String code) {
this.code = code;
return this;
}

public Builder name(String name) {
this.name = name;
return this;
}

public Builder nativeName(String nativeName) {
this.nativeName = nativeName;
return this;
}

public DocumentLanguage build() {
return new DocumentLanguage(code, name, nativeName);
}
}
}

0 comments on commit 80dd09e

Please sign in to comment.