You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2014/08/28 05:48:28 UTC
[21/51] [partial] rename folder /datajs into /odatajs. no file
modification.
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/d5ec5557/odatajs/demo/scripts/tools.js
----------------------------------------------------------------------
diff --git a/odatajs/demo/scripts/tools.js b/odatajs/demo/scripts/tools.js
new file mode 100644
index 0000000..d13dd7d
--- /dev/null
+++ b/odatajs/demo/scripts/tools.js
@@ -0,0 +1,146 @@
+(function($) {
+ $.fn.prettify = function(options) {
+ return this.each(function() {
+ try {
+ var $code = $(document.createElement('div')).addClass('code');
+ $(this).before($code).remove();
+ var content = $(this).text();
+ var match = /(xml|json)/.exec($(this).attr('data-type'));
+ var format = (match) ? match[1] : null;
+ var html = null;
+ if (format == 'xml') {
+ var xmlDoc = $.parseXML(content);
+ html = (xmlDoc) ? formatXML(xmlDoc) : null;
+ } else if (format == 'json') {
+ var jsonObj = $.parseJSON(content);
+ html = (jsonObj) ? formatJSON(jsonObj) : null;
+ }
+ if (html) {
+ $code.addClass(format).html(html).find('.list').each(function() {
+ if (this.parentNode.nodeName == 'LI') {
+ $(document.createElement('div')).addClass("toggle").text("-").click(function() {
+ var target = $(this).siblings('.list:first');
+ if (target.size() != 1)
+ return;
+ if (target.is(':hidden')) {
+ target.show().siblings('.deffered').remove();
+ } else {
+ target.hide().before($(document.createElement('span')).attr("class", "deffered").html("..."));
+ }
+ $(this).text($(this).text() == '-' ? '+' : '-');
+ }).insertBefore($(this.parentNode).children(':first'));
+ }
+ });
+ }
+ } catch (e) {
+ console.log(e);
+ }
+ /* encode html */
+ function encodeHtml(html) {
+ return (html != null) ? html.toString().replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">") : '';
+ }
+ /* convert json to html */
+ function formatJSON(value) {
+ var typeofValue = typeof value;
+ if (value == null) {
+ return '<span class="null">null</span>';
+ } else if (typeofValue == 'number') {
+ return '<span class="numeric">' + encodeHtml(value) + '</span>';
+ } else if (typeofValue == 'string') {
+ if (/^(http|https):\/\/[^\s]+$/.test(value)) {
+ var fragment = '';
+ var fragmentIndex = value.indexOf('#');
+ if (fragmentIndex != -1) {
+ fragment = value.substr(fragmentIndex);
+ value = value.substr(0, fragmentIndex);
+ }
+ var format = (value.length > 7) ? (value.substr(value.length - 7, 7) == '/$value' ? '' : '&$format=json' ) : '';
+ format = (value.length > 10) ? (value.substr(value.length - 10, 10) == '/$metadata' ? '' : '&$format=json' ) : '';
+ var separator = (value.indexOf('?') == -1) ? '?' : '&';
+ return '<span class="string">"<a href="' + value + separator + 'sap-ds-debug=true' + format + fragment + '">' + encodeHtml(value) + encodeHtml(fragment) + '</a>"</span>';
+ } else {
+ return '<span class="string">"' + encodeHtml(value) + '"</span>'
+ }
+ } else if (typeofValue == 'boolean') {
+ return '<span class="boolean">' + encodeHtml(value) + '</span>'
+ } else if (value && value.constructor == Array) {
+ return formatArray(value);
+ } else if (typeofValue == 'object') {
+ return formatObject(value);
+ } else {
+ return '';
+ }
+ function formatArray(json) {
+ var html = '';
+ for ( var prop in json)
+ html += '<li>' + formatJSON(json[prop]) + '</li>';
+ return (html) ? '<span class="array">[</span><ul class="array list">' + html + '</ul><span class="array">]</span>' : '<span class="array">[]</span>'
+ }
+ function formatObject(json) {
+ var html = '';
+ for ( var prop in json)
+ html += '<li><span class="property">' + encodeHtml(prop) + '</span>: ' + formatJSON(json[prop]) + '</li>';
+ return (html) ? '<span class="obj">{</span><ul class="obj list">' + html + '</ul><span class="obj">}</span>' : '<span class="obj">{}</span>';
+ }
+ }
+ /* convert xml to html */
+ function formatXML(document) {
+ return formatElement(document.documentElement);
+ function formatElement(element) {
+ var html = '<span><</span><span class="tag">' + encodeHtml(element.nodeName) + '</span>';
+ if (element.attributes && element.attributes.length > 0) {
+ html += formatAttributes(element);
+ }
+ if (element.childNodes && element.childNodes.length > 0) {
+ html += '<span>></span>';
+ if (element.childNodes.length == 1 && element.childNodes[0].nodeType == 3) {
+ html += '<span class="text">' + encodeHtml(element.childNodes[0].nodeValue) + '</span>';
+ } else {
+ html += formatChildNodes(element.childNodes);
+ }
+ html += '<span></</span><span class="tag">' + encodeHtml(element.nodeName) + '</span><span>></span>';
+ } else {
+ html += '<span>/></span>';
+ }
+ return html;
+ }
+ function formatChildNodes(childNodes) {
+ html = '<ul class="list">';
+ for ( var i = 0; i < childNodes.length; i++) {
+ var node = childNodes[i];
+ if (node.nodeType == 1) {
+ html += '<li>' + formatElement(node) + '</li>';
+ } else if (node.nodeType == 3 && !/^\s+$/.test(node.nodeValue)) {
+ html += '<li><span class="text">' + encodeHtml(node.nodeValue) + '</span></li>';
+ } else if (node.nodeType == 4) {
+ html += '<li><span class="cdata"><![CDATA[' + encodeHtml(node.nodeValue) + ']]></span></li>';
+ } else if (node.nodeType == 8) {
+ html += '<li><span class="comment"><!--' + encodeHtml(node.nodeValue) + '--></span></li>';
+ }
+ }
+ html += '</ul>';
+ return html;
+ }
+ function formatAttributes(element) {
+ var html = '';
+ for (var i = 0; i < element.attributes.length; i++) {
+ var attribute = element.attributes[i];
+ if (/^xmlns:[^\s]+$/.test(attribute.nodeName)) {
+ html += ' <span class="ns">' + encodeHtml(attribute.nodeName) + '="' + encodeHtml(attribute.nodeValue) + '"</span>';
+ } else {
+ html += ' <span class="atn">' + encodeHtml(attribute.nodeName) + '</span>=';
+ if (attribute.nodeName == 'href' || attribute.nodeName == 'src') {
+ var separator = (attribute.nodeValue.indexOf('?') == -1) ? '?' : '&';
+ var href = (element.baseURI && attribute.nodeValue[0] != '/') ? element.baseURI + attribute.nodeValue : attribute.nodeValue;
+ html += '"<a class="link" href="' + href + separator + 'sap-ds-debug=true">' + encodeHtml(attribute.nodeValue) + '</a>"';
+ } else {
+ html += '"<span class="atv">' + encodeHtml(attribute.nodeValue) + '</span>"';
+ }
+ }
+ }
+ return html;
+ }
+ }
+ });
+ };
+})(jQuery);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/d5ec5557/odatajs/demo/tester.html
----------------------------------------------------------------------
diff --git a/odatajs/demo/tester.html b/odatajs/demo/tester.html
new file mode 100644
index 0000000..512b9e1
--- /dev/null
+++ b/odatajs/demo/tester.html
@@ -0,0 +1,217 @@
+<html>
+ <head>
+ <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
+ <title>datajs startup perf test</title>
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
+ <script type="text/javascript" src="./scripts/odatajs-4.0.0-beta-01.js"></script>
+ <script type="text/javascript" src="./scripts/tools.js" ></script>
+ <style type="text/css">
+ .code{font-family:"Courier New",monospace;font-size:13px;line-height:18px;}
+ .code ul{list-style:none;margin:0 0 0 1.5em;padding:0;}
+ .code li{position:relative;}
+ .code.json li:after{content:',';}
+ .code.json li:last-child:after{content:'';}
+ .code span{white-space:nowrap;padding:2px 1px;}
+ .code .property{font-weight:bold;color:#000000;}
+ .code .null{color:#9d261d;}
+ .code .boolean{color:#760a85;}
+ .code .numeric{color:#0076cb;}
+ .code .string{color:#247230;}
+ .code .deffered{color:#666666;font-size:0.9em;}
+ .code .toggle{position:absolute;left:-1em;cursor:pointer;}
+ .code .tag{color:#003283;}
+ .code .atn{color:#760a85;}
+ .code .atv{color:#247230;}
+ .code .text{color:#000000;}
+ .code .cdata{color:#008080;}
+ .code .comment,.code .ns{color:#666666;}
+
+ .left {
+ margin-left : 20px;
+ position:relative;
+ }
+
+ </style>
+ </head>
+ <body>
+ <table><tr><td valign="top" width="150px">
+ Metadata<br>
+ <input type="radio" id="inMetadata1" name="inMetadata" value="none"/>
+ <label for="inMetadata1">none</label><br>
+
+ <input type="radio" id="inMetadata2" name="inMetadata" value="minimal" checked="checked"/>
+ <label for="inMetadata2">minimal<br>
+ <div class="left">
+ <input type="checkbox" id="inMinimalToFull">
+ <label for="inMinimalToFull" id="lblInMinimalToFull">minimal to full</label><br>
+ </div>
+
+ <input type="radio" id="inMetadata3" name="inMetadata" value="full"><label for="inMetadata3">full</label>
+ <br>
+ Recognize Dates<br>
+ <input type="checkbox" id="inRecognizeDates"><label for="check1">yes/no</label><br>
+
+ </td><td>
+ <div id="buttons"></div>
+ </td><td>
+ <button id="btnMetaData">MetaData</button><br/>
+ <button id="btnPOST_entry_food">POST food entry</button><br/>
+ <button id="btnPOST_entry_categorie">POST categorie entry</button><br/>
+ </td></tr></table>
+ <div id='resultsArea' data-type="json">
+ </div>
+ <script>
+ // Config
+ var config = [
+ { name: 'Feed', url: 'http://localhost:4002/tests/endpoints/FoodStoreDataServiceV4.svc/Foods'},
+ { name: 'Entry', url: 'http://localhost:4002/tests/endpoints/FoodStoreDataServiceV4.svc/Foods(0)'},
+ { name: 'Collection of Complex', url: 'http://localhost:4002/tests/endpoints/FoodStoreDataServiceV4.svc/Foods(0)/Providers'},
+ { name: 'Collection of Simple', url: 'http://localhost:4002/tests/endpoints/FoodStoreDataServiceV4.svc/Foods(0)/AlternativeNames'},
+ { name: 'Complex property', url: 'http://localhost:4002/tests/endpoints/FoodStoreDataServiceV4.svc/Foods(0)/Packaging'},
+ { name: 'Simple property', url: 'http://localhost:4002/tests/endpoints/FoodStoreDataServiceV4.svc/Foods(0)/Name'},
+ ];
+
+ // UI Stuff
+ var createButtonClickHandler = function(nr) {
+ return function() { buttonClick(nr);};
+ };
+
+ var buttonRoot = $('#buttons');
+ $("input[name*='inMetadata'").click( function() {
+ var metadata = $("input[name*='inMetadata']:checked").val();
+ if (metadata === "minimal") {
+ $("#lblInMinimalToFull").css('color', '#000000');
+ $("#inMinimalToFull").removeAttr('disabled');
+ } else {
+ $("#lblInMinimalToFull").css('color', '#999999');
+ $("#inMinimalToFull").attr('disabled','disabled');
+ }
+ });
+
+ for (var i = 0; i < config.length; i++) {
+ var button = $('<button id="btnArray">'+config[i].name+'</button><br/>"');
+ button.click( createButtonClickHandler(i));
+ buttonRoot.append(button);
+ }
+
+ // Testing
+ function buttonClick(configNr) {
+ var metadata = $("input[name*='inMetadata']:checked").val();
+ var recognizeDates = ($("#inRecognizeDates").val() ==='on') ? true : false;
+ var inMinimalToFull = ($("#inMinimalToFull").val() ==='on') ? true : false;
+
+ var requestUri = {
+ requestUri : config[configNr].url
+ };
+
+ requestUri.recognizeDates = recognizeDates;
+
+ var metaDatasuccess = function(metadata){
+ odatajs.oData.read(requestUri, success, errorFunc, null, null, metadata);
+ };
+
+ if ( metadata === 'full') {
+ requestUri.headers = { Accept : 'application/json;odata.metadata=full' };
+ odatajs.oData.read(requestUri, success, errorFunc);
+ } else if ( metadata === 'minimal') {
+ requestUri.headers = { Accept : 'application/json;odata.metadata=minimal' };
+ if (inMinimalToFull) {
+ getMetaData(metaDatasuccess);
+ } else {
+ odatajs.oData.read(requestUri, success, errorFunc);
+ }
+ } else {
+ requestUri.headers = { Accept : 'application/json;odata.metadata=none' };
+ odatajs.oData.read(requestUri, success, errorFunc);
+ }
+ }
+
+ function show(data) {
+ $('#resultsArea').empty();
+ var code = $('<code data-type="json"></code>').text(JSON.stringify(data));
+ $('#resultsArea').append(code);
+ $('code[data-type]').prettify();
+ }
+ function success(data) {
+ show(data);
+ }
+
+ function errorFunc(err) {
+ $('#resultsArea').empty();
+ $("#resultsArea").text(JSON.stringify(err));
+ }
+
+ function getMetaData(metaDatasuccess) {
+ var oHeaders = {
+ 'Accept': 'text/html,application/xhtml+xml,application/xml,application/json;odata.metadata=full',
+ "Odata-Version": "4.0",
+ "OData-MaxVersion": "4.0",
+ "Prefer": "odata.allow-entityreferences"
+ };
+ var metadataRequest =
+ {
+ headers: oHeaders,
+ //requestUri: "http://services.odata.org/OData/OData.svc/$metadata",
+ requestUri: "http://localhost:4002/tests/endpoints/FoodStoreDataServiceV4.svc/$metadata", //"http://localhost:6630/PrimitiveKeys.svc/$metadata",
+ data: null,
+ };
+ odatajs.oData.read(metadataRequest, metaDatasuccess, errorFunc,odatajs.oData.metadataHandler);
+ }
+
+ /*******Special buttons***********/
+
+ $('#btnMetaData').on("click", function(){
+ var oHeaders = {
+ 'Accept': 'text/html,application/xhtml+xml,application/xml,application/json;odata.metadata=full',
+ "Odata-Version": "4.0",
+ "OData-MaxVersion": "4.0",
+ "Prefer": "odata.allow-entityreferences"
+ };
+ var metadataRequest =
+ {
+ headers: oHeaders,
+ //requestUri: "http://services.odata.org/OData/OData.svc/$metadata",
+ requestUri: "http://localhost:4002/tests/endpoints/FoodStoreDataServiceV4.svc/$metadata", //"http://localhost:6630/PrimitiveKeys.svc/$metadata",
+ data: null,
+ };
+
+ odatajs.oData.read(metadataRequest, success, errorFunc,odatajs.oData.metadataHandler);
+ });
+
+ $('#btnPOST_entry_food').on("click", function(){
+ var requestUri = {
+ requestUri : 'http://localhost:4002/tests/endpoints/FoodStoreDataServiceV4.svc/Foods',
+ method: 'POST',
+ headers : { Accept : 'application/json' },
+ recognizeDates : true,
+ data : {
+ "@odata.type": "#DataJS.Tests.V4.Food",
+ "@odata.context": "http://localhost:4002/tests/endpoints/FoodStoreDataServiceV4.svc/$metadata#Foods/$entity",
+ FoodID: 111,
+ Name: "flour1"
+ }
+ };
+ odatajs.oData.read(requestUri, success, errorFunc);
+ });
+ $('#btnPOST_entry_categorie').on("click", function(){
+
+ var requestUri = {
+ requestUri : 'http://localhost:4002/tests/endpoints/FoodStoreDataServiceV4.svc/Categories',
+ method: 'POST',
+ headers : { Accept : 'application/json' },
+ recognizeDates : true,
+ data : {
+ "@odata.type": "#DataJS.Tests.V4.Category",
+ "@odata.context": "http://localhost:4002/tests/endpoints/FoodStoreDataServiceV4.svc/$metadata#Categories/$entity",
+ CategoryID: 111,
+ Name: "cat111"
+ }
+ };
+ odatajs.oData.read(requestUri, success, errorFunc);
+ });
+
+
+
+ </script>
+ </body>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/d5ec5557/odatajs/demo/testerV2.html
----------------------------------------------------------------------
diff --git a/odatajs/demo/testerV2.html b/odatajs/demo/testerV2.html
new file mode 100644
index 0000000..b9bf1c8
--- /dev/null
+++ b/odatajs/demo/testerV2.html
@@ -0,0 +1,72 @@
+<html>
+ <head>
+ <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
+ <title>datajs startup perf test</title>
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
+ <script type="text/javascript" src="./scripts/datajs-1.1.2.js"></script>
+ <script type="text/javascript" src="./scripts/tools.js" ></script>
+ <style type="text/css">
+ .code{font-family:"Courier New",monospace;font-size:13px;line-height:18px;}
+ .code ul{list-style:none;margin:0 0 0 1.5em;padding:0;}
+ .code li{position:relative;}
+ .code.json li:after{content:',';}
+ .code.json li:last-child:after{content:'';}
+ .code span{white-space:nowrap;padding:2px 1px;}
+ .code .property{font-weight:bold;color:#000000;}
+ .code .null{color:#9d261d;}
+ .code .boolean{color:#760a85;}
+ .code .numeric{color:#0076cb;}
+ .code .string{color:#247230;}
+ .code .deffered{color:#666666;font-size:0.9em;}
+ .code .toggle{position:absolute;left:-1em;cursor:pointer;}
+ .code .tag{color:#003283;}
+ .code .atn{color:#760a85;}
+ .code .atv{color:#247230;}
+ .code .text{color:#000000;}
+ .code .cdata{color:#008080;}
+ .code .comment,.code .ns{color:#666666;}
+ </style>
+ </head>
+ <body>
+ <button id="btnMetaData">MetaData</button><br/>
+ <button id="btnJSON_minimal">pure JSON</button><br/>
+
+ <div id='resultsArea'>
+
+ </div>
+ <script>
+ function show(data) {
+ $('#resultsArea').empty();
+ var code = $('<code data-type="json"></code>').text(JSON.stringify(data))
+ $('#resultsArea').append(code);
+ $('code[data-type]').prettify();
+ }
+ function success(data) {
+ show(data);
+ }
+
+ function errorFunc(err) {
+ $('#resultsArea').empty();
+ $("#resultsArea").text(JSON.stringify(err));
+ }
+
+
+ $('#btnMetaData').on("click", function(){
+ var metadata;
+ OData.read("http://localhost:4003/sap/bc/ds/odata/v2/$metadata",success, errorFunc, OData.metadataHandler);
+ });
+
+ $('#startXML').on("click", function(){
+ //var requestUri = 'http://localhost:4002/tests/endpoints/FoodStoreDataServiceV4.svc/Foods';
+ var requestUri ='http://localhost:4003/sap/bc/odata/Employees';
+ OData.read(requestUri, success, errorFunc);
+ });
+
+ $('#btnJSON_minimal').on("click", function(){
+ var requestUri ='http://localhost:4003/sap/bc/odata/Employees?$format=json';
+ OData.read(requestUri, success, errorFunc);
+ });
+
+ </script>
+ </body>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/d5ec5557/odatajs/grunt-config/browserify_transforms/stripheader/package.json
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/browserify_transforms/stripheader/package.json b/odatajs/grunt-config/browserify_transforms/stripheader/package.json
new file mode 100644
index 0000000..b8837af
--- /dev/null
+++ b/odatajs/grunt-config/browserify_transforms/stripheader/package.json
@@ -0,0 +1,24 @@
+{
+ "name": "grunt-rat",
+ "version": "0.0.1",
+ "description": "Transform vor removing license headers",
+ "license": "Apache",
+ "author": {
+ "name": "Sven Kobler-Morris",
+ "email": "koblers@apache.org"
+ },
+ "files": [
+ "tasks"
+ ],
+ "dependencies": {
+ "through": "^2.3.4"
+ },
+ "devDependencies": {
+ },
+ "peerDependencies": {
+ "grunt": "~0.4.0"
+ },
+ "engines": {
+ "node": ">=0.8.0"
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/d5ec5557/odatajs/grunt-config/browserify_transforms/stripheader/stripheader.js
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/browserify_transforms/stripheader/stripheader.js b/odatajs/grunt-config/browserify_transforms/stripheader/stripheader.js
new file mode 100644
index 0000000..7df58cb
--- /dev/null
+++ b/odatajs/grunt-config/browserify_transforms/stripheader/stripheader.js
@@ -0,0 +1,21 @@
+var through = require('through');
+
+module.exports = function (file) {
+ //if (/\.json$/.test(file)) return through();
+
+ var data = "";
+
+ return through(
+ function (buf) { data += buf; },
+ function () {
+ try {
+ var out = data.replace(/^(\/\*(.|\n|\r)*?\*\/)/gi,"");
+ this.queue(out);
+ } catch (er) {
+ this.emit("error", new Error(er.toString().replace("Error: ", "") + " (" + file + ")"));
+ }
+ this.queue(null);
+ }
+ );
+};
+
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/d5ec5557/odatajs/grunt-config/custom-tasks/rat/package.json
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/custom-tasks/rat/package.json b/odatajs/grunt-config/custom-tasks/rat/package.json
new file mode 100644
index 0000000..6753173
--- /dev/null
+++ b/odatajs/grunt-config/custom-tasks/rat/package.json
@@ -0,0 +1,26 @@
+{
+ "name": "grunt-rat",
+ "version": "0.0.1",
+ "description": "Run Apache Rat(release audit tool)",
+ "license": "Apache",
+ "author": {
+ "name": "Sven Kobler-Morris",
+ "email": "koblers@apache.org"
+ },
+ "files": [
+ "tasks"
+ ],
+ "dependencies": {
+ "chalk": "~0.4.0"
+ },
+ "devDependencies": {
+ "grunt": "~0.4.0",
+ "xml2js": "^0.4.4"
+ },
+ "peerDependencies": {
+ "grunt": "~0.4.0"
+ },
+ "engines": {
+ "node": ">=0.8.0"
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/d5ec5557/odatajs/grunt-config/custom-tasks/rat/readme.md
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/custom-tasks/rat/readme.md b/odatajs/grunt-config/custom-tasks/rat/readme.md
new file mode 100644
index 0000000..2921499
--- /dev/null
+++ b/odatajs/grunt-config/custom-tasks/rat/readme.md
@@ -0,0 +1,2 @@
+require http://creadur.apache.org/rat/download_rat.cgi --> apache-rat-0.10-bin.zip
+to be upacked to /tools/apache-rat-0.10-bin
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/d5ec5557/odatajs/grunt-config/custom-tasks/rat/tasks/rat.js
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/custom-tasks/rat/tasks/rat.js b/odatajs/grunt-config/custom-tasks/rat/tasks/rat.js
new file mode 100644
index 0000000..8c6e8b0
--- /dev/null
+++ b/odatajs/grunt-config/custom-tasks/rat/tasks/rat.js
@@ -0,0 +1,93 @@
+'use strict';
+
+module.exports = function (grunt) {
+ grunt.registerMultiTask('rat', 'Run Apache Rat', function () {
+ var path = require('path');
+ var chalk = require('chalk');
+ var childProcess = require('child_process');
+ var xml2js = require('xml2js');
+ var fs = require('fs');
+
+ var cb = this.async();
+
+ var options = this.options({ xml : true, tmpDir : './build/tmp'});
+ var dir = this.data.dir;
+ var out = options.tmpDir + '/' + (options.xml ? 'rat.xml' : 'rat.txt');
+
+ var pathToRat = path.resolve(__dirname,'./../tools/apache-rat-0.10/apache-rat-0.10.jar');
+
+ //sample command java -jar apache-rat-0.10.jar -x -d ./src > ./build/tmp/rat.txt
+ var cmd = 'java -jar ' + pathToRat+ ' ';
+ cmd += options.xml ? ' -x' : '';
+ cmd += ' --force -d ' + dir + ' > ' + out;
+
+ grunt.verbose.writeln('Directory: '+dir);
+
+ var cp = childProcess.exec(cmd, options.execOptions, function (err, stdout, stderr) {
+ if (err) {
+ grunt.fail.warn('rat --> ' + err, 1); //exit grunt with error code 1
+ }
+
+
+
+ if (!options.xml) {
+ grunt.fail.warn('rat --> ' + 'No XML output: checkRatLogFile skipped!', 1);
+ }
+
+ var xml = grunt.file.read(out);
+ var parser = new xml2js.Parser();
+
+ parser.parseString(xml, function (err, result) {
+
+ if (err) {
+ grunt.fail.warn('rat --> ' + err, 1);
+ }
+
+ if (checkRatLogFile(result)) {
+ grunt.fail.warn('rat --> ' + 'Missing or Invalied license header detected ( see "'+out+'")', 1);
+ }
+
+
+ });
+ cb();
+
+ }.bind(this));
+
+ var checkRatLogFile = function(result) {
+
+ var list = result['rat-report']['resource'];
+ for (var i = 0; i < list.length; i++ ){
+ var item = list[i];
+
+ var headerType = list[i]['header-type'];
+ var attr = headerType[0]['$'];
+ if (attr.name.trim() !== 'AL') {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ var captureOutput = function (child, output) {
+ if (grunt.option('color') === false) {
+ child.on('data', function (data) {
+ output.write(chalk.stripColor(data));
+ });
+ } else {
+ child.pipe(output);
+ }
+ };
+
+ grunt.verbose.writeln('Command:', chalk.yellow(cmd));
+
+ captureOutput(cp.stdout, process.stdout);
+ captureOutput(cp.stderr, process.stderr);
+
+ if (options.stdin) {
+ process.stdin.resume();
+ process.stdin.setEncoding('utf8');
+ process.stdin.pipe(cp.stdin);
+ }
+ });
+};
+
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/d5ec5557/odatajs/grunt-config/rat-config.js
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/rat-config.js b/odatajs/grunt-config/rat-config.js
new file mode 100644
index 0000000..06f5b7d
--- /dev/null
+++ b/odatajs/grunt-config/rat-config.js
@@ -0,0 +1,15 @@
+module.exports = function(grunt) {
+ grunt.config('rat', {
+ options: { xml : true, tmpDir : './build/tmp' },
+ src: {
+ dir: './src',
+ },
+ test: {
+ dir: './tests'
+ },
+ });
+
+
+ grunt.loadTasks('grunt-config/custom-tasks/rat/tasks');
+ grunt.registerTask('custom-license-check',['rat:src','rat:test']);
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/d5ec5557/odatajs/package.json
----------------------------------------------------------------------
diff --git a/odatajs/package.json b/odatajs/package.json
new file mode 100644
index 0000000..18eee26
--- /dev/null
+++ b/odatajs/package.json
@@ -0,0 +1,42 @@
+{
+ "name": "odatajs",
+ "postfix" : "beta-01",
+ "title": "Olingo OData Client for Java Script",
+ "version": "4.0.0",
+ "description": "odatajs is a new cross-browser JavaScript library that enables data-centric web applications by leveraging modern protocols such as JSON and OData and HTML5-enabled browser features. It's designed to be small, fast and easy to use.",
+ "homepage": "http://olingo.apache.org",
+ "main": "index.js",
+ "repository": {
+ "type": "git",
+ "url": "http://git-wip-us.apache.org/repos/asf/olingo-odata4-js.git"
+ },
+ "engines": {
+ "node": ">= 0.10.0"
+ },
+ "contributors": [
+ {
+ "name": "Bing Li",
+ "email": "bingl@apache.org"
+ },
+ {
+ "name": "Sven Kobler-Morris",
+ "email": "koblers@apache.org"
+ }
+ ],
+ "scripts": {},
+ "devDependencies": {
+ "browserify": "^4.1.5",
+ "grunt": "^0.4.5",
+ "grunt-browserify": "^2.1.0",
+ "grunt-connect-proxy": "^0.1.10",
+ "grunt-contrib-clean": "^0.6.0",
+ "grunt-contrib-compress": "^0.10.0",
+ "grunt-contrib-concat": "^0.5.0",
+ "grunt-contrib-connect": "^0.7.1",
+ "grunt-contrib-copy": "^0.5.0",
+ "grunt-contrib-uglify": "^0.4.0",
+ "grunt-jsdoc": "^0.5.6",
+ "grunt-node-qunit": "^2.0.2",
+ "through": "^2.3.4"
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/d5ec5557/odatajs/packages.config
----------------------------------------------------------------------
diff --git a/odatajs/packages.config b/odatajs/packages.config
new file mode 100644
index 0000000..9e7480b
--- /dev/null
+++ b/odatajs/packages.config
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Microsoft.OData.Client" version="6.5.0" targetFramework="net40" />
+ <package id="Microsoft.OData.Core" version="6.5.0" targetFramework="net40" />
+ <package id="Microsoft.OData.Edm" version="6.5.0" targetFramework="net40" />
+ <package id="Microsoft.Spatial" version="6.5.0" targetFramework="net40" />
+</packages>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/d5ec5557/odatajs/readme.md
----------------------------------------------------------------------
diff --git a/odatajs/readme.md b/odatajs/readme.md
new file mode 100644
index 0000000..bcd2560
--- /dev/null
+++ b/odatajs/readme.md
@@ -0,0 +1,20 @@
+Development
+===========
+
+Preparation
+1. npm install -g grunt-cli
+
+Installation
+1. git clone https://git-wip-us.apache.org/repos/asf/olingo-odata4-js
+1. cd datajs
+1. npm install
+
+Build datajs-x.x.x.js
+1. grunt build
+* Output is copied into the directory ...
+
+Run demo
+1. grunt run
+
+Run tests
+1. grunt test
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/d5ec5557/odatajs/src/banner.txt
----------------------------------------------------------------------
diff --git a/odatajs/src/banner.txt b/odatajs/src/banner.txt
new file mode 100644
index 0000000..edbaff2
--- /dev/null
+++ b/odatajs/src/banner.txt
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/d5ec5557/odatajs/src/index.js
----------------------------------------------------------------------
diff --git a/odatajs/src/index.js b/odatajs/src/index.js
new file mode 100644
index 0000000..fa4203d
--- /dev/null
+++ b/odatajs/src/index.js
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+var odatajs = require('./lib/datajs.js');
+
+odatajs.oData = require('./lib/odata.js');
+odatajs.store = require('./lib/store.js');
+odatajs.cache = require('./lib/cache.js');
+
+if (typeof window !== 'undefined') {
+ //expose to browsers window object
+ window.odatajs = odatajs;
+} else {
+ //expose in commonjs style
+ odatajs.node = "node";
+ module.exports = odatajs;
+}