Creating new repository using RepositoryManage!
Reem
New Altair Community Member
Hi,
To create new Repository I used the following way:
First run
So, I checked the path where the repository should exist, and I found NO folder called "Repository" after creating the repository. However, the strange thing is I got the new repository in the list returned by getRepositories() method! (shown in the output above)
If I restart Netbeans and RapidMiner, I found the new repositories exist in RapidMiner studio but not in my file system!!!
My question is: how can I save the changes of creating repository (or even delete repository) without closing Netbeans and RapidMiner?
I tried to use save() and load() mothods as they load and save xml configuration files, but it didn't make sense!
To create new Repository I used the following way:
If I run the program twice and display the repositories, I got:
RepositoryAccessor repositoryAccessor = new RepositoryAccessorImplementation();
RepositoryManager repositoryManager = RepositoryManager.getInstance(repositoryAccessor);
File root = new File("Files/");
if (!(new File("Files/Repository").exists())){
System.out.println("*************************");
LocalRepository localRepository = new LocalRepository("Repository", root);
repositoryManager.addRepository(localRepository);
File[] files = root.listFiles();
for (File file : files){
copyFile(file, new File("Files/Repository/"+file.getName()));//copy files from directory to another
}
}
repositoryManager.save();
First run
Second run (immediately after the first run)
Before creation:
com.rapidminer.repository.resource.ResourceRepository@1b186cb
com.rapidminer.repository.db.DBRepository@87a4b
LocalRepository
*************************
After creation:
com.rapidminer.repository.resource.ResourceRepository@1b186cb
com.rapidminer.repository.db.DBRepository@87a4b
LocalRepository
Repository
Even if the folder of repository exists, it keep creating the the repository and ignoring the condition,
Before creation:
com.rapidminer.repository.resource.ResourceRepository@1b186cb
com.rapidminer.repository.db.DBRepository@87a4b
LocalRepository
Repository
*************************
After creation:
com.rapidminer.repository.resource.ResourceRepository@1b186cb
com.rapidminer.repository.db.DBRepository@87a4b
LocalRepository
Repository
Repository
So, I checked the path where the repository should exist, and I found NO folder called "Repository" after creating the repository. However, the strange thing is I got the new repository in the list returned by getRepositories() method! (shown in the output above)
If I restart Netbeans and RapidMiner, I found the new repositories exist in RapidMiner studio but not in my file system!!!
My question is: how can I save the changes of creating repository (or even delete repository) without closing Netbeans and RapidMiner?
I tried to use save() and load() mothods as they load and save xml configuration files, but it didn't make sense!
0
Answers
-
Hi,
the existance of a repository is stored in the repositories.xml file in the user_home/.RapidMiner folder. Note that repositories only create folders when needed, e.g. after creating a new repository it is empty, thus needing no actual folders yet. I'd change the condition to asking the RepositoryManager directly if a repository with a given name already exists before creating one. Callling RepositoryManager.getInstance().shutdown() ensures your newly created repository is stored in the aforementioned xml file and exists the next time you start your program.
Regards,
Marco0 -
This is clear, thanks!
Is there any way to get the absolute path of an exist repository?
I tried to use the following:
but it gave me:
String path1 = repositoryManager.getRepository("Repository").getLocation().getAbsoluteLocation();
String path2 = repositoryManager.getRepository("Repository").getLocation().toString();
//Repository0 -
Hi,
you can check which Repository is of the type LocalRepository and then call getFile() on the LocalRepository instance.
Regards,
Marco0 -
Hi,
I used this answer to integrate RapidMiner from FAQ:
I included all RapidMiner jar files into my application. however, the application still not running on a computer that doesn't have RapidMiner studio already installed!
1) Question: I want to integrate RapidMiner into my application! What do I have to do?
Answer: You need to either add the RapidMiner project as a library to your java project, or the RapidMiner library .jar files. RapidMiner sourcecode can be accessed via GIT here. For further sources (e.g. some extensions), check out our Scoureforge page here!
There are many errors appeared for me like:
However, I am creating the repository before setting up the process and run it as follows:
Exception in thread "main" com.rapidminer.repository.RepositoryException: Requested repository Local Repository does not exist.
at com.rapidminer.repository.RepositoryManager.getRepository(RepositoryManager.java:202)
at RapidMinerClassifier.RapidMinerTopicClassifier.<init>(RapidMinerTopicClassifier.java:47)
at RapidMinerClassifier.RapidMinerTopicClassifier.main(RapidMinerTopicClassifier.java:138)
So, how can I guarantee that the repository is created in order to copy the processes (built using RapidMiner GUI) to it?
RepositoryAccessor repositoryAccessor = null;
RepositoryManager repositoryManager = RepositoryManager.getInstance(repositoryAccessor);
if (repositoryManager.getRepository("Local Repository") != null) {
String sourcePath = new File("Files/").getPath();
LocalRepository localRepository = (LocalRepository) repositoryManager.getRepository("Local Repository");
ManageFiles.copyFolderContent(sourcePath, repositoryPath);
RepositoryManager.getInstance(repositoryAccessor).shutdown();
}
Note: the same code is working in a computer that has RapidMiner already installed on it and the repository is created from RapidMiner GUI.
Sorry for the asking a lot, but there is no detiled documentation to help.
Thanks!0 -
Hi,
when you debug your code, are you actually entering the if block which requires a "Local Repository" to exist? I suspect not, so you need to first check if it exists, if it does not create it and only after that copy your files.
Regards,
Marco0