DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
  • submit to reddit
Jason Beres10/16/14
57 views
0 replies

Infragistics Announces New Release: Ultimate 14.2

CRANBURY, N.J., Oct. 15, 2014 – Infragistics, a worldwide leader in desktop, Web, mobile native and mobile hybrid user interface toolsets, today announced the launch of Infragistics Ultimate 14.2, which continues to deliver on the promise of helping...

Christopher Taylor10/16/14
370 views
0 replies

Salesforce’s Wave tries to catch up on analytics

Salesforce will introduce their Wave could analytics functionality at Dreamforce and along with it, an admission that analytics has been missing from their platform for some time. How they got this far without having more than a partner community is the question but at least they’re headed in the right direction.

Adi Gaskell10/16/14
274 views
0 replies

New sites aim to support working remotely

Flexible working has become more acceptable over the years, but it still seems that being free to work from literally anywhere may be a little way off. Nevertheless, it was interesting to read recently of a new report exploring the best places to work for those people fortunate enough to have the kind of job they can do from anywhere.

Jive Community10/16/14
268 views
0 replies

Top 10 Things to Bring to JiveWorld (with a Fun Video!)

I've never been to JiveWorld. On top of that, I've never really attended many conferences either. Or traveled much. So it's safe to say that I have no idea what to pack for JiveWorld.

Adi Gaskell10/16/14
211 views
0 replies

Can MOOCs help slow the spread of Ebola?

It seems that the world is rapidly waking up to the severe threat posed by the Ebola outbreak in western Africa. I wrote last week about the launch of a new open innovation challenge by USAID to try and come up with a new protective suit for healthcare workers.

Comindware Inc.10/16/14
893 views
0 replies

Evaluating the Actual ROI of New Software Implementation

Implementing tools and software rollouts to improve business and IT processes is a risky move, both financially and organizationally. Such implementations, when not considered with diligence and meticulous care, frequently end up providing the opposite of what management initially expects.

Dele Sikuade10/16/14
1755 views
0 replies

The Single Most Important Thing in Agile

Agile is a methodology that was formed to bridge the gap between abstract requirement and real-world want. It implicitly acknowledges the existence of the gap by requiring the business to participate and therefore to be complicit in the process of development and delivery. It is the best methodology I have ever seen for overcoming this problem and this problem is the single biggest cause of pain in software development.

Tomasz Sobczak10/16/14
746 views
1 replies

Review of "Scaling Apache Solr" Book

Review of "Scaling Apache Solr" book.

//Insert a Document at Any Location
/**
 * Inserts content of the external document after the specified node.
 * Section breaks and section formatting of the inserted document are ignored.
 *
 * @param insertAfterNode Node in the destination document after which the content
 * should be inserted. This node should be a block level node (paragraph or table).
 * @param srcDoc The document to insert.
 */
public static void insertDocument(Node insertAfterNode, Document srcDoc) throws Exception
{
    // Make sure that the node is either a paragraph or table.
    if ((insertAfterNode.getNodeType() != NodeType.PARAGRAPH) &
      (insertAfterNode.getNodeType() != NodeType.TABLE))
        throw new IllegalArgumentException("The destination node should be either a paragraph or table.");

    // We will be inserting into the parent of the destination paragraph.
    CompositeNode dstStory = insertAfterNode.getParentNode();

    // This object will be translating styles and lists during the import.
    NodeImporter importer = new NodeImporter(srcDoc, insertAfterNode.getDocument(), ImportFormatMode.KEEP_SOURCE_FORMATTING);

    // Loop through all sections in the source document.
    for (Section srcSection : srcDoc.getSections())
    {
        // Loop through all block level nodes (paragraphs and tables) in the body of the section.
        for (Node srcNode : (Iterable<Node>) srcSection.getBody())
        {
            // Let's skip the node if it is a last empty paragraph in a section.
            if (srcNode.getNodeType() == (NodeType.PARAGRAPH))
            {
                Paragraph para = (Paragraph)srcNode;
                if (para.isEndOfSection() && !para.hasChildNodes())
                    continue;
            }

            // This creates a clone of the node, suitable for insertion into the destination document.
            Node newNode = importer.importNode(srcNode, true);

            // Insert new node after the reference node.
            dstStory.insertAfter(newNode, insertAfterNode);
            insertAfterNode = newNode;
        }
    }
}

//Insert a Document During Mail Merge

//This example relies on the InsertDocument method shown at the beginning of the article to insert a document into a merge field during mail merge execution. This code demonstrates how to use the InsertDocument method to insert a document into a merge field during mail merge.

public void insertDocumentAtMailMerge() throws Exception
{
    // Open the main document.
    Document mainDoc = new Document(getMyDir() + "InsertDocument1.doc");

    // Add a handler to MergeField event
    mainDoc.getMailMerge().setFieldMergingCallback(new InsertDocumentAtMailMergeHandler());

    // The main document has a merge field in it called "Document_1".
    // The corresponding data for this field contains fully qualified path to the document
    // that should be inserted to this field.
    mainDoc.getMailMerge().execute(
        new String[] { "Document_1" },
        new String[] { getMyDir() + "InsertDocument2.doc" });

    mainDoc.save(getMyDir() + "InsertDocumentAtMailMerge Out.doc");
}

private class InsertDocumentAtMailMergeHandler implements IFieldMergingCallback
{
    /**
     * This handler makes special processing for the "Document_1" field.
     * The field value contains the path to load the document.
     * We load the document and insert it into the current merge field.
     */
    public void fieldMerging(FieldMergingArgs e) throws Exception
    {
        if ("Document_1".equals(e.getDocumentFieldName()))
        {
            // Use document builder to navigate to the merge field with the specified name.
            DocumentBuilder builder = new DocumentBuilder(e.getDocument());
            builder.moveToMergeField(e.getDocumentFieldName());

            // The name of the document to load and insert is stored in the field value.
            Document subDoc = new Document((String)e.getFieldValue());

            // Insert the document.
            insertDocument(builder.getCurrentParagraph(), subDoc);

            // The paragraph that contained the merge field might be empty now and you probably want to delete it.
            if (!builder.getCurrentParagraph().hasChildNodes())
                builder.getCurrentParagraph().remove();

            // Indicate to the mail merge engine that we have inserted what we wanted.
            e.setText(null);
        }
    }

    public void imageFieldMerging(ImageFieldMergingArgs args) throws Exception
    {
        // Do nothing.
    }
}
 
//If a document to be inserted is stored as binary data in the database field (BLOB field), use the following example. A slight variation to the above example to load a document from a BLOB database field instead of a file.

private class InsertDocumentAtMailMergeBlobHandler implements IFieldMergingCallback
{
    /**
     * This handler makes special processing for the "Document_1" field.
     * The field value contains the path to load the document.
     * We load the document and insert it into the current merge field.
     */
    public void fieldMerging(FieldMergingArgs e) throws Exception
    {
        if ("Document_1".equals(e.getDocumentFieldName()))
        {
            // Use document builder to navigate to the merge field with the specified name.
            DocumentBuilder builder = new DocumentBuilder(e.getDocument());
            builder.moveToMergeField(e.getDocumentFieldName());

            // Load the document from the blob field.
            ByteArrayInputStream inStream = new ByteArrayInputStream((byte[])e.getFieldValue());
            Document subDoc = new Document(inStream);
            inStream.close();

            // Insert the document.
            insertDocument(builder.getCurrentParagraph(), subDoc);

            // The paragraph that contained the merge field might be empty now and you probably want to delete it.
            if (!builder.getCurrentParagraph().hasChildNodes())
                builder.getCurrentParagraph().remove();

            // Indicate to the mail merge engine that we have inserted what we wanted.
            e.setText(null);
        }
    }
public void imageFieldMerging(ImageFieldMergingArgs args) throws Exception
    {
        // Do nothing.
    }
}

//Insert a Document During Replace

//This example shows how to insert content of one document into another during a customized find and replace operation.

[Code Sample]

public void insertDocumentAtReplace() throws Exception
{
    Document mainDoc = new Document(getMyDir() + "InsertDocument1.doc");
    mainDoc.getRange().replace(Pattern.compile("\\[MY_DOCUMENT\\]"), new InsertDocumentAtReplaceHandler(), false);
    mainDoc.save(getMyDir() + "InsertDocumentAtReplace Out.doc");
}

private class InsertDocumentAtReplaceHandler implements IReplacingCallback
{
    public int replacing(ReplacingArgs e) throws Exception
    {
        Document subDoc = new Document(getMyDir() + "InsertDocument2.doc");

        // Insert a document after the paragraph, containing the match text.
        Paragraph para = (Paragraph)e.getMatchNode().getParentNode();
        insertDocument(para, subDoc);

        // Remove the paragraph with the match text.
        para.remove();

        return ReplaceAction.SKIP;
    }
}
John Walter10/15/14
8798 views
0 replies

The Best of DZone: Oct. 8 - Oct. 15

If you missed anything on DZone this week, now's your chance to catch up! This week's best include a tutorial for getting started building mobile apps with the Ionic framework, an editorial detailing how developers are integrating, an attempt at linear regression, and more.

Adi Gaskell10/15/14
626 views
0 replies

The role of social networks in knowledge sharing in healthcare

Social networks, of both the internal and external variety, often seem to be a technology that is striving for a practical and useful application in our workplaces.

Highq Collaborate10/15/14
481 views
0 replies

Enterprise collaboration for corporates: four core use cases

Secure file sharing, external collaboration, project management and enterprise social networking.

Adi Gaskell10/15/14
412 views
0 replies

Talko aims to support spoken collaboration

As enterprise social networking has taken off, the notion of collaboration has increasingly been seen as a written thing. It makes a lot of sense, in that it allows conversations to be archived and searchable, thus hopefully creating both accountability and a knowledge base for others to tap into.

Daniela Castrataro10/15/14
655 views
0 replies

Shorter is Generally Better – Components of a Good Crowdfunding Campaign 6

It might seem that a longer campaign is a better idea as it gives more opportunity for funding but this is very rarely the case. A sense of urgency and time pressure is generally helpful for all concerned.

Adi Gaskell10/15/14
258 views
0 replies

Is the Ebola grand challenge too little, too late?

The use of social on healthcare is undoubtedly on the rise, with a number of projects aiming to map and predict the spread of disease by monitoring social media output.

Christopher Taylor10/14/14
423 views
0 replies

Social isn’t dead, it’s just an expectation

It’s funny to watch the hype around trends and technologies grow and shrink over time. What seemed like a critical need at one point quietly fades out and slips off the front page.

Adi Gaskell10/14/14
427 views
0 replies

What principles define an innovative organization?

It’s pretty well known that innovating is hard for many companies to achieve. A big reason for that is that most of their profits are derived from being as efficient as possible with their main revenue driving products and services.

Bloomfire Marketing10/14/14
1156 views
0 replies

Measuring the ROI of Enterprise Collaboration

Raise your hand if you’ve ever been asked what is the ROI of your enterprise social collaboration initiatives?

Adi Gaskell10/14/14
356 views
0 replies

How the crowd makes elections better

Crowdsourcing has been deployed in all manner of ways, with an increasing number of them being in political type applications. One of the more interesting is in monitoring elections.

Steve Farnsworth10/14/14
220 views
0 replies

11 Keys Of Persuasion For Social Media Marketing

Social media has been the answer that marketers have been looking for to elevate their efforts.