Add contents of Dexterity NamedBlobFile to SearchableText - full-text-search

I've created a dexterity content type that has a NamedBlobFile as one of the fields (users will upload a .pdf). I'd like to have full-text indexing on that pdf -- like the ATFile type -- but not sure what I have to do to make that happen.
I've installed collective.dexteritytextindexer and have gotten some of the other fields added to searchable text by doing this:
searchable('paper_author')
paper_author = schema.Text(title=_(u"Author"), required=False)
I'm not sure what to do for the file field. Suggestions?

I think using the searchable() directive should work for NameBlobFiles too.
There is a converter in collective.dexteritytextindexer taking care of transforming the file contents into text so that it is indexable (see the code at github), which also applies for blobs (since the INamedBlobFileField subclasses INamedFileField for which the adapter is registered).
If it does not work its a bug, so please create an issue at the collective.dexteritytextindexer issue tracker.
If the problem is that the field is not defined in your code and you cannot use the searchable directive, there is also a searchable function (import from .utils!) which can be used outside the scope of the schema like this:
from plone.app.dexterity.behaviors.metadata import IBasic
from collective.dexteritytextindexer.utils import searchable
searchable(IBasic, 'title')
searchable(IBasic, 'description')

Related

Possible to set file name for h2o.save_model() (rather then simply use the model_id value)?

Trying to save an h2o model with some specific name that differs from the model's model_id field, but trying something like...
h2o.save_model(model=model,
path='/some/path/then/filename',
force=False)
just creates a dir/file structure like
some
|__path
|__then
|__filename
|__<model_id>
as opposed to
some
|__path
|__then
|__filename
Is this possible to do from the save_model method?
I can't / hesitate to simply change the model_id before calling the save method because the model names have timestamps appended to them to avoid name collisions with other models that may be on the h2o cluster (am trying to remove these timestamps when saving on disk and simplifying the name on the cluster before saving creates a time where naming collision can occur if other processes are also attempting to save such a model (of, say, a different timestamp)).
Any way to get this behavior or other common alternatives / workarounds?
This is currently not possible, however I created a feature request here. There is a related question here which shows a solution for R (could be adapted to Python). The work-around is just to rename the file manually using a few lines of R/Python code.

Is there any way of importing Query with a custom directive applied?

I want to import Mutation.updateUser() from "./generated/prisma.graphql", but I also want to add the #isAdmin directive. I can accomplish this by copying the query by hand:
type Mutation {
updateUser(data: UserUpdateInput!, where: UserWhereUniqueInput!): User #isAdmin
}
But that means I have to copy every query/mutation/type I want to add a directive to, is there any sintax like this?
# import Mutation.updateUser from "./generated/prisma.graphql" #isAdmin
Unfortunately this is not possible at the moment. GraphQL SDL by default has no way of importing types or fields of types (as you want to do) into other files.
Based on the # import ...-syntax you show, I believe you're trying to use graphql-import. With this library it's possible to import entire types but not individual fields of types. If you'd like to have that functionality in the graphql-import library, please open an issue.

jstl/jsp print name of file beutiful

I have my tag ${file.name} in a jsp file to display a name of file to download
name containt a full file name,include file extension. for example
testfile.png
a-file.zip
testfile-test505454654.png
a-filenum5468.docx
other_file_with_a_name_very_very_very_larrrrrrrrrrrrrrrrrrrrrge.pdf
Files with very long names, crash my layout.
I think the way to format the file name to shorten it but include the extention. Maybe
testfile.png
a-file.zip
testfile-test505454....png *
a-filenum5468.docx
other_file_with_a_na....pdf *
How I can do?
in href no problem because it is done by id ${file.id}
If file is a POJO, you may add a getter-method to the POJO (something like String getShortName(){}) that returns a short version of the file name. And then use the method in your EL expression: ${file.shortName}.
I would write and register a custom tag that would take care of shortening the output to a maximum length
<custom:short value="${file.name}" var="shortFileName" />
The tag would take care of shortening based on defaults or values you specify in the element and putting it the result in a request attribute you can use anywhere after that declaration.
Since the requirements can be used many times so You should go with CUSTOM Tag solution like #Sotirios Delimanolis suggested.
JSTL function ( Like c:fn ) is another solution. Using jstl function get better performance than Custom tag ( simple / classic model )
Link: http://www.noppanit.com/how-to-create-a-custom-function-for-jstl/

Using the compare tool during an object import in Dynamics AX 2009

I'm trying to import a list of objects into a Dynamics AX 2009 system. The problem that I have is that the object IDs differ for all the objects that I'm importing. I'm doing the import manually, and so as part of this I need to compare each object (and there's a few), because they all show as different.
My question is: is there a way to either tell Dynamics to not show the object ID as a difference, or else to fool it into thinking they're the same?
Depending on your scenario, you could export the project from the source without using IDs. When importing the project to another system, there will not be ID conflicts (obviously).
But before you decide whether or not to export without ID, you should understand the pro's and con's of ignoring the IDs.
There is no option to ignore object ids.
However, you could make a code change in \Classes\SysTreeNode\comparableTextListProperties and delete the offending id property.
.XPOs are text files, so you can use a text editor and do a find and replace of object ids outside of AX before trying to import it.

How to add components in to an existing GUI created by guide?

I just created a GUI using guide in MATLAB for a small project I'm working on. I have amongst other things two text fields for from and to dates. Now I'd like to get rid of them and use a Java date select tool. Of course this is not possible using guide so I need to add them manually.
I've managed to get them to show up by putting this code into my Opening_Fcn,
uicomponent(handles, 'style','com.jidesoft.combobox.DateChooserPanel','tag','til2');
using UICOMPONENT.
But even though it shows up I can't access the date select's attributes, for example
get(handles.til2)
returns
??? Reference to non-existent field 'til2'.
How can I fix this?
Unless you edit the saved GUI figure, the basic handles structure will not include your new component by default.
One way to access you component is to store the handle via guidata, by adding the following to your opening function:
handles.til2 = uicomponent(handles, 'style','com.jidesoft.combobox.DateChooserPanel','tag','til2');
guidata(hObject,handles)
Functions that need to access the handle need the line
handles = guidata(hObject)
to return the full handles structure that includes the filed til2

Resources