JBDON
  • Home
  • Applied Analytics
    • Analytics for Decision Making >
      • What is Cluster Analysis
      • Data Reduction and Unsupervised Learning
      • Preparing Data and Measuring Dissimilarities
      • Hierarchical and k-Means Clustering
      • Defining Output Variables and Analyzing the Results
      • Using Historical Data to Model Uncertainty
      • Models with Correlated Uncertain Variables
      • Creating and Interpreting Charts
      • Using Average Values versus Simulation
      • Optimization and Decision Making
      • Formulating an Optimization Problem
      • Developing a Spreadsheet Model
      • Adding Optimization to a Spreadsheet Model
      • What-if Analysis and the Sensitivity Report
      • Evaluating Scenarios and Visualizing Results to Gain Practical Insights
      • Digital Marketing Application of Optimization
      • Advanced Models for Better Decisions
      • Business Problems with Yes/No Decisions
      • Formulation and Solution of Binary Optimization Problems
      • Metaheuristic Optimization
      • Chance Constraints and Value At Risk
      • Simulation Optimization
    • Analytics for Marketing >
      • Marketing Analytics and Customer Satisfaction
      • Customer Satisfaction
      • Measurements and Scaling Techniques – Introduction
      • Primary Scales of Measurement
      • Comparative Scaling
      • Non-Comparative Scaling
      • Experiment Design: Controlling for Experimental Errors
      • A/B Testing: Introduction
      • A/B Testing: Types of Tests
      • ANOVA – Introduction
      • Example -Inspect Spray and Tooth Growth
      • Logit Model - Binary Outome and Forecastign linear regression
      • Text Summarization
      • Social media Microscope
      • N-Gram - Frequcy Count and phase mining
      • LDA Topic Modeling
      • Machine-Learned Classification and Semantic Topic Tagging
    • Data Engine >
      • Understanding The Growth Of Data
      • Evaluating Methods Of Data Access
      • Communication journey
      • Data Journey
      • Planning for data visualisation
      • Visualisation Component
      • Content Connection and Chart Legitibility
    • Customer Insights >
      • Introduction
      • What is Descriptive Analytics?
      • Survey Overview
      • Net Promoter Score and Self-Reports
      • Survey Design
      • Passive Data Collection
      • Media Planning
      • Data Visualization
      • Causal Data Collection and Summary
      • Asking Predictive Questions
      • Regression Analysis
      • Data Set Predictions
      • Probability Models
      • Results and Predictions
      • Perspective Analytics (Maximize Revenue and Market Structure Competitions)
    • Analytics for Advance Marketing >
      • Visualisation and statistics (Political Advertising,Movie Theater and Data Assembly)
      • Excel Analysis of Motion Picture Industry Data
      • Displaying Conditional Distributions
      • Analyzing Qualitative Variables
      • Steps in Constructing Histograms
      • Common Descriptive Statistics for Quantitative Data
      • Regression-Based Modeling
      • Customer Analytics
      • Illustrating Customer Analytics in Excel
      • Customer Valuation Excel Demonstration
  • Soft Skills
    • Adaptability
    • Confidence
    • Change Management
    • Unlearning and Learning
    • Collaboration and Teamwork
    • Cultural Sensitivity
  • Marketing
  • Finance
  • Economics
    • Introduction to Managerial Economics >
      • Basic Techniques
      • The firm: Stakeholders, Objectives and Decision Issues
      • Demand and Revenue Analysis >
        • Demand Estimation and Forecasting
        • Demand Elasticity
        • Demand Concepts and Analysis >
          • Formulation and Solution of Binary Optimization Problems
      • Scope of Managerial Economics
    • Prodution and Cost Analysis >
      • Production Function
      • Estimation of Production and Cost Functions
      • Cost Concepts and Analysis I
      • Cost Concepts and Analysis II
    • Pricing Decisions >
      • Pricing strategies >
        • Adding Optimization to a Spreadsheet Model
      • Market structure and microbes barriers to entry
      • Pricing under pure competition and pure monopoly
      • Pricing under monopolistic and oligopolistic competition
    • Narendra Modi Development Model of Gujarat
  • JBDON Golf
    • Digital Marketing Application of Optimization
  • Let's Talk
  • MBA Project Sharing
  • About Us
    • Good Read >
      • IIMC says PepsiCo CEO Indra Nooyi was an average student
      • India’s middle class figures in Fortune’s Top Ten list of those who matter
      • The Start-Up of you.
      • BUYING AND MERCHANDISING
      • HUMAN RESOURCE MANAGEMENT
      • Do You Suffer From Decision Fatigue?
      • New Page
      • About social media and web 2.0
      • Building Your Own Start-up Technology Company, Part 1
      • Building Your Own Start-up Technology Company, Part 2
      • Building Your Own Start-up Technology Company, Part 3
      • Building Your Own Start-up Technology Company, Part 4
      • Renewable energy is no longer alternative energy
      • What Makes an Exceptional Social Media Manager?
      • The Forgotten Book that Helped Shape the Modern Economy
      • Home
      • How to Think Creatively
      • A Lighthearted Looks at Project Management and Sports Analogies
      • Why Trust Matters More Than Ever for Brands
  • CET Knowledge Zone
    • Tips From JBIMS Students >
      • Prasad Sawant
      • Chandan Roy
      • Ram
      • Ashmant Tiwari
      • Rajesh Rikame
      • Ami Kothari
      • Ankeet Adani
      • Sonam Jain
      • Marketing Analytics and Customer Satisfaction
      • Mitesh Thakker
      • Tresa Sankoorikal
    • Speed Techniques
    • CET Workshops
  • Untitled
  • New Page
    • Cluster analysis using excel and excel miner
    • Chance Constraints and Value At Risk
    • Adding Uncertainty to a Spreadsheet Model
  • Adidas

//Java Helper Class for Janrain Engage import java.util.Map; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.ArrayList; import java.net.URL; import java.net.URLEncoder; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.ProtocolException; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.io.IOException; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.*; import org.xml.sax.SAXException; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Rpx { private String apiKey; private String baseUrl; public Rpx(String apiKey, String baseUrl) { while (baseUrl.endsWith("/")) baseUrl = baseUrl.substring(0, baseUrl.length() - 1); this.apiKey = apiKey; this.baseUrl = baseUrl; } public String getApiKey() { return apiKey; } public String getBaseUrl() { return baseUrl; } public Element authInfo(String token) { Map query = new HashMap(); query.put("token", token); return apiCall("auth_info", query); } public HashMap allMappings() { Element rsp = apiCall("all_mappings", null); Element mappings_node = (Element)rsp.getFirstChild(); HashMap result = new HashMap(); NodeList mappings = getNodeList("/rsp/mappings/mapping", rsp); for (int i = 0; i < mappings.getLength(); i++) { Element mapping = (Element)mappings.item(i); List identifiers = new ArrayList(); NodeList rk_list = getNodeList("primaryKey", mapping); NodeList id_list = getNodeList("identifiers/identifier", mapping); String remote_key = ((Element)rk_list.item(0)).getTextContent(); for (int j = 0; j < id_list.getLength(); j++) { Element ident = (Element) id_list.item(j); identifiers.add(ident.getTextContent()); } result.put(remote_key, identifiers); } return result; } private NodeList getNodeList(String xpath_expr, Element root) { XPathFactory factory = XPathFactory.newInstance(); XPath xpath = factory.newXPath(); try { return (NodeList) xpath.evaluate(xpath_expr, root, XPathConstants.NODESET); } catch (XPathExpressionException e) { return null; } } public List mappings(Object primaryKey) { Map query = new HashMap(); query.put("primaryKey", primaryKey); Element rsp = apiCall("mappings", query); Element oids = (Element)rsp.getFirstChild(); List result = new ArrayList(); NodeList nl = oids.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Element e = (Element)nl.item(i); result.add(e.getTextContent()); } return result; } public void map(String identifier, Object primaryKey) { Map query = new HashMap(); query.put("identifier", identifier); query.put("primaryKey", primaryKey); apiCall("map", query); } public void unmap(String identifier, Object primaryKey) { Map query = new HashMap(); query.put("identifier", identifier); query.put("primaryKey", primaryKey); apiCall("unmap", query); } private Element apiCall(String methodName, Map partialQuery) { Map query = null; if (partialQuery == null) { query = new HashMap(); } else { query = new HashMap(partialQuery); } query.put("format", "xml"); query.put("apiKey", apiKey); StringBuffer sb = new StringBuffer(); for (Iterator it = query.entrySet().iterator(); it.hasNext();) { if (sb.length() > 0) sb.append('&'); try { Map.Entry e = (Map.Entry)it.next(); sb.append(URLEncoder.encode(e.getKey().toString(), "UTF-8")); sb.append('='); sb.append(URLEncoder.encode(e.getValue().toString(), "UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException("Unexpected encoding error", e); } } String data = sb.toString(); try { URL url = new URL(baseUrl + "/api/v2/" + methodName); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.connect(); OutputStreamWriter osw = new OutputStreamWriter( conn.getOutputStream(), "UTF-8"); osw.write(data); osw.close(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setIgnoringElementContentWhitespace(true); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(conn.getInputStream()); Element response = (Element)doc.getFirstChild(); if (!response.getAttribute("stat").equals("ok")) { throw new RuntimeException("Unexpected API error"); } return response; } catch (MalformedURLException e) { throw new RuntimeException("Unexpected URL error", e); } catch (IOException e) { throw new RuntimeException("Unexpected IO error", e); } catch (ParserConfigurationException e) { throw new RuntimeException("Unexpected XML error", e); } catch (SAXException e) { throw new RuntimeException("Unexpected XML error", e); } } public static void main(String [] args) { if (args.length < 3) { System.out.println("Usage: Rpx [...]"); System.exit(1); } Rpx r = new Rpx(args[0], args[1]); if (args[2].equals("mappings")) { System.out.println("Mappings for " + args[3] + ":"); System.out.println(r.mappings(args[3])); } if (args[2].equals("map")) { System.out.println(args[3] + " mapped to " + args[4]); r.map(args[3], args[4]); } if (args[2].equals("unmap")) { System.out.println(args[3] + " unmapped from " + args[4]); r.unmap(args[3], args[4]); } if (args[2].equals("all_mappings")) { System.out.println("All mappings:"); System.out.println(r.allMappings().toString()); } } }
Powered by Create your own unique website with customizable templates.
  • Home
  • Applied Analytics
    • Analytics for Decision Making >
      • What is Cluster Analysis
      • Data Reduction and Unsupervised Learning
      • Preparing Data and Measuring Dissimilarities
      • Hierarchical and k-Means Clustering
      • Defining Output Variables and Analyzing the Results
      • Using Historical Data to Model Uncertainty
      • Models with Correlated Uncertain Variables
      • Creating and Interpreting Charts
      • Using Average Values versus Simulation
      • Optimization and Decision Making
      • Formulating an Optimization Problem
      • Developing a Spreadsheet Model
      • Adding Optimization to a Spreadsheet Model
      • What-if Analysis and the Sensitivity Report
      • Evaluating Scenarios and Visualizing Results to Gain Practical Insights
      • Digital Marketing Application of Optimization
      • Advanced Models for Better Decisions
      • Business Problems with Yes/No Decisions
      • Formulation and Solution of Binary Optimization Problems
      • Metaheuristic Optimization
      • Chance Constraints and Value At Risk
      • Simulation Optimization
    • Analytics for Marketing >
      • Marketing Analytics and Customer Satisfaction
      • Customer Satisfaction
      • Measurements and Scaling Techniques – Introduction
      • Primary Scales of Measurement
      • Comparative Scaling
      • Non-Comparative Scaling
      • Experiment Design: Controlling for Experimental Errors
      • A/B Testing: Introduction
      • A/B Testing: Types of Tests
      • ANOVA – Introduction
      • Example -Inspect Spray and Tooth Growth
      • Logit Model - Binary Outome and Forecastign linear regression
      • Text Summarization
      • Social media Microscope
      • N-Gram - Frequcy Count and phase mining
      • LDA Topic Modeling
      • Machine-Learned Classification and Semantic Topic Tagging
    • Data Engine >
      • Understanding The Growth Of Data
      • Evaluating Methods Of Data Access
      • Communication journey
      • Data Journey
      • Planning for data visualisation
      • Visualisation Component
      • Content Connection and Chart Legitibility
    • Customer Insights >
      • Introduction
      • What is Descriptive Analytics?
      • Survey Overview
      • Net Promoter Score and Self-Reports
      • Survey Design
      • Passive Data Collection
      • Media Planning
      • Data Visualization
      • Causal Data Collection and Summary
      • Asking Predictive Questions
      • Regression Analysis
      • Data Set Predictions
      • Probability Models
      • Results and Predictions
      • Perspective Analytics (Maximize Revenue and Market Structure Competitions)
    • Analytics for Advance Marketing >
      • Visualisation and statistics (Political Advertising,Movie Theater and Data Assembly)
      • Excel Analysis of Motion Picture Industry Data
      • Displaying Conditional Distributions
      • Analyzing Qualitative Variables
      • Steps in Constructing Histograms
      • Common Descriptive Statistics for Quantitative Data
      • Regression-Based Modeling
      • Customer Analytics
      • Illustrating Customer Analytics in Excel
      • Customer Valuation Excel Demonstration
  • Soft Skills
    • Adaptability
    • Confidence
    • Change Management
    • Unlearning and Learning
    • Collaboration and Teamwork
    • Cultural Sensitivity
  • Marketing
  • Finance
  • Economics
    • Introduction to Managerial Economics >
      • Basic Techniques
      • The firm: Stakeholders, Objectives and Decision Issues
      • Demand and Revenue Analysis >
        • Demand Estimation and Forecasting
        • Demand Elasticity
        • Demand Concepts and Analysis >
          • Formulation and Solution of Binary Optimization Problems
      • Scope of Managerial Economics
    • Prodution and Cost Analysis >
      • Production Function
      • Estimation of Production and Cost Functions
      • Cost Concepts and Analysis I
      • Cost Concepts and Analysis II
    • Pricing Decisions >
      • Pricing strategies >
        • Adding Optimization to a Spreadsheet Model
      • Market structure and microbes barriers to entry
      • Pricing under pure competition and pure monopoly
      • Pricing under monopolistic and oligopolistic competition
    • Narendra Modi Development Model of Gujarat
  • JBDON Golf
    • Digital Marketing Application of Optimization
  • Let's Talk
  • MBA Project Sharing
  • About Us
    • Good Read >
      • IIMC says PepsiCo CEO Indra Nooyi was an average student
      • India’s middle class figures in Fortune’s Top Ten list of those who matter
      • The Start-Up of you.
      • BUYING AND MERCHANDISING
      • HUMAN RESOURCE MANAGEMENT
      • Do You Suffer From Decision Fatigue?
      • New Page
      • About social media and web 2.0
      • Building Your Own Start-up Technology Company, Part 1
      • Building Your Own Start-up Technology Company, Part 2
      • Building Your Own Start-up Technology Company, Part 3
      • Building Your Own Start-up Technology Company, Part 4
      • Renewable energy is no longer alternative energy
      • What Makes an Exceptional Social Media Manager?
      • The Forgotten Book that Helped Shape the Modern Economy
      • Home
      • How to Think Creatively
      • A Lighthearted Looks at Project Management and Sports Analogies
      • Why Trust Matters More Than Ever for Brands
  • CET Knowledge Zone
    • Tips From JBIMS Students >
      • Prasad Sawant
      • Chandan Roy
      • Ram
      • Ashmant Tiwari
      • Rajesh Rikame
      • Ami Kothari
      • Ankeet Adani
      • Sonam Jain
      • Marketing Analytics and Customer Satisfaction
      • Mitesh Thakker
      • Tresa Sankoorikal
    • Speed Techniques
    • CET Workshops
  • Untitled
  • New Page
    • Cluster analysis using excel and excel miner
    • Chance Constraints and Value At Risk
    • Adding Uncertainty to a Spreadsheet Model
  • Adidas