Using Reserved words as fields name - salesforce

I am using external WSDL class for creating apex classes for my project, some of the classes have fields which name is reserved in apex, as limit word.
My problem here is, i can't call that field, sample example:
System.debug(object.limit);
where limit is field in object.
I can't even save the file because there is error in console saying:
Variable does not exist: limit
Any idea how reserved word in this cases can be escaped?

I've made an alternative version of Wsdl2Apex. You can get it for free from the FuseIT website.
In this alternative version it will add a _x suffix to the generated apex code for any reserved keywords that are encountered. The underlying generated SOAP request won't have this suffix.

Related

How to remove all keywords except specific from robot framework test report

I want to limit the keywords that are reported in the output.xml / log.html
Something like, I don't want to log keywords like SET VARIABLE or QUERY, etc., but log only specific keywords that create a meaningful test report
checked multiple questions on StackOverflow
How can I prevent the logging of all keywords except Log keyword in robot framework?
How can I tell robot framework not to log a keyword?
This provides a very close answer at the end, but it is not working and getting into the LOGGER is perhaps not my cup of tea
Have tried FlattenKeywords, removekeywords options, but they dont completely help, as I need more dynamic control over the logging
Tried the SET LOG LEVEL keyword also, but that just removes the information within the keyword, does not remove the whole keyword
Expected results should log only the specific keywords that i mention in the script, something like only the checkpoints are reported and not all the steps
If --removekeywords and --flattenkeywords don't work for you, I can think of two possible solutions.
For one, you could write your own script to filter out all the keywords you don't want from output.xml, and then generate the log.html and report.html after you've run the filter.
You could also create your own log file. You can create a listener that can decide at runtime whether a keyword should be logged or not. You can then write the keyword information to your own custom log file.

How to translate role in Drupal?

If I want to translate the role to other language, how do I do it?
I can change that to other language as the default but I would like to use English so I don't have to deal with UTF8 issue in my code with Asian charactors.
if(in_array("administer nodes", $user->roles))
I have tried to find it from translation module but this seems not translatable as other text in Drupal.
So I'm assuming you've already tried using the t() or st() functions?
If that's so, you may need to try a client-side AJAX translation solution. One way you might do this is to create a vocabulary of terms (corresponding to the English role names), and have the Asian character translation as a secondary field. Then use views to create a view of this vocabulary, and create a lightweight module that:
1) loads a Drupal AJAX script on every page (or every page where role names might be utilized)
2) the script looks for a list of specified containers by id that you know will contain role names
3) searches the view you created for the English pattern, and replaces it in the container with any positive matches
Drupal API's example AJAX module
You could then expand the module/AJAX script to solve other similar translate fails on your site.

Using PreAnalyzedField in Solr 4

I am trying to index fields using Solr, in which I already have a TokenStream. I dont want Solr to have any analysis - Its already made. As I understood, I could get this exact functionality using Solr's PreAnalyzedField.
The problem is that I cannot find any good resource to help me understand the flow:
I needto define the field in the schema.xml file as PreAnalyzedField, and the tokenstream should be parsed using the parse method of the parser implementation - but how to I actually feed the field with my tokeStream? how \ when exactly is it sent to the toFormattedString method???
I think PreAnalyzedField is a bleeding edge of Solr as of 4.0/4.1. The main documentation is on the Wiki and basically explains the two parser types. The default is JSON, I am not sure how to get the other type to work.
Once you have that type defined, you just supply fully-tokenized content in the JSON format as described as that field's value. When that hits the parser, it will convert it to the Token stream. The same way a number gets parsed from a string representation into a real numeric representation. Try feeding an unparsable value and you will see the full call stack in the exception stacktrace.
The problem is how to query it. My own discussion on the mailing list did not get very far.

dynamicField in django-haystack SOLR config

How to configure search_indexes.py to index dynamicFields in django-haystack. I'm using SOLR as the search engine for haystack.
If you are using Haystack's build_solr_schema management command to create your schema.xml, notice that it automatically includes various dynamicFields for popular field types. For example, check out the schema template for Haystack v2.1. (This looks like it's been there since Haystack v1.)
This allows you to create dynamically-named fields in your search index's prepare method. For example, if you were indexing notes that could have an id string for your ever-changing group of partners, you could do this:
def prepare(self, obj):
self.prepared_data = super(NoteIndex, self).prepare(obj)
for (partner_name, partner_id) in get_partners():
self.prepared_data['%s_s' % partner_name] = partner_id
return self.prepared_data
The key thing here is that the field name ends with "_s", which according to the schema is a dynamic name for string types.
Unfortunately, these dynamic partner fields are not explicitly defined at the top of your SearchIndex class. You may want to mention this in a comment.
As far as I can see in the source code of django-haystack 1.2.* you can't do this. You can write own schema instead of generating it using management commands and use it.
As #nofinator say, you can do this in .prepare method of SearchIndex class by concatinating field name with prefix from SOLR Schema.xml.
By default Haystack(current ver. is 2.1.1) ships with some default DynamicField like a *_s. But if you want, you can make your own DynamicField.
In my project ill make attr_* field and its work fine.
All you need to do, is add this field, with same syntax in Schema.xml
You can do in manualy or overriding standart Haystack build_solr_schema management command.(Btw, its uses standart django render template fnc. so its pretty easy.

Why do XML Namespaces usually start with http://...?

For example, the WPF namespace is:
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
If I define my own namespace, should it also start with http? Isn't http misleading?
Namespaces doesn't have any meaning in their value, except for that value to be unique to avoid nameclashing. This is why you see a lot of companies putting in the URL for their own website as the namespace. URLs serve the same purpose, to be unique. Over the years it's just become good practice to use an URL, because if everyone does that, no nameclashing should occur :)
The W3C Document defining XML Namespaces says (quoting) :
Definition: An XML namespace is
identified by a URI reference
[RFC3986]
And RFC 3986 says (quoting) :
1.1.1. Generic Syntax
Each URI begins with a scheme name,
as defined in Section 3.1, that
refers to a specification for
assigning identifiers within that
scheme.
So I guess using http:// is what's closest to the standard -- as HTTP is the most common scheme used on the net.
In addition, as there can be only one owner for a domain name, it allows each company to use it's URL in its namespaces.
Another common way instead of using a URL starting with http:// is to use a Uniform Resource Name whose format is defined by RFC2141.
Such namespace identifiers are e.g. used by ODF (OpenDocument Format):
urn:oasis:names:tc:opendocument:xmlns:office:1.0
urn:oasis:names:tc:opendocument:xmlns:style:1.0
urn:oasis:names:tc:opendocument:xmlns:text:1.0
From this article at W3Schools:
"The namespace URI is not used by the parser to look up information. The purpose is to give the namespace a unique name. However, often companies use the namespace as a pointer to a web page containing namespace information. Try to go to http://www.w3.org/TR/html4/."
It is a reliable way to create a readable globally unique identifier. It may or may not be to a valid URL with more information.

Resources