Example usage for java.util SortedSet size

List of usage examples for java.util SortedSet size

Introduction

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

Prototype

int size();

Source Link

Document

Returns the number of elements in this set (its cardinality).

Usage

From source file:net.sourceforge.seqware.common.metadata.MetadataWSTest.java

/**
 * Test of addWorkflow method, of class MetadataWS.
 * dyuen asks: Why was this commented out?
 *//*from w ww  .jav a  2s.  c o m*/
@Test
public void testAddWorkflow() {
    logger.info("addWorkflow");
    String name = "GATKRecalibrationAndVariantCalling";
    String version = "1.3.16";
    String description = "GATKRecalibrationAndVariantCalling";
    String baseCommand = "java -jar /u/seqware/provisioned-bundles/sqwprod/"
            + "Workflow_Bundle_GATKRecalibrationAndVariantCalling_1.2.29_"
            + "SeqWare_0.10.0/GATKRecalibrationAndVariantCalling/1.x.x/lib/"
            + "seqware-pipeline-0.10.0.jar --plugin net.sourceforge.seqware."
            + "pipeline.plugins.WorkflowLauncher -- --bundle /u/seqware/"
            + "provisioned-bundles/sqwprod/Workflow_Bundle_GATKRecalibration"
            + "AndVariantCalling_1.2.29_SeqWare_0.10.0 --workflow GATK"
            + "RecalibrationAndVariantCalling --version 1.3.16";
    java.io.File configFile = null, templateFile = null;
    try {
        configFile = new java.io.File(
                MetadataWSTest.class.getResource("GATKRecalibrationAndVariantCalling_1.3.16.ini").toURI());
        templateFile = new java.io.File(
                MetadataWSTest.class.getResource("GATKRecalibrationAndVariantCalling_1.3.16.ftl").toURI());
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    java.io.File provisionDir = new java.io.File("/u/seqware/provisioned-bundles"
            + "/sqwprod/Workflow_Bundle_GATKRecalibrationAndVariantCalling_" + "1.2.29_SeqWare_0.10.0/");
    int expResult = ReturnValue.SUCCESS;
    ReturnValue result = instance.addWorkflow(name, version, description, baseCommand,
            configFile.getAbsolutePath(), templateFile.getAbsolutePath(), provisionDir.getAbsolutePath(), true,
            "", false, null, null, null);
    Assert.assertEquals(expResult, result.getExitStatus());

    // test certain properties of the workflow parameters in relation to SEQWARE-1444
    String workflow_id = result.getAttribute("sw_accession");
    Workflow workflow = instance.getWorkflow(Integer.valueOf(workflow_id));
    Assert.assertTrue("workflow retrieved is invalid", workflow.getWorkflowId() == result.getReturnValue());
    SortedSet<WorkflowParam> workflowParams = instance.getWorkflowParams(workflow_id);
    Assert.assertTrue("invalid number of workflow params retrieved", workflowParams.size() == 33);
    // check out the values of some long values
    for (WorkflowParam param : workflowParams) {
        if (param.getKey().equals("bam_inputs")) {
            Assert.assertTrue("bam_inputs invalid", param.getDefaultValue().equals(
                    "${workflow_bundle_dir}/GATKRecalibrationAndVariantCalling/1.x.x/data/test/PCSI0022P.val.bam,${workflow_bundle_dir}/GATKRecalibrationAndVariantCalling/1.x.x/data/test/PCSI0022R.val.bam,${workflow_bundle_dir}/GATKRecalibrationAndVariantCalling/1.x.x/data/test/PCSI0022X.val.bam,${workflow_bundle_dir}/GATKRecalibrationAndVariantCalling/1.x.x/data/test/PCSI0022C.val.bam"));
        } else if (param.getKey().equals("chr_sizes")) {
            Assert.assertTrue("chr_sizes invalid", param.getDefaultValue().equals(
                    "chr1:249250621,chr2:243199373,chr3:198022430,chr4:191154276,chr5:180915260,chr6:171115067,chr7:159138663,chr8:146364022,chr9:141213431,chr10:135534747,chr11:135006516,chr12:133851895,chr13:115169878,chr14:107349540,chr15:102531392,chr16:90354753,chr17:81195210,chr18:78077248,chr19:59128983,chr20:63025520,chr21:48129895,chr22:51304566,chrX:155270560,chrY:59373566,chrM:16571"));
        }
    }
}

From source file:org.codehaus.mojo.license.api.DefaultThirdPartyTool.java

/**
 * {@inheritDoc}/*from   w  w  w. ja v a 2  s .  c  o  m*/
 */
public void mergeLicenses(LicenseMap licenseMap, String mainLicense, Set<String> licenses) {

    if (licenses.isEmpty()) {

        // nothing to merge, is this can really happen ?
        return;
    }

    SortedSet<MavenProject> mainSet = licenseMap.get(mainLicense);
    if (mainSet == null) {
        if (isVerbose()) {
            getLogger().warn("No license [" + mainLicense + "] found, will create it.");
        }
        mainSet = new TreeSet<MavenProject>(projectComparator);
        licenseMap.put(mainLicense, mainSet);
    }
    for (String license : licenses) {
        SortedSet<MavenProject> set = licenseMap.get(license);
        if (set == null) {
            if (isVerbose()) {
                getLogger().warn("No license [" + license + "] found, skip the merge to [" + mainLicense + "]");
            }
            continue;
        }
        if (isVerbose()) {
            getLogger().info("Merge license [" + license + "] to [" + mainLicense + "] (" + set.size()
                    + " dependencies).");
        }
        mainSet.addAll(set);
        set.clear();
        licenseMap.remove(license);
    }
}

From source file:org.libreplan.web.orders.ManageOrderElementAdvancesModel.java

@Override
@Transactional(readOnly = true)/*from w w w  .  ja  v  a  2s  . co m*/
public XYModel getChartData(Set<AdvanceAssignment> selectedAdvances) {
    XYModel xyModel = new SimpleXYModel();

    for (AdvanceAssignment each : selectedAdvances) {
        DirectAdvanceAssignment directAdvanceAssignment;
        if (each instanceof DirectAdvanceAssignment) {
            directAdvanceAssignment = (DirectAdvanceAssignment) each;
        } else {
            directAdvanceAssignment = calculateFakeDirectAdvanceAssignment((IndirectAdvanceAssignment) each);
        }
        if (directAdvanceAssignment != null) {
            String title = getInfoAdvanceAssignment(directAdvanceAssignment);
            SortedSet<AdvanceMeasurement> listAdvanceMeasurements = directAdvanceAssignment
                    .getAdvanceMeasurements();
            if (listAdvanceMeasurements.size() > 1) {
                for (AdvanceMeasurement advanceMeasurement : listAdvanceMeasurements) {
                    BigDecimal value = advanceMeasurement.getValue();
                    if ((selectedAdvances.size() > 1) && (value != null)
                            && (value.compareTo(BigDecimal.ZERO) > 0)) {
                        BigDecimal maxValue = directAdvanceAssignment.getMaxValue();
                        value = value.setScale(2).divide(maxValue, RoundingMode.DOWN);
                    }
                    LocalDate date = advanceMeasurement.getDate();
                    if ((value != null) && (date != null)) {
                        xyModel.addValue(title, date.toDateTimeAtStartOfDay().getMillis(), value);
                    }
                }
            }
        }
    }

    return xyModel;
}

From source file:org.apache.hadoop.hbase.regionserver.StoreFileReader.java

/**
 * Checks whether the given scan passes the Bloom filter (if present). Only
 * checks Bloom filters for single-row or single-row-column scans. Bloom
 * filter checking for multi-gets is implemented as part of the store
 * scanner system (see {@link StoreFileScanner#seekExactly}) and uses
 * the lower-level API {@link #passesGeneralRowBloomFilter(byte[], int, int)}
 * and {@link #passesGeneralRowColBloomFilter(Cell)}.
 *
 * @param scan the scan specification. Used to determine the row, and to
 *          check whether this is a single-row ("get") scan.
 * @param columns the set of columns. Only used for row-column Bloom
 *          filters./*ww w  .  jav  a 2  s.  com*/
 * @return true if the scan with the given column set passes the Bloom
 *         filter, or if the Bloom filter is not applicable for the scan.
 *         False if the Bloom filter is applicable and the scan fails it.
 */
boolean passesBloomFilter(Scan scan, final SortedSet<byte[]> columns) {
    // Multi-column non-get scans will use Bloom filters through the
    // lower-level API function that this function calls.
    if (!scan.isGetScan()) {
        return true;
    }

    byte[] row = scan.getStartRow();
    switch (this.bloomFilterType) {
    case ROW:
        return passesGeneralRowBloomFilter(row, 0, row.length);

    case ROWCOL:
        if (columns != null && columns.size() == 1) {
            byte[] column = columns.first();
            // create the required fake key
            Cell kvKey = KeyValueUtil.createFirstOnRow(row, 0, row.length, HConstants.EMPTY_BYTE_ARRAY, 0, 0,
                    column, 0, column.length);
            return passesGeneralRowColBloomFilter(kvKey);
        }

        // For multi-column queries the Bloom filter is checked from the
        // seekExact operation.
        return true;

    default:
        return true;
    }
}

From source file:org.jasig.schedassist.model.AvailableBlockBuilderTest.java

/**
 * @throws ParseException /*from  www  .java  2  s  . c om*/
 * @throws InputFormatException 
 * 
 */
@Test
public void testTwentyMinuteDuration() throws InputFormatException, ParseException {
    SimpleDateFormat dateFormat = CommonDateOperations.getDateFormat();
    SortedSet<AvailableBlock> blocks = AvailableBlockBuilder.createBlocks("9:00 AM", "11:40 AM", "MW",
            dateFormat.parse("20100830"), dateFormat.parse("20100903"));
    Assert.assertEquals(2, blocks.size());
    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100830-0900"),
            blocks.first().getStartTime());
    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100830-1140"),
            blocks.first().getEndTime());

    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100901-0900"),
            blocks.last().getStartTime());
    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100901-1140"),
            blocks.last().getEndTime());

    SortedSet<AvailableBlock> expanded = AvailableBlockBuilder.expand(blocks, 20);
    Assert.assertEquals(16, expanded.size());

    Date originalStart = CommonDateOperations.getDateTimeFormat().parse("20100830-0900");

    Date currentStart = originalStart;
    for (AvailableBlock e : expanded) {
        if (!DateUtils.isSameDay(e.getStartTime(), currentStart)) {
            currentStart = DateUtils.addDays(originalStart, 2);
        }
        Assert.assertEquals(currentStart, e.getStartTime());
        currentStart = DateUtils.addMinutes(currentStart, 20);
        Assert.assertEquals(currentStart, e.getEndTime());
    }
}

From source file:org.wrml.werminal.Werminal.java

private void addKeySlotValuesToHistory(final URI historyListSchemaUri, final Keys keys) {

    final Context context = getContext();
    final SchemaLoader schemaLoader = context.getSchemaLoader();
    if (keys == null || keys.getCount() == 0) {
        return;/*from  w w w  .j  a  va 2s. c  o m*/
    }

    for (final URI keyedSchemaUri : keys.getKeyedSchemaUris()) {
        final Object keyValue = keys.getValue(keyedSchemaUri);

        final Prototype keyDeclaredPrototype = schemaLoader.getPrototype(keyedSchemaUri);
        if (keyDeclaredPrototype == null) {
            continue;
        }
        final SortedSet<String> keySlotNames = keyDeclaredPrototype.getDeclaredKeySlotNames();

        if (keySlotNames == null || keySlotNames.isEmpty()) {
            continue;
        }

        if (keySlotNames.size() == 1) {
            final String keySlotName = keySlotNames.first();

            addSlotValueToHistory(historyListSchemaUri, keySlotName, keyValue);
        } else {
            final CompositeKey compositeKey = (CompositeKey) keyValue;
            if (compositeKey == null) {
                continue;
            }

            final Map<String, Object> compositeKeySlots = compositeKey.getKeySlots();
            for (final String compositeKeySlotName : compositeKeySlots.keySet()) {
                final Object compositeKeySlotValue = compositeKeySlots.get(compositeKeySlotName);
                if (compositeKeySlotValue != null) {
                    addSlotValueToHistory(historyListSchemaUri, compositeKeySlotName, compositeKeySlotValue);
                }
            }
        }
    }
}

From source file:eu.udig.tools.jgrass.navigationview.NavigationView.java

private void updateData() {
    Display.getDefault().asyncExec(new Runnable() {
        public void run() {
            IMap activeMap = ApplicationGIS.getActiveMap();
            ViewportModel viewportModel = (ViewportModel) activeMap.getViewportModel();
            activeMap.addMapListener(NavigationView.this);
            activeMap.addMapCompositionListener(NavigationView.this);

            ReferencedEnvelope bounds = viewportModel.getBounds();

            double west = bounds.getMinX();
            double east = bounds.getMaxX();
            double north = bounds.getMaxY();
            double south = bounds.getMinY();

            if (lowerLeftText.isDisposed()) {
                return;
            }// w  w w  . jav  a2s  .co m
            lowerLeftText.setText(numFormatter.format(west) + ", " + numFormatter.format(south));
            upperRightText.setText(numFormatter.format(east) + ", " + numFormatter.format(north));

            canvas.redraw();

            SortedSet<Double> preferredScaleDenominators = viewportModel.getPreferredScaleDenominators();
            Double[] scalesArray = (Double[]) preferredScaleDenominators
                    .toArray(new Double[preferredScaleDenominators.size()]);
            String[] scales = new String[scalesArray.length];
            for (int i = 0; i < scales.length; i++) {
                scales[i] = "1:" + String.valueOf(scalesArray[i]);
            }
            int itemCount = scaleCombo.getItemCount();
            int selectionIndex = scaleCombo.getSelectionIndex();
            scaleCombo.setItems(scales);
            if (scales.length == itemCount) {
                scaleCombo.select(selectionIndex);
            }

            List<DateTime> availableTimesteps = viewportModel.getAvailableTimesteps();
            if (availableTimesteps != null) {
                dateTimeCombo.setEnabled(true);
                dtDownButton.setEnabled(true);
                dtUpButton.setEnabled(true);
                String[] dates = new String[availableTimesteps.size()];
                for (int i = 0; i < dates.length; i++) {
                    dates[i] = ISO_DATE_TIME_FORMATTER.print(availableTimesteps.get(i));
                }
                itemCount = dateTimeCombo.getItemCount();
                selectionIndex = dateTimeCombo.getSelectionIndex();
                dateTimeCombo.setItems(dates);
                if (dates.length == itemCount) {
                    dateTimeCombo.select(selectionIndex);
                }
            } else {
                dateTimeCombo.setEnabled(false);
                dtDownButton.setEnabled(false);
                dtUpButton.setEnabled(false);
            }

            List<Double> availableElevation = viewportModel.getAvailableElevation();
            if (availableElevation != null) {
                verticalCombo.setEnabled(true);
                verticalDownButton.setEnabled(true);
                verticalUpButton.setEnabled(true);
                String[] elev = new String[availableElevation.size()];
                for (int i = 0; i < elev.length; i++) {
                    elev[i] = String.valueOf(availableElevation.get(i));
                }
                itemCount = verticalCombo.getItemCount();
                selectionIndex = verticalCombo.getSelectionIndex();
                verticalCombo.setItems(elev);
                if (elev.length == itemCount) {
                    verticalCombo.select(selectionIndex);
                }
            } else {
                verticalCombo.setEnabled(false);
                verticalDownButton.setEnabled(false);
                verticalUpButton.setEnabled(false);
            }
        }
    });
}

From source file:org.wrml.runtime.schema.Prototype.java

/**
 * Creates a new Prototype to represent the identified schema.
 *
 * @param schemaLoader The schema loader for this prototype's schema.
 * @param schemaUri    The schema identifier.
 * @throws PrototypeException Thrown if there are problems with the initial prototyping of the schema.
 *///from www  .  j  a v a2 s  . com
Prototype(final SchemaLoader schemaLoader, final URI schemaUri) throws PrototypeException {

    LOGGER.debug("Creating Prototype for schema ID: {}", new Object[] { schemaUri });

    _SchemaLoader = schemaLoader;
    if (_SchemaLoader == null) {

        throw new PrototypeException("The SchemaLoader parameter value cannot be *null*.", null, this);
    }

    _SchemaUri = schemaUri;
    if (_SchemaUri == null) {
        throw new PrototypeException("The undefined (aka *null*) schema can not be prototyped.", null, this);
    }

    if (schemaUri.equals(schemaLoader.getResourceTemplateSchemaUri())) {
        LOGGER.debug("Creating Prototype for ResourceTemplate");
    }

    _UniqueName = new UniqueName(_SchemaUri);

    //
    // Use the SchemaLoader and the schema uri to get the schema's Java Class
    // representation.
    //
    final Class<?> schemaInterface = getSchemaInterface();

    if (ValueType.JAVA_TYPE_ABSTRACT.equals(schemaInterface)) {
        _IsAbstract = true;
    } else if (Document.class.equals(schemaInterface)) {
        _IsDocument = true;
    }

    //
    // Introspect the associated class, extracting metadata from the parent
    // schema's Java interfaces (up to but not including the Model
    // interface).
    //

    _SchemaBean = new JavaBean(schemaInterface, ValueType.JAVA_TYPE_MODEL, LinkSlot.class);
    _AllBaseSchemaUris = new LinkedHashSet<>();
    _BaseSchemaUris = new LinkedHashSet<>();
    _AllSlotNames = new TreeSet<>();
    _ProtoSlots = new TreeMap<>();
    _CollectionPropertyProtoSlots = new TreeMap<>();
    _LinkRelationUris = new TreeMap<>();

    _LinkProtoSlots = new TreeMap<>();
    _SlotAliases = new TreeMap<>();
    _SearchableSlots = new TreeSet<>();

    // initBaseSchemas(...)
    {

        //
        // Use Java reflection to get all implemented interfaces and then turn
        // them into schema ids. With reflection we get de-duplication and
        // recursive traversal for free.
        //

        final List<Class<?>> allBaseInterfaces = ClassUtils.getAllInterfaces(schemaInterface);
        // Loop backwards to achieve desired key mapping precedence/overriding
        for (final Class<?> baseInterface : allBaseInterfaces) {

            if (ValueType.isSchemaInterface(baseInterface) && (baseInterface != ValueType.JAVA_TYPE_MODEL)) {

                final URI baseSchemaUri = _SchemaLoader.getTypeUri(baseInterface);
                _AllBaseSchemaUris.add(baseSchemaUri);

                if (Document.class.equals(baseInterface)) {
                    _IsDocument = true;
                }

                if (AggregateDocument.class.equals(baseInterface)) {
                    _IsAggregate = true;
                }

            }

        }

        // Store the immediate base schemas as well

        final Class<?>[] baseInterfaces = schemaInterface.getInterfaces();
        if (baseInterfaces != null) {

            for (final Class<?> baseInterface : baseInterfaces) {
                if (ValueType.isSchemaInterface(baseInterface)
                        && (baseInterface != ValueType.JAVA_TYPE_MODEL)) {
                    final URI baseSchemaUri = _SchemaLoader.getTypeUri(baseInterface);
                    _BaseSchemaUris.add(baseSchemaUri);
                }

                if (ValueType.JAVA_TYPE_ABSTRACT.equals(baseInterface)) {
                    _IsAbstract = true;
                }
            }

        }

    } // End of base schema init

    // initKeys(...)
    {
        final WRML wrml = schemaInterface.getAnnotation(WRML.class);
        if (wrml != null) {
            final String[] keySlotNameArray = wrml.keySlotNames();

            if ((keySlotNameArray != null) && (keySlotNameArray.length > 0)) {

                _KeySlotNames = new TreeSet<>(Arrays.asList(keySlotNameArray));

                if (_KeySlotNames.size() == 1) {
                    final String keySlotName = _KeySlotNames.first();
                    final Property property = _SchemaBean.getProperties().get(keySlotName);
                    if (property != null) {
                        _KeyType = property.getType();
                    } else {
                        throw new PrototypeException("The named key slot, \"" + keySlotName
                                + "\", is not defined for Schema: " + schemaUri + ".", null, this);
                    }
                } else {

                    // Schemas with Keys that use more than one slot value to
                    // determine uniqueness use the CompositeKey type (at
                    // runtime) as their key object.
                    //
                    _KeyType = ValueType.JAVA_TYPE_COMPOSITE_KEY;
                }

            }

            final String[] comparableSlotNameArray = wrml.comparableSlotNames();

            if ((comparableSlotNameArray != null) && (comparableSlotNameArray.length > 0)) {

                _ComparableSlotNames = new LinkedHashSet<String>(Arrays.asList(comparableSlotNameArray));
            }

            final String titleSlotName = wrml.titleSlotName();
            if (StringUtils.isNotBlank(titleSlotName)) {
                _TitleSlotName = titleSlotName;
            }

        }

    } // End of the key initialization

    // initMiscAnnotations(...)
    {

        final Description schemaDescription = schemaInterface.getAnnotation(Description.class);
        if (schemaDescription != null) {
            _Description = schemaDescription.value();
        } else {
            _Description = null;
        }

        final Title schemaTitle = schemaInterface.getAnnotation(Title.class);
        if (schemaTitle != null) {
            _Title = schemaTitle.value();
        } else {
            _Title = schemaInterface.getSimpleName();
        }

        final ThumbnailImage thumbnailImage = schemaInterface.getAnnotation(ThumbnailImage.class);
        if (thumbnailImage != null) {
            _ThumbnailLocation = URI.create(thumbnailImage.value());
        } else {
            _ThumbnailLocation = null;
        }

        _ReadOnly = (schemaInterface.getAnnotation(ReadOnly.class) != null) ? true : false;

        final Version schemaVersion = schemaInterface.getAnnotation(Version.class);
        if (schemaVersion != null) {
            _Version = schemaVersion.value();
        } else {
            // TODO: Look for the "static final long serialVersionUID" ?
            _Version = 1L;
        }

        final Tags tags = schemaInterface.getAnnotation(Tags.class);
        if (tags != null) {
            final String[] tagArray = tags.value();

            if ((tagArray != null) && (tagArray.length > 0)) {

                _Tags = new TreeSet<String>(Arrays.asList(tagArray));
            }
        }

    } // End of annotation-based initialization

    // initPropertySlots(...)
    {
        final Map<String, Property> properties = _SchemaBean.getProperties();

        for (final String slotName : properties.keySet()) {
            final Property property = properties.get(slotName);

            final PropertyProtoSlot propertyProtoSlot;

            final CollectionSlot collectionSlot = property.getAnnotation(CollectionSlot.class);
            if (collectionSlot != null) {
                propertyProtoSlot = new CollectionPropertyProtoSlot(this, slotName, property);
            } else {
                propertyProtoSlot = new PropertyProtoSlot(this, slotName, property);
            }

            addProtoSlot(propertyProtoSlot);
        }
    }

    // initLinkSlots(...)
    {

        //
        // Map the the schema bean's "other" (non-Property) methods.
        //

        final SortedMap<String, SortedSet<JavaMethod>> otherMethods = _SchemaBean.getOtherMethods();
        final Set<String> otherMethodNames = otherMethods.keySet();

        for (final String methodName : otherMethodNames) {

            final SortedSet<JavaMethod> methodSet = otherMethods.get(methodName);
            if (methodSet.size() != 1) {
                throw new PrototypeException("The link method: " + methodName + " cannot be overloaded.", this);
            }

            final JavaMethod javaMethod = methodSet.first();
            final Method method = javaMethod.getMethod();

            final LinkSlot linkSlot = method.getAnnotation(LinkSlot.class);
            if (linkSlot == null) {
                throw new PrototypeException("The method: " + javaMethod + " is not a link method", null, this);
            }

            final String relationUriString = linkSlot.linkRelationUri();
            final URI linkRelationUri = URI.create(relationUriString);

            if (_LinkProtoSlots.containsKey(linkRelationUri)) {
                throw new PrototypeException(
                        "A schema cannot use the same link relation for more than one method. Duplicate link relation: "
                                + linkRelationUri + " found in link method: " + javaMethod,
                        this);
            }

            final org.wrml.model.rest.Method relMethod = linkSlot.method();

            String slotName = methodName;
            if (relMethod == org.wrml.model.rest.Method.Get && slotName.startsWith(JavaBean.GET)) {
                slotName = slotName.substring(3);
                slotName = Character.toLowerCase(slotName.charAt(0)) + slotName.substring(1);
            }
            _LinkRelationUris.put(slotName, linkRelationUri);

            if (_ProtoSlots.containsKey(slotName)) {
                throw new PrototypeException(
                        "A schema cannot use the same name for more than one slot. Duplicate slot name: "
                                + slotName + " found in link method: " + javaMethod,
                        this);
            }

            final LinkProtoSlot linkProtoSlot = new LinkProtoSlot(this, slotName, javaMethod);

            if ((linkProtoSlot.isEmbedded() || isAggregate())
                    && (relMethod == org.wrml.model.rest.Method.Get)) {
                _ContainsEmbeddedLink = true;
            }

            _LinkProtoSlots.put(linkRelationUri, linkProtoSlot);

            addProtoSlot(linkProtoSlot);

        }

    } // End of link slot init

    if (!_SlotAliases.isEmpty()) {
        for (final String alias : _SlotAliases.keySet()) {
            final ProtoSlot protoSlot = _ProtoSlots.get(alias);
            protoSlot.setAlias(true);
            final String realName = _SlotAliases.get(alias);
            protoSlot.setRealName(realName);

        }
    }

}

From source file:com.microsoft.tfs.client.common.ui.controls.vc.checkin.NotesCheckinControl.java

private void updateControls() {
    if (dirty == false || updating == true) {
        return;/*w w  w  . j  ava  2  s.c om*/
    }

    if (options.getCheckinNotesReadOnly() && (checkinNote == null || checkinNote.getValues().length == 0)) {
        dirty = false;
        updateEmptyControl();
        return;
    } else if (options.getCheckinNotesReadOnly()) {
        dirty = false;
        updateReadOnlyControl();
        return;
    } else if (options.getCheckinNotesHistoric()) {
        /* Set updating to true to suppress modify events */
        dirty = false;
        updating = true;
        fieldControls = updateHistoricControl();
        updating = false;
        return;
    } else if (projects == null || projects.length == 0) {
        dirty = false;
        updateEmptyControl();
        return;
    } else if (repository == null || !ConnectionHelper.isConnected(repository.getConnection())) {
        dirty = false;
        updateEmptyControl();
        return;
    }

    updateEmptyControl();

    updating = true;
    fieldControls = new CheckinNoteFieldControl[0];

    updateBusyControl();

    /*
     * Set dirty now so that we can detect if we need to (again) requery.
     * Another thread may set us dirty.
     */
    dirty = false;

    /*
     * Run a background job that queries the check-in notes for the
     * currently selected projects, and build the note fields on the UI
     * thread.
     */
    final Display display = getDisplay();

    final TFSRepository repository = this.repository;
    final String[] projects = this.projects;

    final Job updateJob = new Job(BUSY_MESSAGE) {
        @Override
        protected IStatus run(final IProgressMonitor monitor) {
            try {
                if (projects.length == 1) {
                    log.info(MessageFormat.format("Querying checkin notes for project {0}", projects[0])); //$NON-NLS-1$
                } else {
                    log.info("Querying checkin notes for team projects"); //$NON-NLS-1$
                }

                final SortedSet definitionSet = repository.getVersionControlClient()
                        .queryCheckinNoteFieldDefinitionsForServerPaths(projects);
                final CheckinNoteFieldDefinition[] definitions = (CheckinNoteFieldDefinition[]) definitionSet
                        .toArray(new CheckinNoteFieldDefinition[definitionSet.size()]);

                display.asyncExec(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            if (definitions == null || definitions.length == 0) {
                                updateEmptyControl();
                            } else {
                                fieldControls = updateFieldControl(definitions);
                            }

                            updateCheckinNote();
                        } finally {
                            updating = false;

                            if (dirty == true) {
                                updateControls();
                            }
                        }
                    }
                });
            } catch (final Exception e) {
                return new Status(IStatus.ERROR, TFSCommonUIClientPlugin.PLUGIN_ID, 0,
                        Messages.getString("NotesCheckinControl.CouldNotQueryNotes"), //$NON-NLS-1$
                        e);
            }

            return Status.OK_STATUS;
        }
    };

    updateJob.schedule();
}

From source file:org.jasig.schedassist.model.AvailableBlockBuilderTest.java

/**
 * Test that highlights the problem when a customer specifies a start/end range
 * for blocks and a meeting duration that leaves a remainder.
 * //  w ww .  j  ava2 s  .  c  o  m
 * @throws ParseException 
 * @throws InputFormatException 
 */
@Test
public void testDurationLeavesRemainder() throws InputFormatException, ParseException {
    SimpleDateFormat dateFormat = CommonDateOperations.getDateFormat();
    SortedSet<AvailableBlock> blocks = AvailableBlockBuilder.createBlocks("9:03 AM", "3:19 PM", "MWF",
            dateFormat.parse("20100830"), dateFormat.parse("20100903"));
    Assert.assertEquals(3, blocks.size());

    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100830-0903"),
            blocks.first().getStartTime());
    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100830-1519"),
            blocks.first().getEndTime());

    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100903-0903"),
            blocks.last().getStartTime());
    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100903-1519"),
            blocks.last().getEndTime());

    SortedSet<AvailableBlock> expanded = AvailableBlockBuilder.expand(blocks, 17);
    AvailableBlock last = null;

    long millisIn17Minutes = 1020000L;
    for (AvailableBlock e : expanded) {
        if (last != null) {
            if (DateUtils.isSameDay(e.getStartTime(), last.getStartTime())) {
                Assert.assertEquals(last.getEndTime(), e.getStartTime());
                Assert.assertEquals(e.getEndTime().getTime() - last.getEndTime().getTime(), millisIn17Minutes);
            } else {
                Calendar cal = Calendar.getInstance();
                cal.setTime(e.getStartTime());
                Assert.assertEquals(9, cal.get(Calendar.HOUR_OF_DAY));
                Assert.assertEquals(3, cal.get(Calendar.MINUTE));

                cal.setTime(e.getEndTime());
                Assert.assertEquals(9, cal.get(Calendar.HOUR_OF_DAY));
                Assert.assertEquals(20, cal.get(Calendar.MINUTE));

                // double check yesterday's endpoint
                cal.setTime(last.getStartTime());
                Assert.assertEquals(15, cal.get(Calendar.HOUR_OF_DAY));
                Assert.assertEquals(0, cal.get(Calendar.MINUTE));

                cal.setTime(last.getEndTime());
                Assert.assertEquals(15, cal.get(Calendar.HOUR_OF_DAY));
                Assert.assertEquals(17, cal.get(Calendar.MINUTE));
            }
        } else {
            // first block in the series
            Calendar cal = Calendar.getInstance();
            cal.setTime(e.getStartTime());
            Assert.assertEquals(9, cal.get(Calendar.HOUR_OF_DAY));
            Assert.assertEquals(3, cal.get(Calendar.MINUTE));

            cal.setTime(e.getEndTime());
            Assert.assertEquals(9, cal.get(Calendar.HOUR_OF_DAY));
            Assert.assertEquals(20, cal.get(Calendar.MINUTE));
        }
        last = e;
    }

    Assert.assertEquals(66, expanded.size());

    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100830-0903"),
            expanded.first().getStartTime());
    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100830-0920"),
            expanded.first().getEndTime());

    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100903-1500"),
            expanded.last().getStartTime());
    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100903-1517"),
            expanded.last().getEndTime());

}