Package org.apache.tuscany.sca.data.collection

Examples of org.apache.tuscany.sca.data.collection.Item


        Composite compositeCollection = readCompositeCollection();
        for (Composite composite: compositeCollection.getIncludes()) {
            String contributionURI = composite.getURI();
            QName qname = composite.getName();
            String key = compositeKey(contributionURI, qname);
            Item item;
            try {
                item = deployableCollection.get(key);
            } catch (NotFoundException e) {
                item = new Item();
                item.setTitle(compositeTitle(contributionURI, qname));
                item.setLink(compositeSourceLink(contributionURI, qname));
                item.setContents("<span id=\"problem\" style=\"color: red\">Problem: Composite not found</span>");
            }
            Entry<String, Item> entry = new Entry<String, Item>();
            entry.setKey(key);
            entry.setData(item);
            entries.add(entry);
View Full Code Here


     */
    private Entry createFeedEntry(org.apache.tuscany.sca.data.collection.Entry<Object, Object> entry) {
        Object key = entry.getKey();
        Object data = entry.getData();
        if (data instanceof Item) {
            Item item = (Item)data;
           
            Entry feedEntry = new Entry();
            feedEntry.setId(key.toString());
            feedEntry.setTitle(item.getTitle());
   
            String value = item.getContents();
            if (value != null) {
                Content content = new Content();
                content.setType("text/xml");
                content.setValue(value);
                List<Content> contents = new ArrayList<Content>();
                contents.add(content);
                feedEntry.setContents(contents);
            }
   
            String href = item.getLink();
            if (href == null) {
                href = key.toString();
            }
            Link link = new Link();
            link.setRel("edit");
            link.setHref(href);
            feedEntry.getOtherLinks().add(link);
            link = new Link();
            link.setRel("alternate");
            link.setHref(href);
            feedEntry.getAlternateLinks().add(link);
   
            Date date = item.getDate();
            if (date == null) {
                date = new Date();
            }
            feedEntry.setCreated(date);
            return feedEntry;
View Full Code Here

    private org.apache.tuscany.sca.data.collection.Entry<Object, Object> createEntry(Entry feedEntry) {
        if (feedEntry != null) {
            if (itemClassType.getPhysical() == Item.class) {
                String key = feedEntry.getId();
               
                Item item = new Item();
                item.setTitle(feedEntry.getTitle());
               
                List<?> contents = feedEntry.getContents();
                if (!contents.isEmpty()) {
                    Content content = (Content)contents.get(0);
                    String value = content.getValue();
                    item.setContents(value);
                }
               
                for (Object l : feedEntry.getOtherLinks()) {
                    Link link = (Link)l;
                    if (link.getRel() == null || "edit".equals(link.getRel())) {
                        String href = link.getHref();
                        if (href.startsWith("null/")) {
                            href = href.substring(5);
                        }
                        item.setLink(href);
                        break;
                    }
                }
               
                item.setDate(feedEntry.getCreated());
               
                return new org.apache.tuscany.sca.data.collection.Entry<Object, Object>(key, item);
               
            } else {
                String key = feedEntry.getId();
View Full Code Here

                                       DataType<?> itemClassType, DataType<?> itemXMLType, Mediator mediator) {
        if (feedEntry != null) {
            if (itemClassType.getPhysical() == Item.class || feedEntry.getContentType() == Type.HTML ) {
                String key = feedEntry.getId().toString();

                Item item = new Item();
                item.setTitle(feedEntry.getTitle());
                item.setContents(feedEntry.getContent());

                for (Link link : feedEntry.getLinks()) {
                    if (link.getRel() == null || "self".equals(link.getRel())) {
                        if (item.getLink() == null) {
                            item.setLink(link.getHref().toString());
                        }
                    } else if ("related".equals(link.getRel())) {
                        item.setRelated(link.getHref().toString());
                    } else if ("alternate".equals(link.getRel())) {
                        item.setAlternate(link.getHref().toString());
                    }
                }

                item.setDate(feedEntry.getUpdated());

                return new Entry<Object, Object>(key, item);

            } else {
                String key = null;
View Full Code Here

        entriesArray = (Entry<String,Item>[])entries.toArray(entriesArray);
        Arrays.sort(entriesArray, new Comparator() {
            public int compare(final Object xObj, final Object yObj) {
                Entry x = (Entry) xObj;
                Entry y = (Entry) yObj;
                Item xItem = (Item) x.getData();
                Item yItem = (Item) y.getData();
                Date xDate = xItem.getDate();
                Date yDate = yItem.getDate();
                if (xDate == null)
                    return -1;
                if (newFirst)
                    return yDate.compareTo(xDate);
                else
View Full Code Here

                                  DataType<?> itemClassType, DataType<?> itemXMLType, Mediator mediator,
                                  Factory factory) {
        Object key = entry.getKey();
        Object data = entry.getData();
        if (data instanceof Item) {
            Item item = (Item)data;

            org.apache.abdera.model.Entry feedEntry = factory.newEntry();
            if (key != null) {
                feedEntry.setId(key.toString());
            }
            feedEntry.setTitle(item.getTitle());
            feedEntry.setContentAsHtml(item.getContents());

            String href = item.getLink();
            if (href == null && key != null) {
                href = key.toString();
            }

            if (href != null) {
                feedEntry.addLink(href);
            }
            String related = item.getRelated();
            if (related != null) {
                feedEntry.addLink(related, "related");
            }
            String alternate = item.getAlternate();
            if (alternate != null) {
                feedEntry.addLink(alternate, "alternate");
            }

            Date date = item.getDate();
            if (date != null) {
                feedEntry.setUpdated(date);
            }
            return feedEntry;
View Full Code Here

     * @param content Contents of the feed entry
     * @param link Link for the feed entry
     * @return A new feed entry.
     */
    private Entry<Object, Object> createFeedEntry(String title, String content, String link) {
        final Item item = new Item(title, content, link, null, new Date());
        final Entry<Object, Object> entry = new Entry<Object, Object>(nextFeedID(), item);
        return entry;
    }
View Full Code Here

        // Get the list of contributions in the workspace
        Entry<String, Item>[] contributionEntries = contributionCollection.getAll();

        // Read contribution metadata
        for (Entry<String, Item> contributionEntry: contributionEntries) {
            Item contributionItem = contributionEntry.getData();
            Contribution contribution;
            try {
                contribution = contribution(contributionEntry.getKey(), contributionItem.getAlternate());
            } catch (ContributionReadException e) {
                continue;
            }

            // Create entries for the deployable composites
View Full Code Here

    public Item get(String key) throws NotFoundException {
        logger.fine("get " + key);

        // Get the specified contribution info
        String contributionURI = contributionURI(key);
        Item contributionItem = contributionCollection.get(contributionURI);
       
        // Read the contribution
        Contribution contribution;
        try {
            contribution = contribution(contributionURI, contributionItem.getAlternate());
        } catch (ContributionReadException e) {
            throw new NotFoundException(key);
        }

        // Find the specified deployable composite
View Full Code Here

            // contribution
            List<Entry<String, Item>> entries = new ArrayList<Entry<String, Item>>();

            // Get the specified contribution info
            String contributionURI = queryString.substring(queryString.indexOf('=') + 1);
            Item contributionItem;
            try {
                contributionItem = contributionCollection.get(contributionURI);
            } catch (NotFoundException e) {
                return entries.toArray(new Entry[entries.size()]);
            }
           
            // Read the contribution
            Contribution contribution;
            try {
                contribution = contribution(contributionURI, contributionItem.getAlternate());
            } catch (ContributionReadException e) {
                return entries.toArray(new Entry[entries.size()]);
            }

            // Create entries for the deployable composites
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.data.collection.Item

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.