FAQ Database Discussion Community

Datamapper not saving ID, LocalJumpError - no block given

I recently refactored my DataMapper code, slowly rolling it out, and got it working on one database, but now I'm encountering problems when rolling it out to my expense database. Couldn't find the answer anywhere, and I've tried lots of fiddling. I have a form (using Sinatra) that takes several...

validate fields in datamapper (CSV to JSON).

Converting from CSV to JSON using mule datamapper. I want to check if required field is empty. If empty log that field and discard it for further processing. I know in script option we have if(input.data.length >0).' But how to discard the whole row if this fails??...

Mule Datamapper JSON to XML Transformation

JSON Input Payload information, Where i have issue with. { "name": "xyz", "city": "california", "serialNumber": [ "T2323" , "T2332" ] } Expected transformed Output Payload : <COMPANY_ITEM_INFO> <COMPANY_NAME>xyz</COMPANY_NAME> <COMPANY_CITY>california</COMPANY_NAME> <Inv_Update SEGMENT="1"> <SERIALNO>T2323</SERIALNO> </Inv_Update SEGMENT="1"> <Inv_Update SEGMENT="1"> <SERIALNO>T2332</SERIALNO> </Inv_Update SEGMENT="1"> </COMPANY_ITEM_INFO> Actual Output...

Can't use conditions on symbols. DataMapper with Sinatra

I'm getting troubles when trying to use conditions on symbols in DataMapper: clusters = Cluster.all(:latitude.not => nil) This code throws an error: ArgumentError - condition #<Origin::Key:0x50d05a0 @name=:latitude, @strategy=:__override__, @operator="$not", @expanded=nil, @block= nil> of an unsupported object Origin::Key: C:/Ruby21/lib/ruby/gems/2.1.0/gems/dm-core-1.2.1/lib/dm-core/query.rb:888:in `block in assert_valid_conditions' C:/Ruby21/lib/ruby/gems/2.1.0/gems/dm-core-1.2.1/lib/dm-core/query.rb:853:in `each'...

How to use flowvariable in a Mule Query

I am trying to use a query with flowvariable in the where clause in Mule ESB (Connecting with Salesforce) SELECT id FROM Account WHERE CX_ID__c = '"flowvars.orgpayload.CXM_ID+"' LIMIT 1 But I am not getting an error here. Any pointers on how to use flow variable in a query would help....

Using PHP's ArrayObject to implement a collection of model objects

I am developing a "fat model" for my open-source project, and I am working on the layer that will sit between the ORM (RedBeanPHP) and the controller. I will have a User class, and probably a UserFactory/UserMapper class that can construct User objects, as well as perform meta-actions like usernameExists,...

How to save data from Mapper to Entity using Left Joined data in PHP

I have simple custom made Entity and Mapper class. Mapper is used to get data from Database, and Entity is a collection object with variables, getter/setter methods and relationships between Entities. Model\Entity\Category class Category extends Entity { private $id, $name, $link; // belongs to private $category; // has many private...

Using Sinatra and DataMapper, are classes one and the same?

When declaring classes in a sinatra app for data mapper, I understand it would look something like this: class Thing include DataMapper::Resource property :id, Serial property :name, String property :num, Integer end And if this wasn't a web app, but just desktop ruby program, you might do something like this:...

Mule - Date format from m/dd/yy to yyyy-mm-dd

want to convert date to the above required format. Is it possible to write a groovy script to do so in datamapper? If yes can you please give an example. Or can i reference another expression or component?

Data Transformation in Mule ESB

My Mule flow query a Database and inserts the data queried in Salesforce. One of the column in DB has values say 'C','P'&'U' this needs to be inserted into a picklist in Salesforce which has values 'Company', 'Person', 'Unknown' where C should map to Company and P to Person etc....

DataMapper Self Referential Model

I have a model: class Comment include DataMapper::Resource property :id, Serial property :comment, Text, :required => true belongs_to :user belongs_to :lecture has n, :replies, :child_key => [:source_id] has n, :comments, self, :through => :replies, :via => :target end And I want to add a comment as a reply to another,...