I searched a lot, but I only found this:
copy-a-resource
Unfortunatelly this copies a single node only but not it's children (tree).
The JCR Workspace.copy method does copy whole subtrees.
There is a tree copy, but not ibn Sling but in com.day.cq.commons.jcr.JcrUtil (which is closed source)
Related
When creating a pipeline, I find myself with the need to bring all the files that are in folders called in the following way:
\folder1\folder2_202201\file1.parquet
\folder1\folder2_202204\file1.parquet
Like the folder2_?????? it will be changing all the time, I can't find a way to take a fixed path, since it is dynamic.
Is there any way to make a regular expression which can take the source like: \folder1\folder2_*\file1.parquet so that I can take everything that starts in folder?
thanks
regards
Osky
So I have the following (simplified) project structure.
scripts/
client.m
src/
+estimators/
#estimator1/
3party/
shell_script.sh
estimator1.m
Basically, what I try to do is, calling estimator1.m from client.m. This is working very well, no issues. However, from within estimator1.m I try to call shell_script.sh. The problem, relative paths do not work since it is always looking from the path client.m is called.
What I tried from estimator1.m is:
pathToScript = fullfile('3Party','shell_script');
system(pathToScript);
I would really like to avoid absolute paths since I'd like this package to be used by others as well. So hardcoding paths to my home directory is not good.
Use mfilename('fullpath') to get the full path of the currently executing file. Use fileparts to get just the directory part. Putting it together,
scriptdir = fullfile (fileparts(mfilename('fullpath')), '3Party');
Here is an additional answer to the one by #Edric. My second issue was that I wanted to implement the feature in the parent class since it is a functionality used by all child classes. The proposed answer is perfect when you have the function implemented in the class itself. However:
scriptdir = fullfile (fileparts(mfilename('fullpath')));
would always return the location of my parent class. So I implemented following in the parent class to retrieve the correct location in child classes:
function classdir= getClassDir(obj)
[classdir, ~, ~] = fileparts(which(class(obj)));
end
I am confused because I figured out, that there are 2 different FileReference classes inside TYPO3. One of them is from the Core and the other one is from Extbase.
The one from the core has function like delete(), but this delete is not implemented yet. I cannot find any function for deleting the FileReference.
If I use update in my extension from the repository, the image will be added not replaced by the new one.
I would like to understand how I can add, delete and fetch files to/from ext_file_reference in a simple way.
Does anybody have a solution or a hint?
It's unclear from your question what you are trying to do.
If you want to replaces files, you do that on the File Object itself, not the references. But note, that this replaces the file for all references. There is a replaceFile() function on the ResourceStorage object of the file.
If you want to replace a file in a Property, you have to detach one file and attach the other. Every Property that holds FileReferences is an ObjectStorage, and as such comes with attach() and detach() methods to do that.
let me try to explain it in more details. I try to replace an image on a page with another one, but without modifying the image at all. Also the new image is already stored under fileadmin. I would need a new filereference and to replace the old one in the sys_file_reference.
So attach and detach would be the goodsolutions, but are not working with extbase filereference. For that I need a \TYPO3\CMS\Extbase\Persistence\ObjectStorage object. I tried "\TYPO3\CMS\Extbase\Persistence\ObjectStorage<\HGA\Hgarecipes\Domain\Model\FileReference>" but it creates an error "Cannot cast object of type "TYPO3\CMS\Extbase\Persistence\ObjectStorage" to string". So finally I am looking for a sulution to add and delete images from sys_file_reference under extbase. I found many pleople which are looking for something, but no solution. Alo if I use the objectstorage I have not longer access to the originalResource of the filereference.
With other words, to create a entry in the sys_file_reference with a given filepath and delete this entry if not longer needed.
On the other hand I want to understand why extbase needs a own filereference.
I would like to hide some tree nodes in the match results of EMF Compare, since they are just containers with no meaning to our users.
I have tried two approaches, but both result in some unwanted side-effects.
Using a more narrow scope
Details: https://www.eclipse.org/forums/index.php/t/781759/This
results in the separate diffs being available, but without the
enclosing tree structure of the model.
Using a post processor to remove some container objects from the tree of matches.
Details: https://www.eclipse.org/forums/index.php/t/781794/
This is more of a success in that the resulting tree structure is exactly what I'm after. This however breaks navigation in the bottom pane.
I'd be really happy if someone could have a look and see what my attempts are missing.
Thanks,
Mattias
I got a reply in the Eclipse forum. An EMF Compare core dev let me know that this is not possible without breaking behaviour as I described.
So for the rest of you trying: no dice.
Here is my problem>
We currently have several Ecore models for our applications. One of the Ecore models (mainModel.ecore) has stuff that is common in all the rest of the models. So, what i want to do is have all the other models reference the contents of that one model so we do not have to constantly copy the contents of that one model into all the models every time there is a change.
Is this possible and how can I do this?
(I am very new to Ecore and still do not understand a lot of the terminology.)
EDIT:
How do i get the EcoreUtil.getRootContainer to return the the container of the loaded resource? I need to have that location so that i can resolve certain paths from that root. This may resolve my issue.
Here is what i attempted so far:
I tried "load resource..." by loading the mainModel.ecore into all the other models and deleting the local references. There were a lot of places that i had to fix after doing this and i did. After re-generating the source and trying to compile there are places where it tried accessing the "dotpath" that was local to the original file and i do not know how to change that "dotpath" to reference the "loaded resource". So it is not able to resolve those paths.
Thanks!
You'll generally get answers about EMF more readily by using the EMF newsgroup (eclipse.tools.emf) which is web accessible via
http://www.eclipse.org/forums/index.php/f/108/
Your problem isn't so clear. I don't understand how the compiled code accesses anything via a "dot path". I know if you load a resource and refer to it's contents you'll generally end up with relative paths, but those are normally resolved during loading to an absolute URI. Of course the referencing resource itself needs to be loaded with an absolute URI, but the generator does that properly...