I am using mule to connect to a Postgres database server.
I can't use the datamapper since I am using the community edition.
The object to xml transformer is not giving a good formatted result.
Any ideas of how I can transform the jdbc response into a good format for parsing.
Here is my configuration file.
This is the datasource with the connector.
<jdbc:postgresql-data-source name="PostgreSQL_Data_Source"
user="USERNAME" password="PASSWORD"
url="jdbc:postgresql://*******:***/*****"
transactionIsolation="UNSPECIFIED" doc:name="PostgreSQL Data Source" />
<jdbc:connector name="organizations" dataSource-ref="PostgreSQL_Data_Source"
validateConnections="true" queryTimeout="-1" pollingFrequency="0"
doc:name="JDBC">
<jdbc:query key="getOrganizations" value="SELECT * FROM organization" />
<jdbc:query key="getOrganizationApplications"
value="SELECT * FROM organization o,application a,organization_apps oa WHERE o.id=oa.org_id AND a.id=oa.app_id AND o.id=#[flowVars['org_id']]" />
<jdbc:query key="insertOrganization"
value="INSERT INTO organization(name, phone, email, address, website) VALUES (?, ?, ?, ?, ?)" />
<jdbc:query key="getOrganizationUsers"
value="SELECT * FROM "public".user WHERE org_id=#[flowVars['org_id']]" />
</jdbc:connector>
and this is the flow:
<flow name="logixy-platform-organizations-workflow" doc:name="logixy-platform-organizations-workflow">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="8082" doc:name="HTTP" path="organization" />
<set-variable variableName="choice"
value="#[message.inboundProperties['choice']]" doc:name="Set Choice" />
<choice doc:name="Choice">
<when expression="#[flowVars['choice'] == '0']">
<jdbc:outbound-endpoint exchange-pattern="request-response"
queryTimeout="-1" doc:name="getAllOrganizations" connector-ref="organizations"
queryKey="getOrganizations" />
</when>
<when expression="#[flowVars['choice'] == '2']">
<set-variable variableName="org_id"
value="#[(int)(message.inboundProperties['org_id'])]" doc:name="Set Organization ID" />
<jdbc:outbound-endpoint exchange-pattern="request-response"
queryKey="getOrganizationUsers" queryTimeout="-1" connector-ref="organizations"
doc:name="getOrganizationUsers" />
</when>
<when expression="#[flowVars['choice'] == '1']">
<set-variable variableName="#['org_id']"
value="#[(int)(message.inboundProperties['org_id'])]" doc:name="Set Organization ID" />
<jdbc:outbound-endpoint exchange-pattern="request-response"
queryKey="getOrganizationApplications" queryTimeout="-1"
connector-ref="organizations" doc:name="getOrganizationApplications" />
</when>
</choice>
<mulexml:object-to-xml-transformer
doc:name="Object to XML" />
</flow>
You should really define "a good format for parsing", but I guess you don't like the "entry", "string", etc field names.
You have plenty of options to format the XML, for example:
use XSLT to transform the generated XML to your preferred format
define a class in Java or Groovy that corresponds to your return data and then either
use object-to-json and then json-to-object with your class as return class
assign the return data to objects of your class in Java or Groovy
Once you have your data as custom objects, object-to-xml-transformer will print produce a much cleaner output.
Related
I can't write to the RACP record to start the appropriate procedure on the glucose device and I don't know what's wrong:
Bluetooth powered on.
Device Contour7802H6798544 found, try to connect...
Connected to Contour7802H6798544
*******************************************************
Service: <CBService: 0x14566740, isPrimary = YES, UUID = Glucose>
<CBCharacteristic: 0x1466fdc0, UUID = 2A18, properties = 0x10, value = (null), notifying = NO>
... has notify
<CBCharacteristic: 0x1465bb00, UUID = 2A52, properties = 0x28, value = (null), notifying = NO>
... has write
*******************************************************
Characteristic's value subscribed
Subscribed. Notification has begun for: 2A18
Optional(Error Domain=CBATTErrorDomain Code=129 "Unknown ATT error." UserInfo={NSLocalizedDescription=Unknown ATT error.})
129 is 0x81 in HEX, the specification of the error message in the title can be found in the official Bluetooth docs of the Glucose Service: https://github.com/www378660084/BluetoothProfile/blob/master/GLS_SPEC_V10.pdf
I write op-code and operand to 0x2a52 as follows:
let data = Data([0x04,0x01]);
peripheral.writeValue(data , for: racp?, type: .withResponse);
And this is the specification of the characteristic:
<?xml version="1.0" encoding="utf-8"?>
<!-- Created with Liquid XML Studio Designer Edition 9.1.10.3537 (http://www.liquid-technologies.com) -->
<!--Copyright 2011 Bluetooth SIG, Inc. All rights reserved.-->
<Characteristic xsi:noNamespaceSchemaLocation="http://schemas.bluetooth.org/Documents/characteristic.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
name="Record Access Control Point"
type="org.bluetooth.characteristic.record_access_control_point"
uuid="2A52" last-modified="2011-12-6" approved="Yes">
<InformativeText>
<Summary>This control point is used with a service to provide
basic management functionality for the Glucose Sensor patient
record database. This enables functions including counting
records, transmitting records and clearing records based on
filter criterion. The filter criterion in the Operand field is
defined by the service that references this characteristic as
is the format of a record (which may be comprised of one or
more characteristics) and the sequence of transferred
records.</Summary>
</InformativeText>
<Value>
<Field name="Op Code">
<Requirement>Mandatory</Requirement>
<Format>uint8</Format>
<Enumerations>
<Enumeration key="0"
value="Reserved for future use (Operator:N/A)" />
<Enumeration key="1"
value="Report stored records (Operator: Value from Operator Table)" />
<Enumeration key="2"
value="Delete stored records (Operator: Value from Operator Table)" />
<Enumeration key="3"
value="Abort operation (Operator: Null 'value of 0x00 from Operator Table')" />
<Enumeration key="4"
value="Report number of stored records (Operator: Value from Operator Table)" />
<Enumeration key="5"
value="Number of stored records response (Operator: Null 'value of 0x00 from Operator Table')" />
<Enumeration key="6"
value="Response Code (Operator: Null 'value of 0x00 from Operator Table')" />
<ReservedForFutureUse start="7" end="255" />
</Enumerations>
</Field>
<Field name="Operator">
<Requirement>Mandatory</Requirement>
<Format>uint8</Format>
<Enumerations>
<Enumeration key="0" value="Null" />
<Enumeration key="1" value="All records" />
<Enumeration key="2" value="Less than or equal to" />
<Enumeration key="3" value="Greater than or equal to" />
<Enumeration key="4" value="Within range of (inclusive)" />
<Enumeration key="5"
value="First record(i.e. oldest record)" />
<Enumeration key="6"
value="Last record (i.e. most recent record)" />
<ReservedForFutureUse start="7" end="255" />
</Enumerations>
</Field>
<Field name="Operand">
<InformativeText>The operands correspond to the Op Code
values (Keys 0 to 255) defined in the Op Code Field
above</InformativeText>
<Requirement>Mandatory</Requirement>
<Format>variable</Format>
<Enumerations>
<InformativeText>Op Code / Operand Value
Correspondence</InformativeText>
<Enumeration key="0" value="N/A" />
<Enumeration key="1"
value="Filter parameters (as appropriate to Operator and Service)" />
<Enumeration key="2"
value="Filter parameters (as appropriate to Operator and Service)" />
<Enumeration key="3" value="Not included" />
<Enumeration key="4"
value="Filter parameters (as appropriate to Operator and Service)" />
<Enumeration key="5"
value="Number of Records (Field size defined per service)" />
<Enumeration key="6"
value="Request Op Code, Response Code Value" />
<ReservedForFutureUse start="7" end="255" />
</Enumerations>
<AdditionalValues>
<InformativeText>Response Code Values</InformativeText>
<Enumeration key="0" value="Reserved For Future Use"
description="N/A" />
<Enumeration key="1" value="Success"
description="Normal response for successful operation" />
<Enumeration key="2" value="Op Code not supported"
description="Normal response if unsupported Op Code is received" />
<Enumeration key="3" value="Invalid Operator"
description="Normal response if Operator received does not meet the requirements of the service (e.g. Null was expected)" />
<Enumeration key="4" value="Operator not supported"
description="Normal response if unsupported Operator is received" />
<Enumeration key="5" value="Invalid Operand"
description="Normal response if Operand received does not meet the requirements of the service" />
<Enumeration key="6" value="No records found"
description="Normal response if request to report stored records or request to delete stored records resulted in no records meeting criteria." />
<Enumeration key="7" value="Abort unsuccessful"
description="Normal response if request for Abort cannot be completed" />
<Enumeration key="8" value="Procedure not completed"
description="Normal response if unable to complete a procedure for any reason" />
<Enumeration key="9" value="Operand not supported"
description="Normal response if unsupported Operand is received" />
<ReservedForFutureUse start="10" end="255" />
</AdditionalValues>
</Field>
</Value>
<Note>The fields in the above table are in the order of LSO to
MSO. Where LSO = Least Significant Octet and MSO = Most
Significant Octet.</Note>
</Characteristic>
0x04 0x01 means I want to get the total number of stores records.
But I get always the error message mentioned above.
I used to have the same issue, but after checking the spec I found this:
Ensure that the client configures RACAP Charac for indication
by writing "0x0200" on the Client configuration descriptor related to RACAP
From section 3.4 of the specification.
A little snippet of a database schema I'm trying to define in my "schema.xml" file:
<table name="hotelroom" phpName="hotelroom">
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
<column name="room_number" type="varchar" size="10" required="true" />
<column name="price" type="numeric" defaultValue="1000" required="true" />
<unique>
<unique-column name="room_number" />
</unique>
</table>
In PostgreSQL for that "price" column I would've written CHECK (price > 0::numeric),but I can't seem to find any way to achieve this here.I've checked the documentation (http://propelorm.org/documentation/reference/schema.html), but couldn't find anything on this.
Thank you for the time.
You're using v1, but from the doc link above, looks like you're using v2,
I think you're looking for the GreaterThan which is only available from v2 onwards.
<behavior name="validate">
<parameter name="rule1" value="{column: price, validator: GreaterThan, options: {value: 0, message=Price is not valid}}" />
</behavior>
Created a WCF Data Service to pull data from Oracle database and when debugging in VS I can use the ?$filter syntax to filter returned sets.
However, using the remote url I cannot.
Point to note: I can filter by integers and dates, however I cannot filter by strings.
Also, I cannot filter by any string field in code. The filter is ignored.
Sample item below:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed xml:base="http://localhost:61905/CampaignerSVC.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
<title type="text">Contacts</title>
<id>http://localhost:61905/CampaignerSVC.svc/Contacts</id>
<updated>2015-04-29T15:06:48Z</updated>
<link rel="self" title="Contacts" href="Contacts" />
<entry>
<id>http://localhost:61905/CampaignerSVC.svc/Contacts(23517014)</id>
<title type="text"></title>
<updated>2015-04-29T15:06:48Z</updated>
<author>
<name />
</author>
<link rel="edit" title="ContactList" href="Contacts(23517014)" />
<category term="Campaigner_DAL_WCF.ContactList" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:LicenseNumber m:type="Edm.Int32">23517014</d:LicenseNumber>
<d:ClientCode>2000</d:ClientCode>
<d:ClientName>Doodler</d:ClientName>
<d:ClientMnemonic>DD</d:ClientMnemonic>
<d:LastName>Kerr</d:LastName>
<d:FirstName>Rover</d:FirstName>
<d:MiddleName>Frank</d:MiddleName>
<d:Title>Mr.</d:Title>
<d:PreferredFirstName>Rover</d:PreferredFirstName>
<d:PreferredMiddleName>Frank</d:PreferredMiddleName>
<d:CompanyName m:null="true" />
<d:JobTitle m:null="true" />
<d:Gender>M</d:Gender>
<d:DateOfBirth m:type="Edm.DateTime">1947-04-27T00:00:00</d:DateOfBirth>
<d:PrimaryChapterCode m:type="Edm.Int16">400</d:PrimaryChapterCode>
<d:AlternateChapterCode m:type="Edm.Int16" m:null="true" />
<d:MainAddrStreetNo>121</d:MainAddrStreetNo>
<d:MainAddrLine1>So Crescent</d:MainAddrLine1>
<d:MainAddrLine2 m:null="true" />
<d:MainAddrLine3 m:null="true" />
<d:MainAddrCity>MAICK</d:MainAddrCity>
<d:MainAddrProvCode>ON</d:MainAddrProvCode>
<d:MainAddrProv>Ontario</d:MainAddrProv>
<d:MainAddrPostalCode>KB7</d:MainAddrPostalCode>
<d:MainAddrCountryCode>CA</d:MainAddrCountryCode>
<d:MainAddrCountry>Canada</d:MainAddrCountry>
<d:MainPhoneNum>610-000-0703</d:MainPhoneNum>
<d:MainPhoneExt m:null="true" />
<d:MainFaxNum m:null="true" />
<d:MainEmailAddr>someone#rogers.com</d:MainEmailAddr>
<d:CellPhoneNum m:null="true" />
<d:ChangeType>D</d:ChangeType>
<d:EventTimeStamp m:type="Edm.DateTime">2015-04-29T02:40:02</d:EventTimeStamp>
<d:PrivacyIndicator>N</d:PrivacyIndicator>
</m:properties>
</content>
</entry>
</feed>
You can filter by string also by using the string in quotes like below-
'string'
Ok, so the issue was that I had created a class to store the results from the entity model.
Although I had a DataKey value specified, the problem was that the field I specified was not unique, therefore the filters were being ignore (or only the first matching record was filtered).
What I had to do was decorate the class with a composite DataKey.
I have created a custom type in orchard cms, that has a two column lay out
It has 2 header text fileds and 2 content HTML flavour fileds
Heres the migration :
public class MigrationTwoColumnPageType : DataMigrationImpl
{
public int Create()
{
// Define the project type
ContentDefinitionManager.AlterTypeDefinition("TwoColumnPage", cfg => cfg
.WithSetting("Stereotype", "Content")
.CommomPart()
.AutoroutePart()
.WithPart("TitlePart")
.WithPart("MenuPart")
.WithPart("TagsPart")
.WithPart("PublishLaterPart")
.WithPart("TwoColumnPage")
.Creatable()
.Draftable());
return 1;
}
public int UpdateFrom1()
{
// Define project part - having a part with the same name will create fields in the project type
ContentDefinitionManager.AlterPartDefinition("TwoColumnPage", builder => builder
.TextField("Column1Title", Flavour.Large)
.TextField("Column1Text", Flavour.Html)
.TextField("Column2Title", Flavour.Large)
.TextField("Column2Text", Flavour.Html)
.Attachable());
return 2;
}
}
NOTE: TextField is a custom extension method to make things less verbose
When I try and use the media picker to up load an image into one of these content fields I get a folder not found error, - I have traced this back to the media path on the Request querystring not being set
// media directory to save uploaded files into
var mediaPath = Request["uploadpath"];
in ../../Orchard.MediaPicker/Views/admin/Tab_Url.cshtml
Is there some way to set this using filed settings ?
Seems to work fine for any pages I create, but custom types .... how do I set this value ?
UPDATE
Heres the xml meta data for a page...
<!--Exported from Orchard-->
<Orchard>
<Recipe>
<Name>Generated by Orchard.ImportExport</Name>
<Author>admin</Author>
</Recipe>
<Metadata>
<Types>
<Page ContentTypeSettings.Creatable="True" ContentTypeSettings.Draftable="True" TypeIndexing.Included="true" DisplayName="Page">
<NavigationPart />
<CommonPart DateEditorSettings.ShowDateEditor="true" />
<PublishLaterPart />
<TitlePart />
<AutoroutePart AutorouteSettings.AllowCustomPattern="true" AutorouteSettings.AutomaticAdjustmentOnEdit="false" AutorouteSettings.PatternDefinitions="[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-page'}]" AutorouteSettings.DefaultPatternIndex="0" />
<BodyPart />
<TagsPart />
<LocalizationPart />
</Page>
</Types>
<Parts>
<NavigationPart ContentPartSettings.Attachable="True" />
<CommonPart ContentPartSettings.Attachable="True" />
<PublishLaterPart ContentPartSettings.Attachable="True" />
<TitlePart ContentPartSettings.Attachable="True" />
<AutoroutePart ContentPartSettings.Attachable="True" />
<BodyPart ContentPartSettings.Attachable="True" BodyPartSettings.FlavorDefault="html" />
<TagsPart ContentPartSettings.Attachable="True" />
<LocalizationPart />
</Parts>
</Metadata>
</Orchard>
Here's the XML meta for my custom type, using TestFiledSetting instead of BodyPartSetting
<!--Exported from Orchard-->
<Orchard>
<Recipe>
<Name>Generated by Orchard.ImportExport</Name>
<Author>admin</Author>
</Recipe>
<Metadata>
<Types>
<TwoColumnPage Stereotype="Content" OwnerEditorSettings.ShowOwnerEditor="false" ContentTypeSettings.Creatable="True" ContentTypeSettings.Draftable="True" DisplayName="Two Column Page">
<CommonPart />
<AutoroutePart AutorouteSettings.PatternDefinitions="[{Name:'/Title', Pattern: '/{Content.Slug}', Description: 'my-page'}]" />
<TitlePart />
<MenuPart />
<TagsPart />
<PublishLaterPart />
<TwoColumnPage />
</TwoColumnPage>
</Types>
<Parts>
<CommonPart ContentPartSettings.Attachable="True" />
<AutoroutePart ContentPartSettings.Attachable="True" />
<TitlePart ContentPartSettings.Attachable="True" />
<MenuPart ContentPartSettings.Attachable="True" />
<TagsPart ContentPartSettings.Attachable="True" />
<PublishLaterPart ContentPartSettings.Attachable="True" />
<TwoColumnPage ContentPartSettings.Attachable="True">
<Column1Title.TextField TextFieldSettings.Required="True" TextFieldSettings.Flavor="Large" TextFieldSettings.Hint="" />
<Column1Text.TextField TextFieldSettings.Required="True" TextFieldSettings.Flavor="Html" TextFieldSettings.Hint="" />
<Column2Title.TextField TextFieldSettings.Required="True" TextFieldSettings.Flavor="Large" TextFieldSettings.Hint="" />
<Column2Text.TextField TextFieldSettings.Required="True" TextFieldSettings.Flavor="Html" TextFieldSettings.Hint="" />
</TwoColumnPage>
</Parts>
</Metadata>
</Orchard>
No mention of data-mediapicker-uploadpath in either. I'm still lost!
I am getting the following response from server:
<?xml version="1.0" encoding="UTF-8"?>
<tracks type="array">
<track>
<id type="integer">13082503</id>
<created-at type="datetime">2011-04-05T05:48:05Z</created-at>
<user-id type="integer">2796383</user-id>
<duration type="integer">6715</duration>
<commentable type="boolean">true</commentable>
<state>finished</state>
<sharing>public</sharing>
<tag-list />
<permalink>myfirstsong-tutorial1-6</permalink>
<description nil="true" />
<streamable type="boolean">true</streamable>
<downloadable type="boolean">false</downloadable>
<genre nil="true" />
<release nil="true" />
<purchase-url nil="true" />
<label-id nil="true" />
<label-name nil="true" />
<isrc nil="true" />
<video-url nil="true" />
<track-type nil="true" />
<key-signature nil="true" />
<bpm nil="true" />
<title>MyFirstSong-Tutorial1</title>
<release-year nil="true" />
<release-month nil="true" />
<release-day nil="true" />
<original-format>m4a</original-format>
<license>all-rights-reserved</license>
<uri>http://api.soundcloud.com/tracks/13082503</uri>
<permalink-url>http://soundcloud.com/sleuth007/myfirstsong-tutorial1-6</permalink-url>
<artwork-url nil="true" />
<waveform-url>http://w1.sndcdn.com/8MqNbtkeyhNZ_m.png</waveform-url>
<user>
<id type="integer">2796383</id>
<permalink>sleuth007</permalink>
<username>sleuth007</username>
<uri>http://api.soundcloud.com/users/2796383</uri>
<permalink-url>http://soundcloud.com/sleuth007</permalink-url>
<avatar-url>http://a1.sndcdn.com/images/default_avatar_large.png?5fb6c47</avatar-url>
</user>
<stream-url>http://api.soundcloud.com/tracks/13082503/stream</stream-url>
<downloads-remaining type="integer">100</downloads-remaining>
<secret-token>s-5vz60</secret-token>
<secret-uri>http://api.soundcloud.com/tracks/13082503?secret_token=s-5vz60</secret-uri>
<user-playback-count type="integer">1</user-playback-count>
<user-favorite type="boolean">false</user-favorite>
<playback-count type="integer">0</playback-count>
<download-count type="integer">0</download-count>
<favoritings-count type="integer">0</favoritings-count>
<comment-count type="integer">0</comment-count>
<created-with>
<id type="integer">61</id>
<name>Cocoa API Wrapper Test</name>
<uri>http://api.soundcloud.com/apps/61</uri>
<permalink-url>http://soundcloud.com/apps/cocoa-api-wrapper-test</permalink-url>
</created-with>
<attachments-uri>http://api.soundcloud.com/tracks/13082503/attachments</attachments-uri>
</track>
</tracks>
Do I have to do XML parsing for this or is there any other way to save this as array
You will have to use NSXMLParser for parsing the xml file. "type=array" is XML attribute and not an array.