Mehno Mehno - 1 year ago 92
PHP Question

How to create Domain on Jasper via PHP Client

My problem is:

i've got the PHP Client from the Jasper Community.
I want to add a Domain with PHP to the Jasper Repository and i've got the needed data in an .xml, like label etc.
In this PHP Client i have to use the class SemanticLayerDataSource to create a domain.
This class got a public variable schema.
But i can't find what this schema needs to work and add an correct domain to repository. There is not info neither on the webside nor in the class.

$semLayer = new SemanticLayerDataSource();
$semLayer->schema = ?????
$semLayer->label = (string)$xml->label; //SimpleXml

Which Data needs schema? An array, a resource or something else? Thank you.
Also a code sample with PHP Client would be really good, cause the documentation is not that good in this point.

Edit: I tried to create a xml as a local file a set for schema the uri of this xml. To create the xml i used this:
I am able to create a domain, but AdHoc views on this domain doesn't work. I get a null exception from jasper.

Answer Source

Well, i found the solution. If you want to create a schema per php client, create a new file object.

$file = new \Jaspersoft\Dto\Resource\File();
$file->type = "xml";
$file->label = "MyDomain_schema";
$file->content = base64_encode((string)$schemaXML);

The file content is the base64 encoded (valid) domain schema. Now set $semLayer->schema = $file. This way works rather good. Also, there is a way to create the domain via multipart request, but this way is rather complicated with php client. There is a function multipartrequest in the PHP Client, but it seems that this function consists of legacy code.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download