Example usage for java.util SortedSet add

List of usage examples for java.util SortedSet add

Introduction

In this page you can find the example usage for java.util SortedSet add.

Prototype

boolean add(E e);

Source Link

Document

Adds the specified element to this set if it is not already present (optional operation).

Usage

From source file:de.interactive_instruments.ShapeChange.Target.FeatureCatalogue.FeatureCatalogue.java

/**
 * @param i/* w  w  w.  j  a v  a2  s . c  om*/
 * @param type
 * @param op
 * @return the diffs with the given ElementType and Operation for the given
 *         Info object, if such diffs exist; can be empty but not
 *         <code>null</code>
 */
private SortedSet<DiffElement> getDiffs(Info i, ElementType type, Operation op) {

    SortedSet<DiffElement> result = new TreeSet<DiffElement>();

    if (diffs != null && diffs.get(i) != null) {

        for (DiffElement diff : diffs.get(i)) {
            if (diff.subElementType == type && diff.change == op) {
                result.add(diff);
            }
        }
    }

    return result;
}

From source file:com.projity.pm.task.Project.java

public int getRowHeight(SortedSet baseLines) {
    for (Iterator i = getTaskOutlineIterator(); i.hasNext();) {
        Task task = (Task) i.next();//www .  java 2s .com
        int current = Snapshottable.CURRENT.intValue();
        for (int s = 0; s < Settings.numGanttBaselines(); s++) {
            if (s == current)
                continue;
            TaskSnapshot snapshot = (TaskSnapshot) task.getSnapshot(new Integer(s));
            if (snapshot != null)
                baseLines.add(new Integer(s));
        }
    }
    int num = (baseLines.size() == 0) ? 0 : (((Integer) baseLines.last()).intValue() + 1);
    int rowHeight = GraphicConfiguration.getInstance().getRowHeight()
            + num * GraphicConfiguration.getInstance().getBaselineHeight();
    return rowHeight;
}

From source file:net.sourceforge.fenixedu.domain.StudentCurricularPlan.java

final public void resetIsFirstTimeEnrolmentForCurricularCourse(final CurricularCourse curricularCourse) {
    final SortedSet<Enrolment> enrolments = new TreeSet<Enrolment>(
            Enrolment.COMPARATOR_BY_EXECUTION_PERIOD_AND_ID);
    for (final Enrolment enrolment : getEnrolmentsSet()) {
        if (curricularCourse == enrolment.getCurricularCourse()) {
            enrolments.add(enrolment);
        }//  w w w  .  ja v a 2 s . c om
    }
    Boolean b = Boolean.TRUE;
    for (final Enrolment enrolment : enrolments) {
        if (!enrolment.isAnnulled()) {
            enrolment.setIsFirstTime(b);
            b = Boolean.FALSE;
        } else {
            enrolment.setIsFirstTime(Boolean.FALSE);
        }
    }
}

From source file:net.sourceforge.fenixedu.domain.StudentCurricularPlan.java

final public ExecutionYear getApprovedCurriculumLinesLastExecutionYear() {
    if (getRoot() != null) {
        return getRoot().getApprovedCurriculumLinesLastExecutionYear();
    } else {/* w w  w  .  j  a v  a2 s.  c  o m*/
        final SortedSet<ExecutionYear> executionYears = new TreeSet<ExecutionYear>(
                ExecutionYear.COMPARATOR_BY_YEAR);

        for (final CurriculumLine curriculumLine : getAprovedEnrolments()) {
            if (curriculumLine.hasExecutionPeriod()) {
                executionYears.add(curriculumLine.getExecutionPeriod().getExecutionYear());
            }
        }

        return executionYears.isEmpty() ? ExecutionYear.readCurrentExecutionYear() : executionYears.last();
    }
}

From source file:com.castis.xylophone.adsmadapter.convert.axistree.ConvertMgad.java

private String checkPpsSlotNumber(SortedSet<Slot_detail> SlotInfoSet) {
    List<Slot_detail> slotDetailList = new ArrayList<Slot_detail>(SlotInfoSet);

    for (int i = 0; i < slotDetailList.size(); i++) {
        int idx = slotDetailList.size() - 1 - i;
        if (!slotDetailList.get(idx).getPps_YN().equalsIgnoreCase("Y")) {
            for (int j = 0; j < idx; j++) {
                slotDetailList.get(j).setPps_YN("N");
            }/*w w  w  . j a  v  a  2s.c om*/
            break;
        }
    }

    SortedSet<Integer> ppsSlotNumber = new TreeSet<Integer>();
    for (Slot_detail slot : slotDetailList) {
        if (slot.getPps_YN().equalsIgnoreCase("Y")) {
            ppsSlotNumber.add(Integer.parseInt(slot.getSlot_ORD()));
        }
    }

    return toPpsString(ppsSlotNumber);
}

From source file:com.castis.xylophone.adsmadapter.convert.axistree.ConvertMgad.java

private SlotNumberPolicyDTO makeSlotNumberPolicyWithContentPrice(String startDate, Category category,
        PlacementOpportunityTypeEnum oppType, Platform platformType, InventoryType inventoryType)
        throws Exception {
    SlotNumberPolicyDTO policyDTO = new SlotNumberPolicyDTO();
    PriceTypeEnum paidType = getPriceTypeOfKT(category.getContent_price_type());
    int priceTypeValue = getPriorityValue(paidType);
    if (category.getPriority() == null || category.getPriority().isEmpty()) {
        int level = inventoryExportSysCompForAdapter
                .getNodeLevelByTreeTypeAndExternalId(TreeType.CATEGORY_AXIS_TREE, category.getCategory_id());
        if (level >= 0)
            policyDTO.setPriority(1000 - level * 10 - priceTypeValue);//??  ?.
        else//from w w w.  j  a  va 2 s .  co  m
            policyDTO.setPriority(DEFAULT_PRIORITY);
    } else
        policyDTO.setPriority(Integer.parseInt(category.getPriority()));

    //? slot count . (-1: ? ? ?)
    //for HC
    int freeSlotCnt = getSlotCount(category.getFree_content_slot_CNT());
    int paidSlotCnt = getSlotCount(category.getPaid_content_slot_CNT());

    //for KT
    if (category.getContent_price_type() != null) {
        if (category.getContent_price_type().equals("1"))
            paidSlotCnt = getSlotCount(category.getSlot_CNT());
        else if (category.getContent_price_type().equals("2"))
            freeSlotCnt = getSlotCount(category.getSlot_CNT());
    }

    //pps_YN
    SortedSet<Slot_detail> SlotInfoSet = new TreeSet<Slot_detail>();
    for (Slot_detail slotInfo : category.getCategory_slotList()) {
        if (slotInfo.getPps_YN() != null) {
            SlotInfoSet.add(slotInfo);
        }
    }

    policyDTO.setPpsSlotNumber(checkPpsSlotNumber(SlotInfoSet));

    policyDTO.setSlotNumber(Integer.parseInt(category.getSlot_CNT()));

    policyDTO.setMaxDuration(CiStringUtil.getMaxDuration(category.getMax_duration()));
    policyDTO.setExternalPolicyId(category.getPolicy_id());
    policyDTO.setLicensingStart(DateUtil.string2Date(category.getStart_DT()));
    policyDTO.setLicensingEnd(DateUtil.getNextDate(DateUtil.string2Date(category.getEnd_DT())));

    //relay  
    RelayTargetType relayType = RelayTargetType.ALL;
    if (category.getRelay_YN() != null) {
        if (category.getRelay_YN().equalsIgnoreCase("1"))
            relayType = RelayTargetType.RELAY_Y;
        else if (category.getRelay_YN().equalsIgnoreCase("2"))
            relayType = RelayTargetType.RELAY_N;
    }
    policyDTO.setRelay_YN(relayType);

    SubInventoryDTO subInventoryDTO;
    if (category.getTargetList() != null && category.getTargetList().isExistTarget() == true) {
        Set<GenericAxisItemIDDTO> commonGenericAxisItems = new HashSet<GenericAxisItemIDDTO>();
        //         commonGenericAxisItems.add(tambourineConnector.getPlacementTypeGenericAxisItemID(oppType));
        subInventoryDTO = generateMultiSubInventoryMember(category.getTargetList(), startDate, "99991231",
                commonGenericAxisItems, paidType);
    } else {
        subInventoryDTO = tambourineConnector.generateSubInventory(startDate, "99991231",
                category.getTarget_TM(), category.getTargetDay_CD(), category.getRegion_Info(),
                splitIds(category.getCategory_id(), true), null, null, oppType, paidType, timeDefineMap, null,
                null, null, null);
    }
    policyDTO.setOppType(oppType);
    policyDTO.setInventoryType(inventoryType);
    policyDTO.setPlatformType(platformType);
    policyDTO.setSubInventory(subInventoryDTO);
    return policyDTO;
}

From source file:com.castis.xylophone.adsmadapter.convert.axistree.ConvertMgad.java

private List<SlotNumberPolicyDTO> generateContentSlotNumberPolicy(String startDate,
        List<SlotNumberPolicyDTO> policyListDTO, List<Content> contentList,
        PlacementOpportunityTypeEnum oppType, Platform platformType, InventoryType inventoryType) {
    for (Content content : contentList) {

        try {//from ww w.j  a v a2s.  c om

            PriceTypeEnum paidType = getPriceTypeOfKT(content.getContent_price_type());
            int priceTypeValue = getPriorityValue(paidType);

            SlotNumberPolicyDTO policyDTO = new SlotNumberPolicyDTO();

            if (priceTypeValue == 1)
                policyDTO.setPriority(DEFAULT_CONTENT_POLICY_PRIORITY);
            else
                policyDTO.setPriority(4);

            policyDTO.setSlotNumber(Integer.parseInt(content.getSlot_CNT()));
            policyDTO.setMaxDuration(CiStringUtil.getMaxDuration(content.getMax_duration()));

            //relay  
            RelayTargetType relayType = RelayTargetType.ALL;
            if (content.getRelay_YN() != null) {
                if (content.getRelay_YN().equalsIgnoreCase("1"))
                    relayType = RelayTargetType.RELAY_Y;
                else if (content.getRelay_YN().equalsIgnoreCase("2"))
                    relayType = RelayTargetType.RELAY_N;
            }
            policyDTO.setRelay_YN(relayType);

            //pps_YN
            SortedSet<Slot_detail> SlotInfoSet = new TreeSet<Slot_detail>();
            for (Slot_detail slotInfo : content.getContent_slotList()) {
                if (slotInfo.getPps_YN() != null) {
                    SlotInfoSet.add(slotInfo);
                }
            }
            policyDTO.setPpsSlotNumber(checkPpsSlotNumber(SlotInfoSet));

            policyDTO.setSubInventory(
                    tambourineConnector.generateSubInventory(startDate, "99991231", null, null, null, null,
                            content.getContent_id(), null, oppType, paidType, null, null, null, null, null));
            policyDTO.setOppType(oppType);
            policyDTO.setInventoryType(inventoryType);
            policyDTO.setPlatformType(platformType);
            policyListDTO.add(policyDTO);
        } catch (WrappingException e) {
            log.error("ContentSlotNumberPolicy  ? . err : " + e.getMessage());
        } catch (Exception e) {
            log.error("", e);
        }
    }
    return policyListDTO;
}

From source file:com.castis.xylophone.adsmadapter.convert.axistree.ConvertMgad.java

private List<SlotNumberPolicyDTO> generateContentGroupSlotNumberPolicy(String startDate,
        List<SlotNumberPolicyDTO> policyListDTO, List<ContentGroup> contentGroupList,
        PlacementOpportunityTypeEnum oppType, Platform platformType, InventoryType inventoryType) {

    for (ContentGroup contentGroup : contentGroupList) {
        try {/*from ww w.j ava2 s .  c  o  m*/

            PriceTypeEnum paidType = getPriceTypeOfKT(contentGroup.getContent_price_type());
            int priceTypeValue = getPriorityValue(paidType);

            SlotNumberPolicyDTO policyDTO = new SlotNumberPolicyDTO();

            if (priceTypeValue == 1)
                policyDTO.setPriority(DEFAULT_CONTENT_GROUP_POLICY_PRIORITY);
            else
                policyDTO.setPriority(11);

            policyDTO.setSlotNumber(Integer.parseInt(contentGroup.getSlot_CNT()));
            policyDTO.setMaxDuration(CiStringUtil.getMaxDuration(contentGroup.getMax_duration()));

            //relay  
            RelayTargetType relayType = RelayTargetType.ALL;
            if (contentGroup.getRelay_YN() != null) {
                if (contentGroup.getRelay_YN().equalsIgnoreCase("1"))
                    relayType = RelayTargetType.RELAY_Y;
                else if (contentGroup.getRelay_YN().equalsIgnoreCase("2"))
                    relayType = RelayTargetType.RELAY_N;
            }
            policyDTO.setRelay_YN(relayType);

            //pps_YN
            SortedSet<Slot_detail> SlotInfoSet = new TreeSet<Slot_detail>();
            for (Slot_detail slotInfo : contentGroup.getContent_group_slotList()) {
                if (slotInfo.getPps_YN() != null) {
                    SlotInfoSet.add(slotInfo);
                }
            }
            policyDTO.setPpsSlotNumber(checkPpsSlotNumber(SlotInfoSet));

            policyDTO.setSubInventory(tambourineConnector.generateSubInventory(startDate, "99991231", null,
                    null, null, null, contentGroup.getContent_group_id(), null, oppType, paidType, null, null,
                    null, null, null));
            policyDTO.setOppType(oppType);
            policyDTO.setInventoryType(inventoryType);
            policyDTO.setPlatformType(platformType);
            policyListDTO.add(policyDTO);

        } catch (WrappingException e) {
            log.error("ContentSlotNumberPolicy  ? . err : " + e.getMessage());
        } catch (Exception e) {
            log.error("", e);
        }

    }

    return policyListDTO;
}

From source file:net.cbtltd.rest.nextpax.A_Handler.java

private void addToAvailableDates(SortedSet<DateTime> availableDates, String startdate, String enddate)
        throws ParseException {
    int daysBetween = Days.daysBetween(new DateTime(DF.parse(startdate)), new DateTime(DF.parse(enddate)))
            .getDays();//from  ww  w  . j  a v a2  s.  c om
    DateTime startDate = new DateTime(DF.parse(startdate));
    for (int i = 0; i <= daysBetween; i++) {
        availableDates.add(startDate.withFieldAdded(DurationFieldType.days(), i));
    }
}

From source file:de.huxhorn.lilith.swing.ViewActions.java

private void updateCustomCopyMenu(EventWrapper wrapper) {
    ApplicationPreferences prefs = mainFrame.getApplicationPreferences();
    String[] scripts = prefs.getClipboardFormatterScriptFiles();
    boolean changed = false;
    if (groovyClipboardActions == null) {
        groovyClipboardActions = new HashMap<String, CopyToClipboardAction>();
        changed = true;/*w  w w. j  a v a2  s .c om*/
    }
    if (groovyClipboardData == null) {
        groovyClipboardData = new HashMap<String, ClipboardFormatterData>();
        changed = true;
    }
    if (scripts == null || scripts.length == 0) {
        if (groovyClipboardActions.size() > 0) {
            groovyClipboardActions.clear();
            groovyClipboardData.clear();
            changed = true;
        }
    } else {
        List<String> scriptsList = Arrays.asList(scripts);
        // add missing formatters
        for (String current : scriptsList) {
            if (!groovyClipboardActions.containsKey(current)) {
                GroovyFormatter newFormatter = new GroovyFormatter();
                newFormatter.setGroovyFileName(
                        prefs.resolveClipboardFormatterScriptFile(current).getAbsolutePath());
                CopyToClipboardAction newAction = new CopyToClipboardAction(newFormatter);
                groovyClipboardActions.put(current, newAction);
                changed = true;
            }
        }

        // find deleted formatters
        List<String> deletedList = new ArrayList<String>();
        for (Map.Entry<String, CopyToClipboardAction> current : groovyClipboardActions.entrySet()) {
            if (!scriptsList.contains(current.getKey())) {
                deletedList.add(current.getKey());
            }
        }

        // remove deleted formatters
        for (String current : deletedList) {
            groovyClipboardActions.remove(current);
            changed = true;
        }
    }

    for (Map.Entry<String, CopyToClipboardAction> current : groovyClipboardActions.entrySet()) {
        String key = current.getKey();
        CopyToClipboardAction value = current.getValue();
        ClipboardFormatter formatter = value.getClipboardFormatter();
        if (formatter == null) {
            continue;
        }
        ClipboardFormatterData data = new ClipboardFormatterData(formatter);
        if (!data.equals(groovyClipboardData.get(key))) {
            changed = true;
            groovyClipboardData.put(key, data);
            value.setClipboardFormatter(formatter); // this reinitializes the action
        }
    }

    if (changed) {
        customCopyMenu.removeAll();
        customCopyPopupMenu.removeAll();
        boolean enabled = false;
        if (groovyClipboardActions.size() > 0) {
            enabled = true;
            SortedSet<CopyToClipboardAction> sorted = new TreeSet<CopyToClipboardAction>(
                    CopyToClipboardByNameComparator.INSTANCE);
            // sort the actions by name
            for (Map.Entry<String, CopyToClipboardAction> current : groovyClipboardActions.entrySet()) {
                sorted.add(current.getValue());
            }
            HashMap<KeyStroke, CopyToClipboardAction> freshMapping = new HashMap<KeyStroke, CopyToClipboardAction>(
                    keyStrokeActionMapping);
            prepareClipboardActions(sorted, freshMapping);

            // add the sorted actions to the menus.
            for (CopyToClipboardAction current : sorted) {
                customCopyMenu.add(current);
                customCopyPopupMenu.add(current);
            }
        }
        customCopyMenu.setEnabled(enabled);
        customCopyPopupMenu.setEnabled(enabled);
    }

    //      boolean enabled=false;
    for (Map.Entry<String, CopyToClipboardAction> current : groovyClipboardActions.entrySet()) {
        CopyToClipboardAction value = current.getValue();
        value.setEventWrapper(wrapper);
        //         if(value.isEnabled())
        //         {
        //            enabled = true;
        //         }
    }
    //
    //      customCopyMenu.setEnabled(enabled);
    //      customCopyPopupMenu.setEnabled(enabled);
}