package com.vci.client.omd.linktype.itf;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import com.vci.client.omd.attribpool.ui.APClient;
|
import com.vci.client.omd.linktype.LinkTypeStart;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.omd.atm.AttribItem;
|
import com.vci.corba.omd.ltm.LinkType;
|
|
public class LinkTypeInterfaceImpl implements LinkTypeInterface {
|
String[] allAttributes = null;
|
|
@Override
|
public String[] getDetailAttributesByLinkTypeName(String name) {
|
|
// 获取系统属性
|
String[] sysAttibutes = { "OID", "Creator", "CreateTime", "LastModifier", "LASTMODIFYTIME", "F_OID",
|
"F_REVISIONOID", "F_NAMEOID", "F_BtwName", "T_OID", "T_REVISIONOID", "T_NAMEOID", "T_BtwName", "TS" };
|
String[] nonAttibutes = null;
|
List<String> list = new ArrayList<String>();
|
LinkType[] linkTypes;
|
|
linkTypes = getLinkTypes();
|
for (LinkType linkType : linkTypes) {
|
if (linkType.name.equals(name)) {
|
String[] attributes = linkType.attributes;
|
for (String attrbute : attributes) {
|
list.add(attrbute);
|
}
|
}
|
}
|
nonAttibutes = list.toArray(new String[0]);
|
allAttributes = arraycat(sysAttibutes, nonAttibutes);
|
|
return allAttributes;
|
}
|
|
/**
|
* 合并数组
|
*
|
* @param dgc1
|
* @param dgc2
|
* @return
|
*/
|
public String[] arraycat(String[] dgc1, String[] dgc2) {
|
try {
|
int len1 = 0;
|
int len2 = 0;
|
if (dgc1 != null)
|
len1 = dgc1.length;
|
if (dgc2 != null)
|
len2 = dgc2.length;
|
if (len1 + len2 > 0)
|
allAttributes = new String[len1 + len2];
|
if (len1 > 0)
|
System.arraycopy(dgc1, 0, allAttributes, 0, len1);
|
if (len2 > 0)
|
System.arraycopy(dgc2, 0, allAttributes, len1, len2);
|
return allAttributes;
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
@Override
|
public String[] getSystemAttributes() {
|
String[] sysAttibutes = { "OID", "Creator", "CreateTime", "LastModifier", "LASTMODIFYTIME", "F_OID",
|
"F_REVISIONOID", "F_NAMEOID", "F_BtwName", "T_OID", "T_REVISIONOID", "T_NAMEOID", "T_BtwName", "TS" };
|
return sysAttibutes;
|
}
|
|
@Override
|
public AttribItem[] getNonSystemAttributesByLinkTypeName(String name) {
|
|
try {
|
com.vci.corba.omd.atm.AttribItem[] abItems = null;
|
List<String> abNames = new ArrayList<String>();
|
LinkType[] linkTypes = LinkTypeStart.getService().getLinkTypes();
|
for (LinkType linkType : linkTypes) {
|
if (linkType.name.equals(name)) {
|
String[] attributes = linkType.attributes;
|
for (String attribute : attributes) {
|
abNames.add(attribute);
|
}
|
abItems = APClient.getService().getAttribItemsByNames(abNames.toArray(new String[0]));
|
}
|
}
|
return abItems;
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return new AttribItem[0];
|
}
|
|
@Override
|
public LinkType getLinkTypeByName(String name) {
|
|
LinkType[] linkTypes = getLinkTypes();
|
for (LinkType linkType : linkTypes) {
|
if (linkType.name.equals(name)) {
|
return linkType;
|
}
|
|
}
|
return null;
|
}
|
|
@Override
|
public String getRelationByLtName(String ltName) {
|
|
LinkType[] linkTypes = getLinkTypes();
|
for (LinkType lt : linkTypes) {
|
if (lt.name.equals(ltName)) {
|
return lt.relation;
|
}
|
}
|
return null;
|
}
|
|
private LinkType[] getLinkTypes() {
|
try {
|
return LinkTypeStart.getService().getLinkTypes();
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
|
return new LinkType[0];
|
}
|
|
// public String[] getNonSystemAttributesByLinkTypeName(String name) {
|
// try {
|
// String[] nonAttibutes = null;
|
// List<String> list = new ArrayList<String>();
|
// LinkType[] linkTypes = LinkTypeStart.getService().getLinkTypes();
|
// for(LinkType linkType:linkTypes){
|
// if(linkType.name.equals(name)){
|
// AttribItem[] attribItems = linkType.attribNameArray;
|
// for(AttribItem attrbute:attribItems){
|
// list.add(attrbute.name);
|
// }
|
// }
|
// }
|
// nonAttibutes = list.toArray(new String[0]);
|
// return nonAttibutes;
|
// } catch (PlmLinkTypeError e) {
|
// // TODO Auto-generated catch block
|
// e.printStackTrace();
|
// }
|
// return null;
|
// }
|
|
}
|