/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cli_fmw.delegate.directory.complex;
import cli_fmw.delegate.directory.DirectoryItem;
import cli_fmw.main.ClipsException;
import framework.beans.address.DirectoryKladrTypeBeanRemote;
import framework.beans.address.entities.AddressObjectTypeDetails;
/**
* предоставляет доступ к одной строке справочника типов адресуемых объектов
* @author petr
*/
public class DirectoryKladrTypeItem
extends DirectoryItem<AddressObjectTypeDetails> {
public DirectoryKladrTypeItem(AddressObjectTypeDetails details) {
super(details);
}
public String getAbbrivation() {
return getDetails().abbrivation;
}
public void setAbbrivation(String abbrivation) throws ClipsException {
if(isInDirectory()) {
AddressObjectTypeDetails newDetails = getDetailsCopy();
newDetails.abbrivation = abbrivation;
saveDetails(newDetails);
} else {
getDetails().abbrivation = abbrivation;
}
}
public int getCode() {
return getDetails().code;
}
public void setCode(int code) throws ClipsException {
if(isInDirectory()) {
AddressObjectTypeDetails newDetails = getDetailsCopy();
newDetails.code = code;
saveDetails(newDetails);
} else {
getDetails().code = code;
}
}
public boolean isIsVillage() {
return getDetails().isVillage;
}
public void setIsVillage(boolean isVillage) throws ClipsException {
if(isInDirectory()) {
AddressObjectTypeDetails newDetails = getDetailsCopy();
newDetails.isVillage = isVillage;
saveDetails(newDetails);
} else {
getDetails().isVillage = isVillage;
}
}
public int getLevel() {
return getDetails().level;
}
public void setLevel(int level) throws ClipsException {
if(isInDirectory()) {
AddressObjectTypeDetails newDetails = getDetailsCopy();
newDetails.level = level;
saveDetails(newDetails);
} else {
getDetails().level = level;
}
}
/**
* @see DirectoryKladrType
* @param type
* @return
*/
public boolean isType(String type){
return getTitle().equalsIgnoreCase(type);
}
public void setExtKey(String extkey) throws ClipsException{
saveExtKeyDB(extkey);
}
final private void saveExtKeyDB(String extkey) throws ClipsException {
if(isInDirectory()) {
AddressObjectTypeDetails newDetails = getDetailsCopy();
newDetails.external_key = extkey;
saveDetails(newDetails);
} else {
getDetails().external_key = extkey;
}
}
public String getExtKey() {
return getDetails().external_key;
}
}