I've been working with Acceleo 3.2.2 for awhile lately but this is my first approach and there are many basic points that I'm still missing..
In my .mtl file I have created a new association for a class:
[anAssocClass.createAssociation(true, snk.aggregation, snk.name, 1, 1, snk.type,
true, snk.aggregation, anAssocClass.name, src.lower, src.upper) /]
How can I set a name to this new association?
The API provides the operations
setValue(stereotype: Stereotype, propertyName: String, newValue: String)
eSet(feature: EStructuralFeature, newValue: OclAny)
but I don't know if they are what I'm in need of and how to use them neither (which stereotype/feature and how can I get them?)...
Does anyone know how to help me?
Related
I have problems with closeArray in pact-jvm-consumer.
Given Json like this, how would the
"DslPart imeiResults = new PactDslJsonBody()"-statment be constructed.
{
"Car": {
"Price": 123,
"Features": [
"rain sensor",
"cruise control"
],
"Id": "6500"
}
}
I tried like this:
DslPart etaResults = new PactDslJsonBody()
.object("Car")
.integerType("Price",123)
.array("Features")
.stringValue("rain sensor")
.stringValue("cruise control")
.closeArray()
.stringValue("Id","6500")
.closeObject()
.asBody();
But that does not work, for example .closeArray() does not return PactDslJsonBody but DslPart, so you can never have anything after .closeArray()? I don't get it, can someone show the code on how to do this the correct way?
I'm taking a guess that your stringValue after the closeArray isn't working?
Sadly, when creating an array using the array function, it actually creates a new PactDslJsonArray and when closing it, there's no way for that class to know what the parent is, hence it just returns the common superclass of DslPart, which can cause some confusion. What needs to be done is cast that DslPart back to a PactDslJsonBody using the asBody function. So, your example should be something like:
DslPart etaResults = new PactDslJsonBody()
.object("Car")
.integerType("Price",123)
.array("Features")
.stringValue("rain sensor")
.stringValue("cruise control")
.closeArray()
.asBody()
.stringValue("Id","6500")
.closeObject();
Now, we know that this is confusing, hence why we started working on a new DSL using Java 8's Lambda functions to try to make the experience better. Hope that helps.
I thought I had escaped/ solved this error. But now am stuck. My db.py code:
Post = db.define_table('post',
Field('message', 'text', requires=IS_NOT_EMPTY(), notnull=False),
Field('answers', 'text', requires=IS_NOT_EMPTY(), notnull=False),
auth.signature
)
Post.is_active.readable=False
Post.is_active.writeable=False
controller:
#auth.requires_login()
def index():
db.post.answers.writable=False
db.post.answers.readable=False
form = SQLFORM(post, formstyle='divs')
if form.process().accepted:
pass
messages = db(post).select(orderby=~post.created_on)
.......code
#after several codes in now need to post a message to answers field, WITHOUT using a form in the view page
db.post.insert(answers=report)
In my view:
{{for msg in messages:}}
code
{{=msg.message}}
{{report from answers field}}
My issue is that i keep getting the error: IntegrityError('NOT NULL constraint failed:post.message
How do I solve this error?
Kind regards
If the database table was originally created with notnull=True, later changing the model to notnull=False will have no effect, as removing the NOT NULL constraint requires an external tool (the DAL cannot remove such constraints).
As you suggest in your comment, you can instead set the default value for the field to something like an empty string, but if you do in fact want to allow null values, you should instead use a database administration tool to remove the constraint from the database schema.
I need to override the product_id_change function defined in sale.order.line, so it doesn't change the unit_price every time I update the quantity.
I understand I have to use super, but I'm not sure how it all works.
Can anyone help?
Thank you.
This is pretty straight forward but you need to do a couple of things (assuming OpenERP 7)
Create your new module.
Create a class that inherits osv.Model
Add an _inherit = 'sale.order.line'
Implement your new product_id_change method.
Install your module and it should work.
A typical pattern is to call super and then process the results.
class MyModel(osv.Model):
_inherit = 'sale.order.line'
def product_id_change(self, cr, uid, ids, ...):
res = super(MyModel, self).product_id_change(cr, uid, ids...)
# do stuff with res.
return res
There is an example of exactly this in the OpenERP sale_margin module in the sale_margin.py file.
Afternoon,
I am getting the following error, and cant work out why... Can some one please take a look and let me know where i am going wrong.
Cannot implicitly convert type 'System.Collections.Generic.List' to 'System.Collections.Generic.List'
below is what i am trying to use, to get a list back so i can use it with Amazon. I have tried to remove the .ToList() bit but nothing seems to work. I am calling an MS SQL view "GetASINForUpdateLowPrices" which returns a list back of product ASIN's
List<string> prodASINs = dc.GetASINForUpdateLowPrices.ToList();
SQL for the view i am using, this may help a little bit more.
SELECT asin
FROM dbo.aboProducts
WHERE (asin NOT IN
(SELECT aboProducts_1.asin
FROM dbo.aboProducts AS aboProducts_1 INNER JOIN
dbo.LowestPrices ON aboProducts_1.asin = dbo.LowestPrices.productAsin
WHERE (dbo.LowestPrices.priceDate >= DATEADD(day, - 1, GETDATE()))))
What data type is a single ASIN?
Probably your GetASINForUpdateLowPrices is not an IEnumerable<string>. Try this to confirm:
List<string> prodASINs = dc.GetASINForUpdateLowPrices
.Select(e => e.ToString())
.ToList();
When you call your GetASINForUpdateLowPrices, it wont directly return List<string> even if there is only one field in your view. Try the following approach:
List<string> prodASINs = dc.GetASINForUpdateLowPrices
.Select(item => item.AsinFieldName)
.ToList();
Visual Studio IntelliSense should suggest you the property name after typing item.. If the property is not string try to add .ToString() at the end of the property name.
Edit: After your comment, it seems like you need to use it as .Select(item => item.asin.ToString()).
Just use var.
var prodASINs = dc.GetASINForUpdateLowPrices.ToList();
Are you sure that GetASINForUpdateLowPrices.ToList() creates a List of Strings? My best estimation is that it is a generic list of a different type.
To figure out what is going on - Change List<string> prodASINS to be Object obj. Then set a breakpoint to see what List type is actually generated by your ToList() code by checking out the object using the debugger. You can then update your code to move the values into a list of the appropriate type.
You might have to cast the right side of the assignor like this to ultimately get the job done (replacing string with another type if necessary) - List<string> prodASINs =(List<string>)dc.GetASINForUpdateLowPrices.ToList()
I am trying to understand how to access dynamics enums to be able to pass these into BusinessConnector calls. For instance, you can call the following:
pobj = (AxaptaObject)ax.CreateAxaptaObject("PurchFormLetter", [ENUM]);
But, I have no idea how to pass in the correct value of [ENUM]. In X++, the enum is DocumentStatus::PurchaseOrder, but I don't seem to be able to access this from anywhere. Can anyone possibly assist in finding out how to pass in the value?
Passing in the numeric value of the enum does not work unfortunately (in this case the value I need is 2). It returns an XPPException of 'Function PurchQuantity::construct has been used incorrectly.'
AxaptaObject pobj = (AxaptaObject)ax.CreateAxaptaObject("PurchFormLetter", 2);
If anyone could please be of assistance that would be greatly appreciated.
Regards,
Steve
Others have the same problem. And they have found a solution by creating an enum proxy.
Ok, this is for everyone else who hits this problem:
If you want to access the enum values from .NET purely without using X++:
string enumName = "DocumentStatus", enumValue = "PurchaseOrder";
object enumObj = (int)axa.CallStaticClassMethod("Global", "enumName2Id", enumName);
AxaptaObject dict = (AxaptaObject)axa.CreateAxaptaObject("DictEnum", enumObj);
object res = dict.Call("symbol2Value", enumValue);
The above can be made into a function very easily if reuse is required.
Still, doing the following won't work:
AxaptaObject pur = (AxaptaObject)axa.CreateAxaptaObject("PurchFormLetter", res);
However, you can do it this way:
AxaptaObject pur = (AxaptaObject)axa.CallStaticClassMethod("PurchFormLetter", "construct", res);
This will allow you to pass in the integer value of the enum (in this case, the variable 'res'). You can then use this object to post the purchase order.
Hope this helps someone.
Regards,
Steve