Create abstract complexType as an input to an operation for webservice argument class - Coldfusion - coldfusion-9

I ran into the error:
Unable to create web service argument class [Lcom.verticalresponse.api._1_0.VRAPI_xsd.NVPair;. Error: java.lang.InstantiationException: [Lcom.verticalresponse.api._1_0.VRAPI_xsd.NVPair;. Often this is because the web service defines an abstract complexType as an input to an operation. You must create an actual instance of this type in Java.
while trying to call a WebService. And I have the solution now and I want to post it for anyone else who might be in my situation one day. The issue is that you have to pass a complex structure through coldfusion to the webservice and it doesn't always like to play well.
The answer to this conundrum is how you set up the data as a combination of structures and arrays.
you have to build the data in a very particular manner.
<cfscript>
var ELMResults = StructNew();
var ELMArgs = StructNew();
var MemberData = arrayNew(1);
var ListMember = StructNew();
var session_id = 'the_session_id_provided'
var list_id = 'the_list_id_provided';
var list_name = 'the_list_name_provided';
var list_type = 'the_list_type_provided';
/* set session id */
ELMArgs.session_id = session_id;
/* set member data */
MemberData[1] = StructNew();
MemberData[1].name = "hash";
MemberData[1].value = hash_value;
MemberData[2] = StructNew();
MemberData[2].name = "optin_status";
MemberData[2].value = "2";
MemberData[3] = StructNew();
MemberData[3].name = "first_name";
MemberData[3].value = "Chewbacca";
MemberData[4] = StructNew();
MemberData[4].name = "fax";
MemberData[4].value = "1112223333";
MemberData[5] = StructNew();
MemberData[5].name = "email_address";
MemberData[5].value = email_address;
/* set list member details */
ListMember.list_id = list_id;
ListMember.list_name = list_name;
ListMember.list_type = list_type;
ListMember.member_data = MemberData;
ELMArgs.list_member = ListMember;
ELMResults = VR.editListMember(ELMArgs);
</cfscript>
I hope this helps someone because I was scratching my head for a while.

I found the solution to my own question and posted it here with the question because I couldn't post an answer on the same day of asking the question. I am now simply closing out the thread. I hope this answer helps someone because I was scratching my head for a while with this one.
Cheers, JP

Related

How to run normally query script in entity framework mvc c#

I have face problem about entity framework in mcv c#,
i decide to change the way to exec query to normally query scripting,
this bellow script I have for exemple
//for only one row result
string activeUser = await db.Users.Where(x => x.Token.Equals(token)).Select(x => x.Username).FirstOrDefaultAsync();
ReceivingSFG receiving = await db.ReceivingSFGs.Where(s => s.ID.Equals(receivingVM.ID)).FirstOrDefaultAsync();
//for multiple row result (List)
IQueryable<ReceivingSFGDetail> query = db.ReceivingSFGDetails.Where(s => s.ReceivingID.Equals(req.ID)).AsQueryable();
IEnumerable<ReceivingSFGDetail> list = Enumerable.Empty<ReceivingSFGDetail>();
list = query.ToList();
IEnumerable<ReceivingSFGDetailDTO> listDto = Enumerable.Empty<ReceivingSFGDetailDTO>();
string message = "";
bool status = false;
listDto = from x in list
select new ReceivingSFGDetailDTO
{
ID = x.ID,
ReceivingID = x.ReceivingID,
Barcode = x.Barcode,
QtyActual = x.QtyActual,
QtyBag = x.QtyBag,
CreatedBy = x.CreatedBy,
CreatedDate = x.CreatedDate,
QtyPerBag = x.QtyPerBag
};
or some case that I never use before,
like how to exec store procedure... please some one can help me to solve this case.
If you want to execute Stored Procedure vie Entity framework you will of course have to start by mapping it into the data context.
Once the stored procedure is mapped in your model layer you can simply call it pseudo like this:
List<SomeStuff_Result> list = _db.NameOfStoredProcedure(string somevariable).ToList();
It should behave the same way any object you receive from data layer.
You can also check this answer.

img.lockFocus is inaccessible via ObjC bridge?

I'm trying to create a purely JXA-ObjC approach to getting pixel colors from image paths. Here's what I have currently:
ObjC.import('Foundation')
ObjC.import('AppKit')
var c_filePath = $(picturePath)
var c_img = $.NSImage.alloc.initWithContentsOfFile(c_filePath)
if(c_img==$()){
return []
}
var c_point = $.NSMakePoint(x,y)
c_img.lockFocus() //Error - Undefined is not a function...?
var c_color = NSReadPixel(c_point)
c_img.unlockFocus() //Error - Undefined is not a function...?
c_img.release()
var r; var g; var b; var a
c_img.getRegGreenBlueAlpha($(r),$(g),$(b),$(a))
r = ObjC.unwrap(r)
g = ObjC.unwrap(g)
b = ObjC.unwrap(b)
a = ObjC.unwrap(a)
This code is heavily based off of the code found here.
However, as shown above c_img.lockFocus() is undefined according to JXA. Oddly I can get access to c_img.lockFocusFlipped(), however I'm not sure how to use this and/or if it can be used for the same purpose as lockFocus().
Is there an obvious problem here? Or is there a better way to get the pixel colour of an image?
Any help would be grateful.
It looks like I am too used to methods requiring parenthesis. TylerGaw however told me that this is not necessarily the case.
ObjC.import('Foundation')
ObjC.import('AppKit')
var c_filePath = $(picturePath)
var c_img = $.NSImage.alloc.initWithContentsOfFile(c_filePath)
if(c_img==$()){
return []
}
var c_point = $.NSMakePoint(x,y)
c_img.lockFocus
var c_color = NSReadPixel(c_point)
c_img.unlockFocus
c_img.release
appears to work as expected.

Can't get additionalSearchFields to work

jsonStoreInit = function(pSuccess, pFailure){
collections={};
collections['objects'] = {};
var options = {};
options.localKeyGen = false;
options.clear = false;
options.username = app.username;
options.password = app.password;
options.additionalSearchFields = {key: 'string'};
WL.JSONStore.init(collections, options)
.then(pSuccess)
.fail(pFailure);
};
putObject = function(pObject) {
var keyValue = pObject.getKey();
var object = {myObject : pObject.getKey()};
var options = {};
//options.additionalSearchFields = {key : keyValue};
WL.JSONStore.get("objects")
.add(object, options);
};
I'm on WL 6.0 FP 1
In the code sample above jsonStoreInit is what I use to init my store including the options.additionalSearchFields.
When I come to add the objects in the putObject funciton it works fine with the additionalSearchFields commented out, but when I uncomment it to add the additional fields I get an error
[wl.jsonstore] {"src":"store","err":21,"msg":"INVALID_ADD_INDEX_KEY","col":"objects","usr":"xxxx","doc":{},"res":{}}
When I look this error message up all I get is
21 INVALID_ADD_INDEX_KEY
Problem with additional search fields.
Which I had kinda figured ... can anyone provide any help on this ...
I don't need to you fix my code but if you could point me to a working example that would be excellent.
Many thanks, ownimage
The person that asked the question solved it, but I'm leaving this answer in case someone is wondering how to pass data that uses additionalSearchFields.
Example:
var data = {hello: 'world'};
WL.JSONStore.get('collection').add(data, {additionalSearchFields: {key: 'value'}})
The example assumes the collection was created with a search field for hello as string and an additional search field for key as string. It also assumes there's a collection initialized called collection.

How to use the exported variables of another commonjs module without declare them again?

Suppose I have a module models.js:
exports.User = mongoose.model('User', UserSchema);
exports.Question = mongoose.model('Question', QuestionSchema);
exports.Answer = mongoose.model('Answer', AnswerSchema);
exports.Comment = mongoose.model('Comment', CommentSchema);
Now I want to use it in another file:
var models = require('./models');
var User = models.User;
var Question = models.Question;
var Answer = models.Answer;
var Comment = models.Comment
// then use them
var user = new User();
It is boring that I have to declare all the models I defined in models.js.
Is there any way to simplify it, that I don't need to declare the models again:
var models = require('./models');
// !!! do some magic
var user = new User();
Curious why don't you want to simply do with no magic needed - what is issue with simple ..
var models = require('./models');
var user = new models.User();

Recipe for adding Drupal node records

I am looking for a recipe for adding Drupal node records.
I have identified three tables.
node_revisions
nid=249 - vid + 1?
vid=248 - auto-increment
node:
nid=250 - vid + 1?
vid=249 - auto-increment
content_type_my_content
vid=248 - from node_revisions table?
nid=249 - from node table?
Am I on right track?
Is there some helper functions for this?
If you are looking to programatically create nodes, use the Drupal API.
Start by creating a $node object. Fill in title, type, status, body, plus any CCK fields. At the end, call node_save($node);.
node_save will save your node object and do the necessary database work.
Check this out:
http://api.drupal.org/api/function/node_save/6
http://mediumexposure.com/how-build-node-drupal-programmatically/
The easiest way to see what each type of content type has as fields is to create a node (for example, Page), then use var_dump() to see the node's contents. That will show you every field you will need to use in your node object creation script.
Some folks will say you should create a form array, and call drupal_execute() on it so validation is performed before it's saved to the database. Either way is fine.
Kevin - With your help I have made good progress.
Node and CCK fields are now being populated.
Location (long/lat) is populated but not showing up on View screen.
Checkboxes are not being populated.
global $user;
$newnode = new stdClass();
$newnode->title = 'New node title';
$newnode->body = "this is a new node, created by import function";
$newnode->uid = $user->uid;
$newnode->type = 'items';
$newnode->status = 1;
$newnode->promote = 0;
// CCK fields
$newnode->field_myfield1[0]['value'] = 'test 1';
$newnode->field_myfield2[0]['value'] = 'test 2';
$newnode->field_mycheckbox[0]['value'] = 1;
// longitude, lalitude
// $newnode->locations[0]['lid'] = ?;
$newnode->locations[0]['street'] = 'xx';
$newnode->locations[0]['city'] = 'xx';
$newnode->locations[0]['province'] = 'xx';
$newnode->locations[0]['postal_code'] = 'xx';
$newnode->locations[0]['latitude'] = 0;
$newnode->locations[0]['longitude'] = 0;
$newnode = node_submit($newnode);
node_save($newnode);
content_insert($newnode);
OK. here is the full recipe. Drupal does the rest automagically.
global $user;
// Node fields
$newnode = new stdClass();
$newnode->title = $data[0];
$newnode->body = $data[1];
$newnode->uid = $user->uid;
$newnode->type = 'mytype';
$newnode->status = 1;
$newnode->promote = 0;
// CCK fields
$newnode->field_myfield1[0]['value'] = $something;
$newnode->field_myfield2[0]['value'] = $something;
$newnode->field_my_checkbox[0]['value'] = $something;
// longitude, latitude
$newnode->field_loc_latitude[0]['street'] = $something;
$newnode->field_loc_latitude[0]['city'] = $something;
$newnode->field_loc_latitude[0]['province'] = $something;
$newnode->field_loc_latitude[0]['postal_code'] = $something;
$newnode->field_loc_latitude[0]['latitude'] = '';
$newnode->field_loc_latitude[0]['longitude'] = '';
$newnode = node_submit($newnode);
node_save($newnode);
content_insert($newnode);