📄 localizationmanagerejb.java
字号:
/*
* Copyright 2006-2007 Queplix Corp.
*
* Licensed under the Queplix Public License, Version 1.1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.queplix.com/solutions/commercial-open-source/queplix-public-license/
*
* 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.queplix.core.modules.config.ejb;
import java.io.Serializable;
import com.queplix.core.error.GenericSystemException;
import com.queplix.core.modules.config.jxb.Caption;
import com.queplix.core.modules.config.jxb.Captions;
import com.queplix.core.modules.config.jxb.Description;
import com.queplix.core.modules.config.jxb.Descriptions;
import com.queplix.core.modules.config.jxb.Htmlcontent;
import com.queplix.core.modules.config.jxb.Htmlcontents;
import com.queplix.core.modules.config.jxb.LocalizedObject;
import com.queplix.core.modules.config.jxb.LocalizedObjectsId;
import com.queplix.core.modules.config.utils.ConfigPropertyFactory;
import com.queplix.core.modules.config.utils.EntityHelper;
import com.queplix.core.modules.config.utils.LocalizationDAO;
import com.queplix.core.utils.SystemHelper;
import com.queplix.core.utils.cache.Cache;
import com.queplix.core.utils.ejb.AbstractSessionEJB;
/**
* LocalizationManager session ejb component
* @author [SVM] Maxim Suponya
* @author [ALB] Baranov Andrey
* @author Michael Trofimov
*/
public class LocalizationManagerEJB extends AbstractSessionEJB {
static class LocalizedObjectTypes {
public static final LocalizedObjectTypes LABEL = new LocalizedObjectTypes(0);
public static final LocalizedObjectTypes FOCUS = new LocalizedObjectTypes(1);
public static final LocalizedObjectTypes TAB = new LocalizedObjectTypes(2);
public static final LocalizedObjectTypes FORM = new LocalizedObjectTypes(3);
public static final LocalizedObjectTypes SERVER = new LocalizedObjectTypes(4);
public static final LocalizedObjectTypes CLIENT = new LocalizedObjectTypes(5);
public static final LocalizedObjectTypes POPUP_MENU = new LocalizedObjectTypes(6);
public static final LocalizedObjectTypes SUB_FOCUS = new LocalizedObjectTypes(7);
public static final LocalizedObjectTypes CONTEXT_MENU = new LocalizedObjectTypes(8);
public static final LocalizedObjectTypes BUTTON = new LocalizedObjectTypes(9);
public static final LocalizedObjectTypes HTML_ELEMENT = new LocalizedObjectTypes(10);
private final int id;
private LocalizedObjectTypes(int id){
this.id = id;
}
public int getId(){
return id;
}
}
static class LocalizationTypes {
public static final LocalizationTypes CAPTION = new LocalizationTypes(0);
public static final LocalizationTypes DESCRIPTION = new LocalizationTypes(1);
public static final LocalizationTypes HTML_CONTENT = new LocalizationTypes(2);
private final int id;
private LocalizationTypes(int id){
this.id = id;
}
public int getId(){
return id;
}
}
static class LocalizedObjectsCacheKey implements Serializable, Comparable {
private String objectId;
private Integer objectType;
private Integer localizationType;
public LocalizedObjectsCacheKey(String objectId,
LocalizedObjectTypes objectType, LocalizationTypes localizationType){
checkNull(objectId, "id");
checkNull(objectType, "type");
checkNull(localizationType, "localizationType");
this.objectId = objectId;
this.objectType = objectType.getId();
this.localizationType = localizationType.getId();
}
public String getId() {
return objectId;
}
public Integer getType() {
return objectType;
}
public Integer getLocalizationType(){
return localizationType;
}
/**
* No javadoc
* @see Comparable#compareTo(Object)
*/
public int compareTo(Object o) {
if (o == this)
return 0;
LocalizedObjectsCacheKey c = (LocalizedObjectsCacheKey) o;
if (objectId.equals(c.objectId)) {
if (objectType.equals(c.objectType)) {
return localizationType.compareTo(c.localizationType);
} else {
return objectType.compareTo( c.objectType );
}
} else {
return objectId.compareTo( c.objectId );
}
}
/**
* No javadoc
* @see Object#hashCode()
*/
public int hashCode() {
return objectId.hashCode() | (objectType.hashCode() << 37)
+ (37 * localizationType.hashCode());
}
/**
* No javadoc
* @see Object#equals(Object)
*/
public boolean equals( Object obj ) {
if (obj == null || !(obj instanceof LocalizedObjectsCacheKey)) {
return false;
}
LocalizedObjectsCacheKey c = (LocalizedObjectsCacheKey) obj;
return c.objectId.equals(objectId) && c.objectType.equals(objectType)
&& c.localizationType.equals(localizationType);
}
/**
* No javadoc
* @see Object#toString()
*/
public String toString() {
return "id=" + objectId + ", type=" + objectType + ", localizationType=" + localizationType;
}
private void checkNull(Object o, String name){
if(o == null)
throw new NullPointerException(name);
}
}
public void ejbCreate() {}
/**
* Fill Efield captions
* @param entityName Entity name attribute
* @param efieldName Efield name attribute
* @param captions Captions object
* @return id of Captions object
*/
public String fillEfieldCaptions( String entityName, String efieldName, Captions captions ) {
String efieldId = EntityHelper.getFieldId( entityName, efieldName );
fillCaptions( efieldId, LocalizedObjectTypes.LABEL, captions );
return efieldId;
}
/**
* Fill Focus captions
* @param focusId focus id attribute
* @param captions Captions object
* @return id of Captions object
*/
public String fillFocusCaptions( String focusId, Captions captions ) {
fillCaptions( focusId, LocalizedObjectTypes.FOCUS, captions );
return focusId;
}
/**
* Fill SubFocus captions
* @param subFocusId subfocus id attribute
* @param captions Captions object
* @return id of Captions object
*/
public String fillSubFocusCaptions( String subFocusId, Captions captions ) {
fillCaptions( subFocusId, LocalizedObjectTypes.SUB_FOCUS, captions );
return subFocusId;
}
/**
* Fill Tab captions
* @param tabId tab id attribute
* @param captions Captions object
* @return id of Captions object
*/
public String fillTabCaptions( String tabId, Captions captions ) {
fillCaptions( tabId, LocalizedObjectTypes.TAB, captions );
return tabId;
}
/**
* Fill Form captions
* @param formId form id attribute
* @param captions Captions object
* @return id of Captions object
*/
public String fillFormCaptions( String formId, Captions captions ) {
fillCaptions( formId, LocalizedObjectTypes.FORM, captions );
return formId;
}
/**
* Fill Button captions
* @param buttonId button id attribute
* @param captions Captions object
* @return id of Captions object
*/
public String fillButtonCaptions( String buttonId, Captions captions) {
fillCaptions( buttonId, LocalizedObjectTypes.BUTTON, captions);
return buttonId;
}
/**
* Fill server messages
* @param id message id
* @param captions Captions object
* @return id of Captions object
*/
public String fillServerMessages( String id, Captions captions ) {
fillCaptions( id, LocalizedObjectTypes.SERVER, captions );
return id;
}
/**
* Fill PopupMenu captions
* @param captionId id
* @param captions Captions object
* @return id of Captions object
*/
public String fillPopupMenuCaptions( String captionId, Captions captions ) {
fillCaptions( captionId, LocalizedObjectTypes.POPUP_MENU, captions );
return captionId;
}
/**
* Fill MenuItem captions
* @param menuId id
* @param captions Captions object
* @return id of Captions object
*/
public String fillMenuItemCaptions( String menuId, Captions captions ) {
fillCaptions( menuId, LocalizedObjectTypes.CONTEXT_MENU, captions );
return menuId;
}
/**
* Get Efield caption
* @param languageId language id
* @param entityName Entity name attribute
* @param efieldName Efield name attribute
* @return localized Caption
*/
public String getEfieldCaption( String languageId, String entityName, String efieldName ) {
String efieldId = EntityHelper.getFieldId( entityName, efieldName );
return getLocalizedCaption( languageId, efieldId, LocalizedObjectTypes.LABEL );
}
/**
* Get Focus caption
* @param languageId language id
* @param focusId focus id attribute
* @return localized Caption
*/
public String getFocusCaption( String languageId, String focusId ) {
return getLocalizedCaption( languageId, focusId, LocalizedObjectTypes.FOCUS );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -