public SpinningTopSpaceView(SpinningTop rigidBody) {
   this.rigidBody = rigidBody;
   frame.setSize(600, 600);
   // panel.setDisplayMode(VisualizationHints.DISPLAY_NO_PERSPECTIVE);
   double d = 4;
   frame.setPreferredMinMax(-d, d, -d, d, -d, d);
   frame.setDecorationType(
       org.opensourcephysics.display3d.core.VisualizationHints.DECORATION_AXES);
   orientation.getStyle().setFillColor(java.awt.Color.RED);
   orientationTrace.getStyle().setLineColor(java.awt.Color.BLACK);
   base.setSizeXYZ(2, 2, 0.15);
   base.getStyle().setResolution(new Resolution(4, 12, 1));
   base.getStyle().setFillColor(java.awt.Color.RED);
   base.setZ(-3);
   post.setSizeXYZ(0.2, 0.2, 3);
   post.getStyle().setResolution(new Resolution(2, 10, 15));
   post.setZ(-1.5); // shift by half the length
   post.getStyle().setFillColor(java.awt.Color.RED);
   shaft.setSizeXYZ(0.2, 0.2, 3);
   shaft.setXYZ(0, 0, 1.5);
   shaft.getStyle().setResolution(new Resolution(1, 10, 15));
   disk.setSizeXYZ(1.75, 1.75, 0.25);
   disk.setXYZ(0, 0, 2.0);
   disk.getStyle().setResolution(new Resolution(4, 12, 1));
   topGroup.addElement(shaft);
   topGroup.addElement(disk);
   topGroup.setTransformation(rigidBody.getTransformation());
   frame.addElement(base);
   frame.addElement(post);
   frame.addElement(orientation);
   frame.addElement(orientationTrace);
   frame.addElement(topGroup);
 }
Пример #2
0
  static <E> Subgroup<E> trivialSubgroup(Group<E> group) {
    Group<E> identity = Groups.from(group.op(), Collections.singleton(group.op().identity()));
    return new Subgroup<E>() {

      @Override
      public Group<E> getSubgroup() {
        return identity;
      }

      @Override
      public Group<E> getOvergroup() {
        return group;
      }

      @Override
      public Coset<E> leftCoset(E e) {
        return (group.isAbelian() ? Coset.Side.BOTH : Coset.Side.LEFT).singletonCoset(group, e);
      }

      @Override
      public Coset<E> rightCoset(E e) {
        return (group.isAbelian() ? Coset.Side.BOTH : Coset.Side.LEFT).singletonCoset(group, e);
      }
    };
  }
Пример #3
0
  /**
   * 사용자그룹(tm_usergroup)에서 보여준다
   *
   * @param groupID
   * @return
   * @throws DataAccessException
   */
  public Group viewGroup(String groupID) throws DataAccessException {

    Group group = new Group();
    Map<String, Object> resultMap = null;
    String sql =
        QueryUtil.getStringQuery(
            "admin_sql", "admin.usergroup.viewgroup"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.

    // 넘겨받은 파라미터를 세팅한다.
    Map<String, Object> param = new HashMap<String, Object>();
    param.put("groupID", groupID);

    // SQL문이 실행된다.
    try {
      resultMap = getSimpleJdbcTemplate().queryForMap(sql, param);
    } catch (EmptyResultDataAccessException e1) {
    }
    if (resultMap != null) {
      group.setGroupID((String) (resultMap.get("groupID")));
      group.setGroupName((String) (resultMap.get("groupName")));
      group.setDescription((String) (resultMap.get("description")));

    } else {
      group.setGroupID("0");
    }
    return group;
  }
  @Override
  public void start(Stage primaryStage) {
    primaryStage.setTitle("CoAP Explorer");
    Group root = new Group();
    Scene scene = new Scene(root, 800, 600);

    TextArea hexArea = new TextArea();
    TextArea binArea = new TextArea();

    CoapPacket packet = new CoapPacket();
    packet.setPayload("PAYLOAD");
    packetProp.setValue(packet);

    binArea.textProperty().bindBidirectional(packetProp, new AsciiConverter());

    hexArea.textProperty().bindBidirectional(packetProp, new HexConverter());
    hexArea.setEditable(false);
    hexArea.setFont(javafx.scene.text.Font.font(Font.MONOSPACED));

    VBox vbox = new VBox();
    vbox.setPadding(new Insets(10));
    vbox.setSpacing(8);

    VBox.setMargin(hexArea, new Insets(0, 0, 0, 8));
    vbox.getChildren().add(hexArea);
    VBox.setMargin(binArea, new Insets(0, 0, 0, 8));
    vbox.getChildren().add(binArea);

    root.getChildren().add(vbox);

    primaryStage.setScene(scene);
    primaryStage.show();
  }
Пример #5
0
  public Group getGroupForPlayer(String playerName) {
    for (Group group : groups) {
      if (group.isInGroup(playerName)) return group;
    }

    return null;
  }
Пример #6
0
  @Test
  public void testAddMultipleContacts() throws Exception {
    groupService.create(group);
    groupService.addAggregation(committee, group);

    group = groupService.findById(group.getId());
    contactService.addToGroup(topLevel, group);

    Contact anotherContact = new Contact();
    anotherContact.setFirstName("Another");
    anotherContact.setEmail("*****@*****.**");
    contactService.create(anotherContact);

    contactService.addToGroup(anotherContact, group);
    group = groupService.findById(group.getId());
    assertEquals(2, group.getTopLevelMembers().size());

    anotherContact = contactService.findById(anotherContact.getId());
    topLevel = contactService.findById(topLevel.getId());

    assertEquals(1, anotherContact.getGroups().size());
    assertEquals(1, topLevel.getGroups().size());

    groupService.delete(group);

    anotherContact = contactService.findById(anotherContact.getId());
    topLevel = contactService.findById(topLevel.getId());

    assertEquals(0, anotherContact.getGroups().size());
    assertEquals(0, topLevel.getGroups().size());
  }
Пример #7
0
  @Test
  @Transactional
  public void testAddContactToGroupAndGroupConstituent() throws Exception {

    groupService.create(group);
    groupService.addAggregation(committee, group);

    Contact contact = new Contact();
    contact.setFirstName("Test Contact");
    contact.setEmail("*****@*****.**");
    contactService.create(contact);

    contactService.addContactToCommittee(contact, committee);
    contactService.addToGroup(contact, group);

    contact = contactService.findById(contact.getId());
    assertTrue(contact.getGroups().contains(group));
    assertTrue(contact.getCommittees().contains(committee));

    committee = committeeService.findById(committee.getId());
    assertTrue(committee.getMembers().contains(contact));

    group = groupService.findById(group.getId());
    assertTrue(group.getTopLevelMembers().contains(contact));
  }
 public Group getGroupbyName(String groupName) {
   Group group = new Group();
   for (Group g : groups) {
     if (g.hasName(groupName)) group = g;
   }
   return group;
 }
  // Returns False if cannot add to group
  public boolean addUsertoGroup(String userName, String groupName) {
    Group group = new Group(groupName);
    boolean containsGroup = false;
    for (Group g : groups) {
      if (g.groupName.equalsIgnoreCase(groupName)) {
        group = g;
        containsGroup = true;
      }
    }

    if (!containsGroup) groups.add(group);

    User user = new User(userName);

    if (user.isAnonymous()) return false;

    if (this.containsUser(userName)) {
      for (User u : users) {
        if (u.name == userName) {
          user = u;
        }
      }
    } else {
      return false;
    }

    user.group.removeUser(user);
    if (user.group.isEmpty()) {
      groups.remove(user.group);
    }
    group.addUser(user);

    return true;
  }
  public class FqnObjElements extends AbstractParserRuleElementFinder {
    private final ParserRule rule =
        (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "FqnObj");
    private final Group cGroup = (Group) rule.eContents().get(1);
    private final Keyword cFqnKeyword_0 = (Keyword) cGroup.eContents().get(0);
    private final Assignment cNameAssignment_1 = (Assignment) cGroup.eContents().get(1);
    private final RuleCall cNameFQNParserRuleCall_1_0 =
        (RuleCall) cNameAssignment_1.eContents().get(0);

    // FqnObj:
    //	"fqn" name=FQN;
    public ParserRule getRule() {
      return rule;
    }

    // "fqn" name=FQN
    public Group getGroup() {
      return cGroup;
    }

    // "fqn"
    public Keyword getFqnKeyword_0() {
      return cFqnKeyword_0;
    }

    // name=FQN
    public Assignment getNameAssignment_1() {
      return cNameAssignment_1;
    }

    // FQN
    public RuleCall getNameFQNParserRuleCall_1_0() {
      return cNameFQNParserRuleCall_1_0;
    }
  }
  public class EnumerationElements extends AbstractParserRuleElementFinder {
    private final ParserRule rule =
        (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "Enumeration");
    private final Group cGroup = (Group) rule.eContents().get(1);
    private final Keyword cEnumKeyword_0 = (Keyword) cGroup.eContents().get(0);
    private final Assignment cValAssignment_1 = (Assignment) cGroup.eContents().get(1);
    private final RuleCall cValEnum1EnumRuleCall_1_0 =
        (RuleCall) cValAssignment_1.eContents().get(0);
    private final Group cGroup_2 = (Group) cGroup.eContents().get(2);
    private final Keyword cCommaKeyword_2_0 = (Keyword) cGroup_2.eContents().get(0);
    private final Assignment cValAssignment_2_1 = (Assignment) cGroup_2.eContents().get(1);
    private final RuleCall cValEnum1EnumRuleCall_2_1_0 =
        (RuleCall) cValAssignment_2_1.eContents().get(0);

    // Enumeration:
    //	"enum" val+=Enum1+ ("," val+=Enum1)*;
    public ParserRule getRule() {
      return rule;
    }

    // "enum" val+=Enum1+ ("," val+=Enum1)*
    public Group getGroup() {
      return cGroup;
    }

    // "enum"
    public Keyword getEnumKeyword_0() {
      return cEnumKeyword_0;
    }

    // val+=Enum1+
    public Assignment getValAssignment_1() {
      return cValAssignment_1;
    }

    // Enum1
    public RuleCall getValEnum1EnumRuleCall_1_0() {
      return cValEnum1EnumRuleCall_1_0;
    }

    // ("," val+=Enum1)*
    public Group getGroup_2() {
      return cGroup_2;
    }

    // ","
    public Keyword getCommaKeyword_2_0() {
      return cCommaKeyword_2_0;
    }

    // val+=Enum1
    public Assignment getValAssignment_2_1() {
      return cValAssignment_2_1;
    }

    // Enum1
    public RuleCall getValEnum1EnumRuleCall_2_1_0() {
      return cValEnum1EnumRuleCall_2_1_0;
    }
  }
  public class SpaceElements extends AbstractParserRuleElementFinder {
    private final ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "Space");
    private final Group cGroup = (Group) rule.eContents().get(1);
    private final Keyword cSpaceKeyword_0 = (Keyword) cGroup.eContents().get(0);
    private final Assignment cValAssignment_1 = (Assignment) cGroup.eContents().get(1);
    private final RuleCall cValIDTerminalRuleCall_1_0 =
        (RuleCall) cValAssignment_1.eContents().get(0);

    // Space:
    //	"space" val=ID;
    public ParserRule getRule() {
      return rule;
    }

    // "space" val=ID
    public Group getGroup() {
      return cGroup;
    }

    // "space"
    public Keyword getSpaceKeyword_0() {
      return cSpaceKeyword_0;
    }

    // val=ID
    public Assignment getValAssignment_1() {
      return cValAssignment_1;
    }

    // ID
    public RuleCall getValIDTerminalRuleCall_1_0() {
      return cValIDTerminalRuleCall_1_0;
    }
  }
Пример #13
0
 public List<Role> getAllRoles() {
   final List<Role> result = new ArrayList<Role>();
   for (final Group group : getGroups()) {
     result.addAll(group.getAssignedRoles());
   }
   return result;
 }
Пример #14
0
  @Override
  public EnergyDataHistoryQueryResult getHistory(
      Enums.HistoryType historyType, Group group, long startTime, long endTime, int interval) {
    User user = getCurrentUser();
    if (group == null || group.getId() == null) {
      logger.debug("No group specified");
      return new EnergyDataHistoryQueryResult();
    }
    // Check group history
    Group userGroup = groupService.getGroup(user, group.getId());
    if (userGroup == null) logger.error("User group is null");

    if (userGroup != null
        && (userGroup.getRole() == Group.Role.OWNER
            || userGroup.getRole() == Group.Role.READONLY)) {
      if (logger.isInfoEnabled())
        logger.info(
            "retrieving "
                + historyType
                + " history for  "
                + group
                + " "
                + startTime
                + "-"
                + endTime);
      EnergyDataHistoryQueryResult result =
          historyService.getHistory(historyType, user, group, startTime, endTime, interval);
      return result;
    }
    logger.warn("Security violation. " + user + " attempted to retrieve history for  " + group);
    return new EnergyDataHistoryQueryResult();
  }
Пример #15
0
  public class AnotherTypeElements extends AbstractParserRuleElementFinder {
    private final ParserRule rule =
        (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "AnotherType");
    private final Group cGroup = (Group) rule.eContents().get(1);
    private final Keyword cBarKeyword_0 = (Keyword) cGroup.eContents().get(0);
    private final Action cAnotherTypeAction_1 = (Action) cGroup.eContents().get(1);

    // AnotherType returns sub::AnotherType:
    //	"bar" {sub::AnotherType};
    public ParserRule getRule() {
      return rule;
    }

    // "bar" {sub::AnotherType}
    public Group getGroup() {
      return cGroup;
    }

    // "bar"
    public Keyword getBarKeyword_0() {
      return cBarKeyword_0;
    }

    // {sub::AnotherType}
    public Action getAnotherTypeAction_1() {
      return cAnotherTypeAction_1;
    }
  }
Пример #16
0
  public class AbstractCallOverridenParserRuleElements extends AbstractParserRuleElementFinder {
    private final ParserRule rule =
        (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "AbstractCallOverridenParserRule");
    private final Group cGroup = (Group) rule.eContents().get(1);
    private final Keyword cOverridemodelKeyword_0 = (Keyword) cGroup.eContents().get(0);
    private final Assignment cElementsAssignment_1 = (Assignment) cGroup.eContents().get(1);
    private final RuleCall cElementsOverridableParserRuleParserRuleCall_1_0 =
        (RuleCall) cElementsAssignment_1.eContents().get(0);

    // AbstractCallOverridenParserRule returns mm::AModel:
    //	"overridemodel" elements+=OverridableParserRule*;
    public ParserRule getRule() {
      return rule;
    }

    // "overridemodel" elements+=OverridableParserRule*
    public Group getGroup() {
      return cGroup;
    }

    // "overridemodel"
    public Keyword getOverridemodelKeyword_0() {
      return cOverridemodelKeyword_0;
    }

    // elements+=OverridableParserRule*
    public Assignment getElementsAssignment_1() {
      return cElementsAssignment_1;
    }

    // OverridableParserRule
    public RuleCall getElementsOverridableParserRuleParserRuleCall_1_0() {
      return cElementsOverridableParserRuleParserRuleCall_1_0;
    }
  }
Пример #17
0
  public class ATypeElements extends AbstractParserRuleElementFinder {
    private final ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "AType");
    private final Group cGroup = (Group) rule.eContents().get(1);
    private final Keyword cFooKeyword_0 = (Keyword) cGroup.eContents().get(0);
    private final Action cATypeAction_1 = (Action) cGroup.eContents().get(1);

    // AType returns root::AType:
    //	"foo" {root::AType};
    public ParserRule getRule() {
      return rule;
    }

    // "foo" {root::AType}
    public Group getGroup() {
      return cGroup;
    }

    // "foo"
    public Keyword getFooKeyword_0() {
      return cFooKeyword_0;
    }

    // {root::AType}
    public Action getATypeAction_1() {
      return cATypeAction_1;
    }
  }
Пример #18
0
  public class OverridableParserRuleElements extends AbstractParserRuleElementFinder {
    private final ParserRule rule =
        (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "OverridableParserRule");
    private final Group cGroup = (Group) rule.eContents().get(1);
    private final Keyword cElementKeyword_0 = (Keyword) cGroup.eContents().get(0);
    private final Assignment cNameAssignment_1 = (Assignment) cGroup.eContents().get(1);
    private final RuleCall cNameIDTerminalRuleCall_1_0 =
        (RuleCall) cNameAssignment_1.eContents().get(0);

    // OverridableParserRule returns mm::AType:
    //	"element" name=ID;
    public ParserRule getRule() {
      return rule;
    }

    // "element" name=ID
    public Group getGroup() {
      return cGroup;
    }

    // "element"
    public Keyword getElementKeyword_0() {
      return cElementKeyword_0;
    }

    // name=ID
    public Assignment getNameAssignment_1() {
      return cNameAssignment_1;
    }

    // ID
    public RuleCall getNameIDTerminalRuleCall_1_0() {
      return cNameIDTerminalRuleCall_1_0;
    }
  }
Пример #19
0
  @Test
  @Transactional
  public void testRemoveContactFromEventMultipleGroups() throws Exception {

    groupService.create(group);
    groupService.addAggregation(event, group);

    Group secondGroup = new Group();
    secondGroup.setGroupName("Second Group");
    groupService.create(secondGroup);
    groupService.addAggregation(event, secondGroup);

    Contact newContact = new Contact();
    newContact.setFirstName("Fresh Contact");
    newContact.setEmail("Fresh email");
    contactService.create(newContact);

    event = eventService.findById(event.getId());
    contactService.attendEvent(newContact, event);

    newContact = contactService.findById(newContact.getId());
    contactService.unattendEvent(newContact, event);

    event = eventService.findById(event.getId());
    assertFalse(event.getAttendees().contains(newContact));

    newContact = contactService.findById(newContact.getId());
    assertFalse(newContact.getAttendedEvents().contains(event));
  }
  @Override
  public OutcomeReportResult createReport(OutcomeReportCriteria reportCriteria, Object data) {

    OutcomeReportResult result = new OutcomeReportResult();
    List<Transaction> transactions = (List<Transaction>) data;

    IGroupStrategy<Account, Transaction> groupStrategy = new TransactionAccountGroupStrategy();

    GroupContainer<Account, Transaction> groupContainer =
        groupStrategy.group(reportCriteria, transactions);

    // aggregate total amounts
    BigDecimal totalOutcome = BigDecimal.ZERO;
    for (Group<Account, Transaction> group : groupContainer.getGroupList()) {
      BigDecimal outcome = BigDecimal.ZERO;

      for (Transaction t : group.getItems()) {
        if (t.getDestinationAccount().getType().equals(AccountTypeEnum.OUTCOME))
          outcome = outcome.add(t.getAmount());
      }

      totalOutcome = totalOutcome.add(outcome);
      result.addResultEntry(
          0,
          outcome.doubleValue(),
          transformationService.transform(group.getKey(), AccountDTO.class));
    }

    result.setTotalOutcome(totalOutcome.doubleValue());
    return result;
  }
  private void printGroupDataSourceList(PrintWriter out, Group group) {
    DataSource ds = null;
    String dsname = null;
    String dstype = null;
    String label = null;
    out.println("<table >");
    out.println(" <caption>" + group.getGroupName() + " combination</caption>");
    out.println("<tr><th> virtual sensor name </th>");
    out.println("<th> access right</th></tr>");

    for (int j = 0; j < group.getDataSourceList().size(); j++) {
      ds = (DataSource) group.getDataSourceList().get(j);
      dsname = ds.getDataSourceName();
      dstype = ds.getDataSourceType();

      if (dstype.charAt(0) == '1') {
        label = "read";
      } else if (dstype.charAt(0) == '2') {
        label = "write";
      } else if (dstype.charAt(0) == '3') {
        label = "read/write";
      }
      out.println("<tr><td>" + dsname + "</td>");
      out.println("<td>" + label + "</td></tr>");
    }
    out.println("</table>");
  }
  public List<Group> getGroups() throws SQLException {
    List<Group> groups = new ArrayList<Group>();

    Statement stmt = null;
    ResultSet rs = null;
    try {
      stmt = con.createStatement();
      rs = stmt.executeQuery("SELECT group_id, groupName, curator, speciality FROM groups");
      while (rs.next()) {
        Group gr = new Group();
        gr.setGroupId(rs.getInt(1));
        gr.setNameGroup(rs.getString(2));
        gr.setCurator(rs.getString(3));
        gr.setSpeciality(rs.getString(4));

        groups.add(gr);
      }
    } finally {
      if (rs != null) {
        rs.close();
      }
      if (stmt != null) {
        stmt.close();
      }
    }
    return groups;
  }
  @Test
  public void testCreateGroupMembership() {
    Account account = new Account();
    account.setGivenName("Anthony");
    account.setSurname("Wolski");
    account.setEmail("*****@*****.**");
    account.setPassword("password");
    account.setUsername("awolski");
    accountService.createAccount(account);

    Group group = new Group();
    group.setName("Test Group");
    accountService.createGroup(group);

    GroupMembership groupMembership = new GroupMembership(account, group);
    accountService.createGroupMembership(groupMembership);

    List<Account> groupAccounts = accountService.getGroupAccounts(group.getId());
    assertEquals(1, groupAccounts.size());

    List<Group> accountGroups = accountService.getAccountGroups(account.getId());
    assertEquals(1, accountGroups.size());

    List<GroupMembership> groupGroupMemberships =
        accountService.getGroupGroupMemberships(group.getId());
    assertEquals(1, groupGroupMemberships.size());

    List<GroupMembership> accountGroupMemberships =
        accountService.getAccountGroupMemberships(account.getId());
    assertEquals(1, accountGroupMemberships.size());
  }
Пример #24
0
  public void parseGroup(Group g) throws Hdf5Exception, EndOfSequenceException {
    startGroup(g);

    java.util.List members = g.getMemberList();

    // NOTE: parsing contents twice to ensure subgroups are handled before datasets
    // This is mainly because synapse_props groups will need to be parsed before dataset of
    // connections

    for (int j = 0; j < members.size(); j++) {
      HObject obj = (HObject) members.get(j);

      if (obj instanceof Group) {
        Group subGroup = (Group) obj;

        logger.logComment("---------    Found a sub group: " + subGroup.getName());

        parseGroup(subGroup);
      }
    }

    for (int j = 0; j < members.size(); j++) {
      HObject obj = (HObject) members.get(j);

      if (obj instanceof Dataset) {
        Dataset ds = (Dataset) obj;

        logger.logComment("Found a dataset: " + ds.getName());

        dataSet(ds);
      }
    }

    endGroup(g);
  }
Пример #25
0
  public Group getGroup(String groupName) {
    for (Group g : groups) {
      if (g.getName().equalsIgnoreCase(groupName)) return g;
    }

    return null;
  }
Пример #26
0
  /**
   * @param group the group to set
   * @param updatePerms if we are to trigger a superperms update.
   */
  public void setGroup(Group group, Boolean updatePerms) {

    if (!this.getDataSource().groupExists(group.getName())) {
      getDataSource().addGroup(group);
    }
    group = getDataSource().getGroup(group.getName());
    String oldGroup = this.group;
    this.group = group.getName();
    flagAsChanged();
    if (GroupManager.isLoaded()) {
      if (!GroupManager.BukkitPermissions.isPlayer_join() && (updatePerms))
        GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer());

      // Do we notify of the group change?
      String defaultGroupName = getDataSource().getDefaultGroup().getName();
      // if we were not in the default group
      // or we were in the default group and the move is to a different
      // group.
      boolean notify =
          (!oldGroup.equalsIgnoreCase(defaultGroupName))
              || ((oldGroup.equalsIgnoreCase(defaultGroupName))
                  && (!this.group.equalsIgnoreCase(defaultGroupName)));

      if (notify)
        GroupManager.notify(
            this.getName(), String.format(" moved to the group %s.", group.getName()));

      GroupManager.getGMEventHandler().callEvent(this, Action.USER_GROUP_CHANGED);
    }
  }
Пример #27
0
  public Flexible copyToGroup(String group) {

    String newName;
    if (group.equals(nullString)) newName = Group.substractObjectName(getName());
    else newName = group + Constants.GROUP_SEPARATOR + Group.substractObjectName(getName());

    // object with new name already exists, add suffix ///!!!
    while (Group.getRoot().findObject(newName, true) != null)
      newName = StringUtils.incrementName(newName, Constants.COPY_SUFFIX);

    Box grBox =
        new Box(
            newName,
            null,
            startVertex.getX(),
            startVertex.getY(),
            endVertex.getX(),
            endVertex.getY());
    grBox.setColor(getColor());
    Group.getRoot().addSubObject(newName, grBox, true);

    // ViewState view = ViewState.getInstance();
    // grBox.move(20 - view.getRx(), 20 - view.getRy());

    unconditionalValidation();
    return grBox;
  }
Пример #28
0
  public boolean addSubGroup(Group subGroup) {

    // Don't allow adding a subgroup if it's already set as the primary.
    if (this.group.equalsIgnoreCase(subGroup.getName())) {
      return false;
    }
    // User already has this subgroup
    if (containsSubGroup(subGroup)) return false;

    // If the group doesn't exists add it
    if (!this.getDataSource().groupExists(subGroup.getName())) {
      getDataSource().addGroup(subGroup);
    }

    subGroups.add(subGroup.getName());
    flagAsChanged();
    if (GroupManager.isLoaded()) {
      if (!GroupManager.BukkitPermissions.isPlayer_join())
        GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer());
      GroupManager.getGMEventHandler().callEvent(this, Action.USER_SUBGROUP_CHANGED);
    }
    return true;

    // subGroup = getDataSource().getGroup(subGroup.getName());
    // removeSubGroup(subGroup);
    // subGroups.add(subGroup.getName());
  }
 /**
  * Deletes the authorization after removing it from any groups that might be referring to it
  *
  * @param em the entity manager reference
  * @param id the ID for authorizatino entity
  * @throws PersistenceException if there were any errors deleting the authorization
  */
 static void deleteAuthorization(EntityManager em, long id) throws PersistenceException {
   Authorization auth = em.find(Authorization.class, id);
   // may return null, if this entity is not saved, in which
   // case don't do anything.
   if (auth == null) {
     return;
   }
   // Iterate through all groups and remove the authorization from them
   Set<SummaryGroup> groups = auth.getGroups();
   if (groups != null) {
     for (SummaryGroup g : groups) {
       Group group = new SingleGroupQuery(g.getId()).fetch();
       Set<Authorization> auths = group.getAuthorizations();
       HashSet<Authorization> updated = new HashSet<Authorization>();
       for (Authorization a : auths) {
         if (a.getId() != auth.getId()) {
           updated.add(a);
         }
       }
       group.setAuthorizations(updated);
       group.save();
     }
   }
   em.remove(em.getReference(Authorization.class, auth.getId()));
 }
Пример #30
0
 private Vote encrypt(byte[] msg, int i) {
   GroupMember key = new GroupMember(group.groupPow(g.member, intToByteArray(i)));
   GroupMember message =
       new GroupMember(group.groupMult(msg, group.groupPow(h.member, intToByteArray(i))));
   Vote vote = new Vote(key, message);
   return vote;
 }