public void setOrg(long _orgID, D_Organization org) throws P2PDDSQLException { if (DEBUG) System.out.println("ConstituentsTest:setOrg: id=" + _orgID); organization = org; if (tree != null) { tree.clean(); } organizationID = _orgID; constituentID = net.ddp2p.common.config.Identity.getDefaultConstituentIDForOrg(organizationID); global_constituentID = D_Constituent.getGIDFromLID(constituentID); if (global_constituentID == null) { constituentID = -1; MainFrame.status.setMeConstituent(null); } else { MainFrame.status.setMeConstituent(D_Constituent.getConstByLID(constituentID, true, false)); } ConstituentsModel cm = new ConstituentsModel( Application.db, organizationID, constituentID, global_constituentID, org, this); tree = new ConstituentsTree(cm); long cID = cm.getConstituentIDMyself(); cm.expandConstituentID(tree, ((cID <= 0) ? null : ("" + cID)), true); JScrollPane scrollPane = new JScrollPane(tree); scrollPane.setPreferredSize(new Dimension(200, 200)); this.removeAll(); if (org_label != null) { org_label.setText(getLabelText()); add(getNorthComponent(), BorderLayout.NORTH); disableRefresh(); this.refresh_button.addActionListener(this); // add(org_label, BorderLayout.NORTH); } add(scrollPane, BorderLayout.CENTER); }
@Override public DD_SK decode(Decoder dec) throws ASN1DecoderFail { String default_orgGID = null; String default_orgGIDH = null; Decoder d = dec.getContent(); if (d.getTypeByte() == DD.TAG_AP0) version = d.getFirstObject(true).getInteger(DD.TAG_AP0).intValue(); if (d.getTypeByte() == DD.TAG_AC0) sk = d.getFirstObject(true).getSequenceOfAL(DD_SK_Entry.getASN1Tag(), new DD_SK_Entry()); if (d.getTypeByte() == DD.TAG_AC1) peer = d.getFirstObject(true).getSequenceOfAL(D_Peer.getASN1Type(), D_Peer.getEmpty()); if (d.getTypeByte() == DD.TAG_AC2) { org = d.getFirstObject(true) .getSequenceOfAL(D_Organization.getASN1Type(), D_Organization.getEmpty()); if (org.size() == 1) { default_orgGID = org.get(0).getGID(); default_orgGIDH = org.get(0).getGIDH(); if (DEBUG) System.out.println( "DD_SK: has a GID for orgs: " + default_orgGID + " H=" + default_orgGIDH); } } if (d.getTypeByte() == DD.TAG_AC3) neigh = d.getFirstObject(true) .getSequenceOfAL(D_Neighborhood.getASN1Type(), D_Neighborhood.getEmpty()); if (d.getTypeByte() == DD.TAG_AC4) constit = d.getFirstObject(true) .getSequenceOfAL(D_Constituent.getASN1Type(), D_Constituent.getEmpty()); if (d.getTypeByte() == DD.TAG_AC5) witn = d.getFirstObject(true).getSequenceOfAL(D_Witness.getASN1Type(), D_Witness.getEmpty()); if (d.getTypeByte() == DD.TAG_AC6) { moti = d.getFirstObject(true).getSequenceOfAL(D_Motion.getASN1Type(), D_Motion.getEmpty()); for (D_Motion m : moti) { if (m.getOrganizationGIDH() == null) { if (_DEBUG) System.out.println("DD_SK: put a GIDH for " + m); m.setOrganizationGID(default_orgGIDH); if (_DEBUG) System.out.println("DD_SK: did put a GIDH for " + m); } else if (DEBUG) System.out.println("DD_SK: had a GIDH for " + m); } } if (d.getTypeByte() == DD.TAG_AC7) just = d.getFirstObject(true) .getSequenceOfAL(D_Justification.getASN1Type(), D_Justification.getEmpty()); if (d.getTypeByte() == DD.TAG_AC8) vote = d.getFirstObject(true).getSequenceOfAL(D_Vote.getASN1Type(), D_Vote.getEmpty()); if (d.getTypeByte() == DD.TAG_AC10) tran = d.getFirstObject(true) .getSequenceOfAL(D_Translations.getASN1Type(), D_Translations.getEmpty()); if (d.getTypeByte() == DD.TAG_AP1) sender = D_Peer.getEmpty().decode(d.getFirstObject(true)); if (d.getTypeByte() == DD.TAG_AP2) signature = d.getFirstObject(true).getBytes(DD.TAG_AP2); return this; }
public static boolean addMotionToDSSK(DD_SK d_SK, D_Motion crt_motion) { if (crt_motion == null) return false; // skip if no GID String mGID = crt_motion.getGID(); if (mGID == null) return false; // skip if already in for (D_Motion old_m : d_SK.moti) { if (Util.equalStrings_and_not_null(old_m.getGID(), mGID)) return false; } D_Organization org = crt_motion.getOrganization(); if (org == null) return false; d_SK.moti.add(crt_motion); D_Constituent constituent = crt_motion.getConstituent(); addConstituentToDSSK(d_SK, constituent); addOrganizationToDSSK(d_SK, org); // identify myself D_Constituent crt_constituent = DD.getCrtConstituent(crt_motion.getOrganizationLID()); long _constituentID_myself = -1; if (crt_constituent != null) { _constituentID_myself = crt_constituent.getLID(); } // find a vote by me or supporters D_Vote my_vote = null; if (_constituentID_myself > 0) { try { my_vote = D_Vote.getOpinionForMotion(crt_motion.getLIDstr(), _constituentID_myself); } catch (P2PDDSQLException e) { e.printStackTrace(); } } // if I did not vote this, find any support by someone else if (my_vote == null) { my_vote = D_Vote.getOneBroadcastedSupportForMotion(crt_motion, null, crt_motion.getSupportChoice()); } if (my_vote != null) { addVoteIfNew(d_SK, my_vote); addConstituentToDSSK(d_SK, my_vote.getConstituent_force()); // crt_constituent); D_Justification j = my_vote.getJustificationFromObjOrLID(); addJustificationToDSSK(d_SK, j); } return true; }
@Override public String getNiceDescription() { String result = ""; for (DD_SK_Entry _sk : sk) result += "SK[: sk=" + _sk.name + "]"; // Util.concat(sk, ";;;", "NULL"); for (D_Peer _peer : peer) result += " Safe=[" + _peer.getName() + "]"; for (D_Organization _org : org) result += " Org=[" + _org.getName() + "]"; for (D_Constituent _constit : constit) result += " Cons=[" + _constit.getNameFull() + "]"; for (D_Witness _witn : witn) result += " Witn=[" + _witn.witnessed_global_constituentID + "]"; for (D_Motion _moti : moti) result += " Moti=[" + _moti.getTitleStrOrMy() + "]"; for (D_Justification _just : just) result += " Just=[" + _just.getTitleStrOrMy() + "]"; for (D_News _news : news) result += " News=[" + _news.getTitleStrOrMy() + "]"; for (D_Vote _vote : vote) result += " Vote=[" + _vote.getChoice() + " " + _vote.getMotionGID() + "]"; // to implement if (tran.size() > 0) result += " tran=" + Util.concat(tran, ",,,", "NULL"); result += "]"; return result; }
public static void addConstituentToDSSK(DD_SK d_SK, D_Constituent constituent) { if (constituent == null) return; for (D_Constituent c : d_SK.constit) { if (c == constituent) return; if (c.getLID() == constituent.getLID()) return; } d_SK.constit.add(constituent); addOrganizationToDSSK(d_SK, constituent.getOrganization()); constituent.loadNeighborhoods(D_Constituent.EXPAND_ALL); D_Neighborhood[] n = constituent.getNeighborhood(); if (n != null) { for (D_Neighborhood _n : n) { // could also add a witness for the neighborhood (with its source... if it is me) addNeighborhoodToDSSK(d_SK, _n); } } // constituent.setNeighborhood(null); }
public String getSurname() { if (constituent != null) return constituent.getSurname(); return surname; }
public String getGivenName() { if (constituent != null) return constituent.getForename(); return given_name; }
public String getSlogan() { if (constituent != null) return constituent.getSlogan(); return slogan; }
public long getC_LID() { if (constituent != null) return constituent.getLID(); return constituentLID; }
public String getC_GID() { if (constituent != null) return constituent.getGID(); return cGID; }
public DisplayableIconObject getIcon() { if (constituent != null) return displayableIcon(constituent.getIconObject()); return icon; }