Can I do a reverse engineering on a PowerDesigner using JSON schema and not XML? - powerdesigner

I tried doing in but I get a blank project in return.
When I select a DBMS to be JSON, thats when I get a blank.
I dont know if theres another way around it?

It does not directly answer the question, but here is an example of scripting PowerDesigner from JavaScript (tested with NodeJS 14, NPM 7). You can then parse your JSON with JavaScript, and create objects (entities, tables...) on the fly through Automation.
"use strict";
// you can get these constants with a VBScript like this:
// option explicit
// dim lib,libname,cls,keep,x
// for each lib in application.metamodel.libraries
// libname = lcase(lib.publicname)
// if left(libname,2) = "pd" then libname = mid(libname,3)
// for each cls in lib.classes
// keep = cls.inheritsfrom(cls_NamedObject)
// if keep and cls.inheritsfrom(cls_BaseClassifierMapping) then keep = false
// if keep and cls.abstract then keep = false
// if keep and ((cls.flags and 1024) <> 0) then keep = false
// if keep then
// x = right("00000000" & hex(cls.kind), 8)
// output "const cls_"&libname&cls.publicname & " = 0x" & x & ";"
// end if
// next
// next
const cls_cdmModel = 0x1E597170;
const cls_cdmEntity = 0x1E597172;
console.log("... connecting");
let winax = require('winax');
let app = new ActiveXObject("PowerDesigner.Application");
console.log("... create model");
let model = app.CreateModel(cls_cdmModel);
let entt = model.CreateObject(cls_cdmEntity);
entt.Name = 'foo';
console.log("... save model");
model.Save('c:\\temp\\foo.cdm');
winax.release(model,entt);
// close Workspace without saving
app.ActiveWorkspace.Close(1);
winax.release(app);
console.log("... happily done");

Related

How to convert hashSet<String> to arrayListOf?

Using shared preferences to save an arrayListOf in my app. Im converting the array to a hashset and saving it but when I load it I am unable to convert it back to an arrayListOf. I have tried toTypedArray() and toArray() but neither solve the problem. Getting the error below.
Required:
kotlin.collections.ArrayList /* = java.util.ArrayList */
Found:
(Mutable)Set<String!>?
Using the following to try and load the hashet and convert it.
var sharedPreferences = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE)
var places = arrayListOf<String>()
var loadSet = sharedPreferences.getStringSet("key", null)
places = loadSet
go.setOnClickListener{
thread {
val place = newLocation.text.toString()
var stringCounter = counter.toString()
if(place !in places){
places.add(place)
//editor.putStringSet("key", places)
//editor.commit()
var sharedPreferences = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE)
var editor = sharedPreferences.edit()
set.add(place)
editor.putStringSet("key", set);
editor.commit();
Log.d("set", set.toString())
var loadSet = sharedPreferences.getStringSet("key", HashSet<String>())?.toList()
Log.d("load", loadSet.toString())
places = loadSet as ArrayList<String>
}
arrayListOf isn’t a type. It’s a function. The type is ArrayList, but it’s more typical to only need the more abstract List or MutableList, depending on what you’re doing with it. For those you can use set.toList() or set.toMutableList().
If you have an existing ArrayList or MutableList, you could also do list.addAll(set).

image array and .src - image not changing

I have created an array which is being used to store a series of .gif images and I'm just trying to test everything out by using document.getElementById to change the .src value but when I change it and load the page the image stays the same as it was before.
function setImage()
{
var images = new Array();
images[0] = anemone.gif;
images[1] = ball.gif;
images[2] = crab.gif;
images[3] = fish2.gif;
images[4] = gull.gif;
images[5] = jellyfish.gif;
images[6] = moon.gif;
images[7] = sail.gif;
images[8] = shell.gif;
images[9] = snail.gif;
images[10] = sun.gif;
images[11] = sunnies.gif;
images[12] = whale.gif;
var slots = new Array();
slots[0] = document.getElementById("slot" + 0);
slots[1] = document.getElementById("slot" + 1);
slots[2] = document.getElementById("slot" + 2);
slots[0].src = "snail.gif";
document.getElementById('slot0').src = images[0];
alert(images.length);
}
I can't understand why the image wont change, but I know it has to be something very simple. I've been wasting hours trying to get this one thing to change but nothing works. can anyone please point out the error of my ways?
There are a couple of issues with your code:
Your filenames need to be Strings, so they'll have to be quoted (also you can simplify the Array creation):
var images = ['anemone.gif', 'ball.gif', 'crab.gif', 'fish2.gif', 'gull.gif', 'jellyfish.gif', 'moon.gif', 'sail.gif', 'shell.gif', 'snail.gif', 'sun.gif', 'sunnies.gif', 'whale.gif'];
Also make sure you are getting your slot-elements right, quote all the attributes like:
<img id="slot0" class="slot" src="crab.gif" width="120" height="80">
When you create the slots-Array you can do it like this (no need to concat the ID string):
var slots = [document.getElementById('slot0'), document.getElementById('slot1'), document.getElementById('slot2')];
Finally make sure you call your function when the document has loaded / the DOM is ready. If you don't want to use a framework like jQuery your easiest bet is probably still using window.onload:
window.onload = setImage; //note that the parens are missing as you want to refer to the function instead of executing it
Further reading on Arrays, window.onload and DOMReady:
https://developer.mozilla.org/de/docs/DOM/window.onload
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array
javascript domready?

Trying To Prevent Repost Data on refresh

working with pre existing code just a simple patch i added ontop
//first get the variables
bridge = namef & valuef
//a paranoid double check
if session("gap") = session("oldgap") then session("gap") = "null"
//the actual comparison
if bridge = session("gap") then
drawbridge = ""
else
drawbridge = inputscrubber("action")
end if
session("oldgap") = session ("gap")
session("gap") = namef & valuef
You should use the PRG (Post/Redirect/Get) pattern to avoid such issues.
The idea is that once the form is posted, you process it and redirect to a different page. The user at this point can refresh without any issue.

Make second connection to external DB

I use classic connecion, which created in bootstap by read parameters from application.ini file. I would like use more external DBs, but I can´t read them from application.ini. I prefer read parameters from main DB (which external DB it is, depend on website). So how effectivelly make connection in model? Now I set that connection every time when I need use it. And when I need use main DB, is neccessary make connection again. It´s very uneffective solution.
function joinClientDB($id)
{
$web = $this->getById($id);
$dbSettings = array();
$dbSettings['host'] = $web['web_dbHost'];
$dbSettings['username'] = $web['web_dbUsername'];
$dbSettings['password'] = $web['web_dbPassword'];
$dbSettings['dbname'] = $web['web_dbName'];
$this->_db = Zend_Db::factory('pdo_mysql', $dbSettings);
$this->_db->query('SET CHARACTER SET ' . $web['web_dbCharset']);
}
function joinDefaultDb()
{
$this->_db = Zend_Registry::get('db');
}
Has anybody easy solution for me?
I would suggest to use the Zend MULTI DB Plugin. Add to your applications.ini all database connections:
; Database ONE
resources.multidb.test.adapter =
resources.multidb.test.dbname =
resources.multidb.test.username =
resources.multidb.test.password = ""
resources.multidb.test.host = "your.local.host"
resources.multidb.test.default = true
; Database TWO
resources.multidb.live.adapter =
resources.multidb.live.dbname =
resources.multidb.live.username =
resources.multidb.live.password = ""
resources.multidb.live.host = "your.live.host.com"
And now you could put them in your registry again (bootstrap.php):
protected function _initDbAdapters()
{
$this->bootstrap('multidb');
$resource = $this->getPluginResource('multidb');
$resource>init();
$testDB = $resource->getDb('test');
$liveDB = $resource->getDb('live');
Zend_Registry::set('DB_TEST', $testDB);
Zend_Registry::set('DB_LIVE', $liveDB);
}

Finding New and Updated Pages in EpiServer

I have a requirement to display lists of newly-created and updated pages in our Episerver intranet - say the last ten of each. I've tried using FindPagesWithCriteria but this returns no results. Here's the code I've tried:
PageDataCollection recentPages;
PropertyCriteriaCollection criteria;
PropertyCriteria upperBound;
PropertyCriteria lowerBound;
criteria = new PropertyCriteriaCollection();
upperBound = new PropertyCriteria();
upperBound.Condition = CompareCondition.LessThan;
upperBound.Type = PropertyDataType.Date;
upperBound.Value = DateTime.Today.ToString();
upperBound.Name = "Created"; // Or Saved for updated pages
criteria.Add(upperBound);
lowerBound = new PropertyCriteria();
lowerBound.Condition = CompareCondition.GreaterThan;
lowerBound.Type = PropertyDataType.Date;
lowerBound.Value = DateTime.Today.AddDays(-7).ToString();
lowerBound.Name = "Created";
criteria.Add(lowerBound);
recentPages = DataFactory.Instance.FindPagesWithCriteria(PageReference.StartPage, criteria);
I've also tried using the RecentlyChangedPagesFinder (as detailed here) - this returns some results, but when I try to use the set of results to build a PageCollection to databind into a PageList, again I get nothing output. And I can't see that I could use that for new pages, only updated ones.
The property name should be "PageCreated".
http://epiwiki.se/developing/properties/all-built-in-properties
You can also improve your FindPagesWithCriteria-syntax by going something like this:
var criterias = new PropertyCriteriaCollection
{
new PropertyCriteria()
{
Name = "SomeProp",
Type = PropertyDataType.PageType,
Value = "eh",
Condition = CompareCondition.Equal,
Required = true
},
new PropertyCriteria()
{
...
};
var pages = DataFactory.Instance.FindPagesWithCriteria(somePageLink, criterias);

Resources