00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "thirdparty/GroupList.h"
00024
00025 namespace cmlabs {
00026
00027 GroupList::GroupList() {
00028 }
00029
00030 GroupList::GroupList(JString xml) {
00031 if (!Object::fromXML(xml)) {
00032 }
00033 }
00034
00035 GroupList::GroupList(XMLNode* node) {
00036 if (!fromXML(node)) {
00037 }
00038 }
00039
00040 GroupList::~GroupList() {}
00041
00042 Object* GroupList::clone() const {
00043 GroupList* fv = new GroupList();
00044 *fv = *this;
00045 return fv;
00046 }
00047
00048 JString GroupList::print() {
00049 JString str = JString::format("List of %d groups:\n", list.getCount());
00050
00051 Group* group;
00052 for (int n=0; n<list.getCount(); n++) {
00053 group = (Group*) list.get(n);
00054 if (group != NULL) {
00055 str += JString::format(" %3d: %s\n", n, (char*) group->print());
00056 }
00057 }
00058 return str;
00059 }
00060
00061 JString GroupList::toXML() {
00062 return JString::format("<grouplist>\n%s</grouplist>", (char*) list.toXML().indentXML());
00063 }
00064
00065 bool GroupList::fromXML(XMLNode* node) {
00066 if (node == NULL) {
00067 return false;
00068 }
00069 if (!node->getTag().equalsIgnoreCase("grouplist"))
00070 return false;
00071
00072 XMLNode* xmlNode = node->getChildNode("collection");
00073 if (xmlNode == NULL)
00074 return false;
00075 if (!list.fromXML(xmlNode))
00076 return false;
00077
00078 return true;
00079 }
00080
00081 bool GroupList::addGroup(Group* group) {
00082 return list.add(group);
00083 }
00084
00085 bool GroupList::removeGroup(Group* group) {
00086 return removeGroup(list.getPos(group));
00087 }
00088
00089 bool GroupList::removeGroup(int pos) {
00090 return list.remove(pos);
00091 }
00092
00093 bool GroupList::replaceGroup(Group* oldGroup, Group* newGroup) {
00094 return list.replace(list.getPos(oldGroup), newGroup);
00095 }
00096
00097 bool GroupList::replaceGroup(int pos, Group* group) {
00098 return list.replace(pos, group);
00099 }
00100
00101 Group* GroupList::getGroup(int pos) {
00102 return (Group*) list.get(pos);
00103 }
00104
00105 Group* GroupList::operator[](int pos) {
00106 return (Group*) list.get(pos);
00107 }
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 SubGroupPairList::SubGroupPairList() {
00133 }
00134
00135 SubGroupPairList::SubGroupPairList(JString xml) {
00136 if (!Object::fromXML(xml)) {
00137 }
00138 }
00139
00140 SubGroupPairList::SubGroupPairList(XMLNode* node) {
00141 if (!fromXML(node)) {
00142 }
00143 }
00144
00145 SubGroupPairList::~SubGroupPairList() {}
00146
00147 Object* SubGroupPairList::clone() const {
00148 SubGroupPairList* fv = new SubGroupPairList();
00149 *fv = *this;
00150 return fv;
00151 }
00152
00153 JString SubGroupPairList::print() {
00154 JString str = JString::format("List of %d pairs:\n", list.getCount());
00155
00156 JString parent, child;
00157 for (int n=0; n<list.getCount(); n++) {
00158 child = list.getKey(n);
00159 parent = list.get(n);
00160 str += JString::format(" %s is in %s\n", (char*) child, (char*) parent);
00161 }
00162 return str;
00163 }
00164
00165 JString SubGroupPairList::toXML() {
00166 return JString::format("<subgrouppairlist>\n%s</subgrouppairlist>", (char*) list.toXML().indentXML());
00167 }
00168
00169 bool SubGroupPairList::fromXML(XMLNode* node) {
00170 if (node == NULL) {
00171 return false;
00172 }
00173 if (!node->getTag().equalsIgnoreCase("SubGroupPairList"))
00174 return false;
00175
00176 XMLNode* xmlNode = node->getChildNode("collection");
00177 if (xmlNode == NULL)
00178 return false;
00179 if (!list.fromXML(xmlNode))
00180 return false;
00181
00182 return true;
00183 }
00184
00185
00186
00187 bool SubGroupPairList::addPair(JString parentGroupID, JString childGroupID) {
00188 return list.put(childGroupID, parentGroupID);
00189 }
00190
00191 JString SubGroupPairList::getChildGroupID(int pos) {
00192 return list.get(pos);
00193 }
00194
00195 Collection SubGroupPairList::getChildGroupIDs() {
00196 return list.getAllKeys();
00197 }
00198
00199 JString SubGroupPairList::getParentGroupOf(JString groupID) {
00200 return list.get(groupID);
00201 }
00202
00203 }
00204