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; }
/** * @param d_SK * @param crt_justification * @param voting_constituent * @param alreadySupported */ public static void addJustificationWithAnySupportToDSSK( DD_SK d_SK, D_Justification crt_justification, D_Constituent voting_constituent, boolean alreadySupported) { addJustificationToDSSK(d_SK, crt_justification); if (alreadySupported) return; D_Motion crt_motion = crt_justification.getMotionForce(); D_Vote my_vote = D_Vote.getOneBroadcastedSupportForJustification( crt_motion, crt_justification, voting_constituent, crt_motion.getSupportChoice()); if (my_vote != null) { addVoteIfNew(d_SK, my_vote); addConstituentToDSSK(d_SK, my_vote.getConstituent_force()); } }