How do I make NSMetadataQuery see my saved documents' folders as packages? - icloud

I'm writing an app which saves and loads documents both locally and on iCloud. Locally is working fine, but I'm having a problem with iCloud.
The documents are saved as a package - the UIDocument reads and writes an NSFileWrapper which contains an image file, a thumbnail file, and an info plist. When I save the document to iCloud and then look at the files under 'Manage Storage', I see the individual files instead of the packages; and more importantly when I search for files using NSMetadataQuery it returns an NSMetadataItem for each of the individual files instead of the packages. As a result, my app doesn't realise there are any packages to load and iCloud is pretty useless.
I thought that if I set up the document type and exported the UTI correctly that the packages would be treated properly. Was that right? If so, what's the checklist for setting up a document type as a package? I have:
Added a document type
set LSTypeIsPackage to YES (I've tried string YES and bool YES)
set CFBundleTypeExtensions to an array containing one string: the file suffix
set LSHandlerRank to Owner
Exported a UTI with the same identifier
set it to conform to com.apple.package
added a UITypeTagSpecification dictionary, containing an array for the key public.filename-extension, which contains one string: the file suffix
I've also tried adding a matching Imported UTI to match the exported one, but no luck there.
What did I miss?
UPDATE: I notice that the OP in this question is seeing the behaviour I want (even though he doesn't want it) so it must be possible.

Based on this I tried removing the LSItemContentTypes from my plist, and it worked.

Related

Python in Knime: Downloading files and dynamically pressing them into workflow

I'm using Knime 3.1.2 on OSX and Linux for OPENMS analysis (Mass Spectrometry).
Currently, it uses static filename.mzML files manually put in a directory. It usually has more than one file pressed in at a time ('Input FileS' module not 'Input File' module) using a ZipLoopStart.
I want these files to be downloaded dynamically and then pressed into the workflow...but I'm not sure the best way to do that.
Currently, I have a Python script that downloads .gz files (from AWS S3) and then unzips them. I already have variations that can unzip the files into memory using StringIO (and maybe pass them into the workflow from there as data??).
It can also download them to a directory...which maybe can them be used as the source? But I don't know how to tell the ZipLoop to wait and check the directory after the python script is run.
I also could have the python script run as a separate entity (outside of knime) and then, once the directory is populated, call knime...HOWEVER there will always be a different number of files (maybe 1, maybe three)...and I don't know how to make the 'Input Files' knime node to handle an unknown number of input files.
I hope this makes sense.
Thanks!
Thanks to Gábor for getting me on the right track. Although I ended up doing a slightly different route after much experimentation.
===
Being new to Knime, I don't know if this is an efficient use of Knime, or a complete Kluge...but it does work.
So, part of the problem is some of the Knime specific objects - One of which is called URIDataValue.
A Python Pandas dataframe is, apparently, interchangable with the Knime tables. However, I don't know if there's a way to import one of these URIDataValue objects into Python. So here's what I did...
1. I wrote a Python script that creates a Pandas Dataframe, and populates it with one Column. Everything is a string, including the column header:
from pandas import DataFrame
# Create empty table
T = DataFrame(
[
['file:///Users/.../copy/lfq_spikein_dilution_1.mzML'],
['file:///Users/.../copy/lfq_spikein_dilution_2.mzML'],
],
)
T.columns = ['URIDataValue']
#print T
output_table = T
That creates this dataframe:
Note: The column name and values are just strings. But it is (apparently) important that the column header be 'URIDataValue'...even though HERE it's just text. If the column name is not 'URIDataValue' the next node doesn't know what to do.
NEXT, the 'output_table' from the 'Python Source' node is patched to a 'String to URI' node, which (apparently and magically) knows to change the entire columns string values to URIDataValues (presumably based on the name of the first column...don't know that for sure).
Finally, the NEW table, with the correct data objects goes to a 'URI to PORT' node...since apparently 'Port' objects and a 'URI' object are different.
This, then, matches the needed input to the ZipLoop...which is normally the out put from a static (hard coded) 'Input Files' node.
Now, to actually solve the question above, I just have to add the code to my 'Python Source' to download and unzip the S3 files, then annotate the dataframe with their locations, and go.
I have no idea what I'm doing, but it worked.
There are multiple options to let things work:
Convert the files in-memory to a Binary Object cells using Python, later you can use that in KNIME. (This one, I am not sure is supported, but as I remember it was demoed in one of the last KNIME gatherings.)
Save the files to a temporary folder (Create Temp Dir) using Python and connect the Pyhon node using a flow variable connection to a file reader node in KNIME (which should work in a loop: List Files, check the Iterate List of Files metanode).
Maybe there is already S3 Remote File Handling support in KNIME, so you can do the downloading, unzipping within KNIME. (Not that I know of, but it would be nice.)
I would go with option 2, but I am not so familiar with Python, so for you, probably option 1 is the best. (In case option 3 is supported, that is the best in my opinion.)

How do I track down specifics for an opencart module that is rendering on my site but missing everything except the catalog template file?

I've inherited an opencart 1.5.5.1 site and am completely new to the cms. From what I've been able to gather, it was built by a competent developer but then went through a hack-it-up development team, and then on to me. So, I really don't know what all to expect from it.
I currently have a module that is rendering in the left sidebar and I don't know why it's rendering there. The only file I can find in the file stack related at all to this "module" is a single template file within the catalog directory structure called:
/catalog/view/theme/mytheme/template/module/affiliate_profile_select.tpl
All of the other installed modules on the site seem to have lots of other files associated with them, whose locations are verified by the research I've done on creating opencart modules: ie, module files in the following directories:
/catalog/controller/module/
/catalog/language/english/module/
/catalog/model/module/
/catalog/view/theme/mytheme/template/module/
/admin/controller/module/
/admin/language/english/module/
/admin/model/module/
/admin/view/template/module/
From what I've been able to find though, this single file (affiliate_profile_select.tpl) is the only file in the file stack that is associated with this module.
I can't find anything related to this module, and/or file, inside any of the vqmod php or xml files.
I can't find anything related to this module in the admin area. I've tried searching through all of the installed modules for other generic identifiers (the section view is rendering at the very top of the left-sidebar on most non-logged-in pages, so I'm looking for layout locations of "Left Sidebar" and positions less than 2), but haven't found anything.
And yet, the section is obviously rendering on the site, so it has to be there somewhere. In fact, it's rendering in two places. It's also in the top-content section of the mobile view of the home page.
Right now it's almost feeling like it was a module that had been written, installed, and configured, and then someone deleted all but one of the files associated with the module. Could a situation like that happen?
Is there any way to track this issue down by querying the database? Or would the template inclusion obviously be inside a file somewhere and I just need to find it? To complicate matters, the hosting company doesn't allow remote login with a console (from what I can tell). Otherwise I'd just have run a grep for the filename in case someone had just thrown an "include()" statement in somewhere. The only place I've checked for something like that so far was in the left-sidebar template file:
/catalog/view/theme/default/template/common/column_left.tpl
but it's just a simple for-loop that echoes out the module views.
Any help or direction on how I might be able to track this problem down would be of significant help.
In Opencart, .tpl (template) files are always called by controllers which as you probably guessed are in catalog/controller/. An if it's a module (showing in left sidebar position, it's probably going to be in catalog/controller/module/. First order of business would be to find the controller that's calling the template you referred to. I'd probably start by getting into a shell and doing something like this from the site's docroot:
grep -r affiliate_profile_select .
From there you should be able to find the associated module controller and any other logic involved. Sometimes people use vQmod to add something on to a pre-existing module so that can possibly explain the lack of other similarly named files.

i have headers separately, how to import it to informatica target

I have source and target in an informatica powercenter developer. I heed some other header name to be imported in the target file automatically without any manual entry. How can I import customized headers to informatica target.
What have you tried?
You can use a header command in the session configuration for the target, I haven't used it, and couldn't find any documentation on it (i.e. what is possible and how, whether parameters can be used or not, etc.). I did test using (on Windows) an ECHO command to output its text to the header row, but it didn't seem to recognize parameters.
Or you can try to include the header as the first data output row. That means your output will have to be all string types and length restrictions may compound the issue.
Or you can try using two mappings, one that truncates the files and writes the header and one which outputs the data specifying append in the session. You may need two target definitions pointing to the same files. I don't know if the second mapping would attempt to load the existing data (i.e. typecheck), in which case it might throw an error if it didn't match.
Other options may be possible, we don't do much with flat files.
The logic is,
In session command, there is an option called user defined headers. Type echo followed by column name separated by comma delimited
echo A, B, C

How do I display a field name containing the substring OMIT in ApEx?

One of the fields in my database table is named DATEOFDISCHARGEFROMITU. In any report output, this displays as DATEOFDISCHARGEFRU. I've figured out that the missing characters form the word 'OMIT', which makes me think it's related to this old problem in a previous version of ApEx (I'm using version 4.1.)
Is there a way to display the whole field name in the report header when the field name contains the string 'OMIT'?
Note: Using html character codes will allow the field name to display properly, but then when the report is exported to CSV the character codes are of course shown instead of the full field name. I need a solution that works for exports as well as displaying onscreen.
Platforms (tested): Oracle Application Express (APEX), Version 4.0.2
Note: I am not sure how the linked OTN post is relevant to your problem aside from the coincidence that their file export contains the word "OMIT" and your column title contains the word "OMIT".
It's safe to say that "OMIT" isn't an APEX or ORACLE reserved word that is sabotaging your output. However, if you were talking about a scrap of SQL that attempted to create a table named "SELECT" or "WHERE"
i.e., SELECT * FROM "SELECT" WHERE...
you'll be blocked by the RDBMS from proceeding. :)
I tried an export with a query that contained a column header labeled "OMIT" (see the far right in the example.) The .csv file interpreted by Microsoft Excel looked like this:
I wrote up a separate Q&A post about creating dynamic APEX report headers to answer your follow-on question about a suitable solution for providing a clean, htmlcode-free output when a report is eventually exported to a text, comma separated (or other delimited) output.
In summary, the linked post suggests to set up a dynamic PL/SQL Function within a page item. The page item can be referenced directly in the report column header definition. This is a screenshot demonstrating a possible solution:
The link to the general explanation has more details on the APEX design tasks that gets to this final product.
Onward.
I solved this by using this solution for exporting to csv without an enclosing quote character - as that was another challenge I was faced with for the particular application I was developing. By manually creating the export file I was also able to define the column headings exactly, and the "OMIT" issue did not occur.
Technically that's not a solution for displaying a report with the required headings that can also be exported (Richard's response does that) but it does what I need it to and solves the immediate problem of the DATEOFDISCHARGEFROMITU column heading.

Moving files in a verity collection

I have a collection of files which have been added to a verity collection. The filename, with complete path, has been used as the key.
I would like to move the location of the files on disk, but I am concerned that I will end up with duplicate entries (when I update the same file, the path to the file will be different, so I'll have an entry for the old file and an entry for the new one).
I wasn't involved with the original application setup, and I don't know much about verity or coldfusion (the rest of the app is in PHP). Can anyone suggest how I can go about running some sort of regex replace on each key in a verity collection, or possibly suggest another approach?
I would recommend to create new collection, adjust to your new specs (at least new path in your case) and swich to it in the application code (replace the collection name in cfindex/cfsearch).
After making sure it works properly you are free to delete the old one.
If you can not create collection for some reason, you can simply purge the collection, switch the path and re-index it.
Please note that you can do all of this directly from the application (maybe temporarily script) using cfcollection tag, and using CF Admin (see Verity Collections in menu) too.