Using Javascript to read metadata from .bqy (Brio query file) file - javascript

I have some .bqy (Brio query file) files I need to loop through them and read the metadata which is the OCE (database connection strings) and write them to an excel file.

Unfortunately, a bqy doesn't know the information contained in the oce. It pretty much only knows what's in the Connection Manager tool (thing you get when you press F11), even if that information is wrong and won't connect.
The official Oracle documentation says the data you're seeking might be in the bqmeta0.ini file, if it's provided by a third party vendor:
https://docs.oracle.com/cd/E17236_01/epm.1112/ir_user/ch36s09s01.html
There are a lot of read only Properties under the DataModel object, which might be useful:
https://docs.oracle.com/cd/E17236_01/epm.1112/ir_user/ch30s18.html
https://docs.oracle.com/cd/E17236_01/epm.1112/ir_user/ch30s17.html

Desktop Hyperion - Create a BQY and use For loops to open each bqy then loop thru the object model. You can write output to excel or access. Something like this
// Request Loop
for (var z = 1; z <= ActiveDocument.Sections[j].Requests.Count; z++) {
// get_data
}

Related

Get value from txt file only when it is updated in Javascript [duplicate]

I have the following UseCase:
A creates a Chat and invites B and C - On the Server A creates a
File. A, B and C writes messages into this file. A, B and C read this
file.
I want a to create a file on server and observe this file if anybody else writes something into this file send the new content back with websockets.
So, any change of this file should be observed by my node.js application.
How can I observe files-changes? Is this possible with node js without locking the files?
If not possible with files, would it be possible with database object (NoSQL)
Good news is that you can observe filechanges with Node's API.
This however doesn't give you access to the contents that has been written into the file.
You can maybe use the fs.appendFile(); function so that when something is being written into the file you emit an event to something else that "logs" your new data that is being written.
fs.watch(): Directly pasted from the docs
fs.watch('somedir', function (event, filename) {
console.log('event is: ' + event);
if (filename) {
console.log('filename provided: ' + filename);
} else {
console.log('filename not provided');
}
});
Read here about the fs.watch(); function
EDIT: You can use the function
fs.watchFile();
Read here about the fs.watchFile(); function
This will allow you to watch a file for changes. Ie. whenever it is accessed by some other processes of any kind.
Also you could use node-watch. Here's an easy example:
const watch = require('node-watch')
watch('README.md', function(event, filename) {
console.log(filename, ' changed.')
})
I do not think you need to have observe file changes or use a NoSQL database for this (if you do not want to). My advice would be to look at events(Observer pattern). There are more than enough tutorials on this topic available online (Google). For example Felix's article about Using EventEmitters
This publish/subcribe semantic can also be achieved with NoSQL. In Redis for example, I think you should have a look at pubsub.
In MongoDB I think tailable cursors is what you are looking for. On their blog they have a post explaining pub/sub.

How to query JSON with JS API to return JSON properties?

Apologies if this seems basic to some, but I'm new to JS/node.js/JSON and still finding my way. I've searched this forum for an hour but cannot find a specific solution.
I have a basic website setup running of a local Node.js server along with 2x JSON data files with information about 32x local suburbs.
An example of an API GET request URL on the site would be:
.../api/b?field=HECTARES
The structure of the JSON files are like:
JSON Structure
In the JSON file there are 32x Features (suburbs), each with it's own list of Properties as shown above. What I am trying to do is use the API 'field' query to push all the HECTARES values each of the 32x Features into a single output variable. The code below is an example of how far I have got:
var fieldStats = [];
var fieldQ = req.query['field'];
for (i in suburbs.features) {
x = suburbs.features[i].properties.HECTARES;
fieldStats.push(x);
}
As you can see in the above "HECTARES" is hard-coded - I need to be able to pass the 'fieldQ' variable to this code but have no idea how to.
Advice appreciated!
Exactly the same syntax you are using just above:
suburbs.features[i].properties[fieldQ];

Can you retrieve the Collection Event Script in Deployd as a string for documentation?

I have been using Deployd for a week or so, and was curious if I could expose the contents of the Collections Event Script itself, from the API. (the contents of the /my-project/resources/my-collection/get.js file itself)
This could be useful to automatically produce documentation of the scripts being applied to Get, Post and other requests.
Thanks for the help,
Jacob
This is what I have so far: If I start at localhost:2404/dashboard , I can run the following code in the Chrome Console to retrieve the string content of the GET Event on the collection Tshirts:
dpd('__resources').get(Context.resourceId + '/' + 'get.js', function(res, err)
{
_events['get'] = res && res.value;
console.log(res.value);
});
Context.resourceId simplifies to the collection ID which is just "tshirts".
This successfully outputs the data I am trying to access, but I wonder if it is possible to retrieve from the API. I imagine I need to dig into Node.JS in general to wrap my head around this.
Thanks again,
Jacob

Node.js / Awssum for S3

Hi there: I'm wondering if anyone knows a method for listing all files inside of an S3 bucket with node.js and Awssum, starting with the most recent file first.
By default, my code takes the first created file.
function getFileList(callback){
s3.ListObjects(coldBucket, function(err, data) {
var fileList = getFilenames(data, coldBucketPath);
callback(fileList);
});
};
Any help is much appreciated! Thanks.
this is Andy, creator of AwsSum.
That's correct, there is no way of asking S3 for the filenames in order of inserted time. However, you can get it using the LastModified.
If you'd like to see an example to get all the keys, see this example here:
https://github.com/appsattic/node-awssum-scripts/blob/master/bin/amazon-s3-list.js
You could then store each item in an array, then sort it using LastModified. The underscore library contains a function that would be useful for this:
http://documentcloud.github.com/underscore/#sortBy
I looking at http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketGET.html, I don't believe s3 allows you to specify the sort order of the response.
However, you may be able to work around that by changing your file structure to include folders named after the date they were created, then you could do a couple of ListObjects requests with prefixes for recent days/months/etc.
For example, you could have year-month folder names so your file structure looks like this:
bucket_name/
- 2012-3/
- file2.jpg
- file3.jpg
- 2012-2/
- file1.jpg
and then before you make your request, do this
var now = new Date();
coldBucket.Prefix = now.getFullYear() + "-" + now.getMonth();
And then if you wanted older stuff you'd have to do a followup request for previous months.
(If you have too many files even for that, you could try year-month-day)

Local HTML 5 database usable in Mac Dashboard wigdets?

I'm trying to use HTML 5's local database feature on a Mac Dashboard widget.
I'm programming in Dashcode the following javascript:
if (window.openDatabase)
{
database = openDatabase("MyDB", "1.0", "Sample DB", 1000);
if (database)
{
...database code here...
}
}
Unfortunately the database-variable remains always null after the call to openDatabase-method. I'm starting to think that local databases are not supported in Widgets...
Any ideas?
/pom
No you will not be able to do the above. And even if you could then you would not be able to distribute the widget without distributing the database assuming it was a MySQL or SGLite. (not sure what you mean by HTML 5's local Db.
here are a number of ways round this:-
You can add a data source which can be a JSON file, or an XML file or and RSS feed. So to do this with JSON for example you would write a page on a server in PHP or something that accessed a database so that when the URL was called the result was a JSON string. Take the JSON string and parse it and use it in the Widget. This will let you get data but not save it.
Another way would be to use the user preferences. This allows you to save and retrieve data in the individual widget.
So
var preferenceKey = "key"; // replace with the key for a preference
var preferenceValue = "value"; // replace with a preference to save
// Preference code
widget.setPreferenceForKey(preferenceValue, preferenceKey);
You can then retrieve it with
var preferenceForKey = "key"; // replace with the key for a preference
// Preference code
preferenceForKey = widget.preferenceForKey(preferenceForKey);
The external call, you could also use REST will let you read any amount of data in and the preferences will let you save data for later reuse that will survive log out's and shut downs.
The Apple site has a lot of information about Widgets and tutorials as well thjat are worth working through.
Hope this helps.

Categories