本文整理汇总了Java中com.rapidminer.repository.BlobEntry类的典型用法代码示例。如果您正苦于以下问题:Java BlobEntry类的具体用法?Java BlobEntry怎么用?Java BlobEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlobEntry类属于com.rapidminer.repository包,在下文中一共展示了BlobEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBlobEntry
import com.rapidminer.repository.BlobEntry; //导入依赖的package包/类
@Override
public BlobEntry createBlobEntry(String name) throws RepositoryException {
// check for possible invalid name
if (!RepositoryLocation.isNameValid(name)) {
throw new RepositoryException(
I18N.getMessage(I18N.getErrorBundle(), "repository.illegal_entry_name", name, getLocation()));
}
BlobEntry entry = null;
acquireWriteLock();
try {
ensureLoaded();
entry = new SimpleBlobEntry(name, this, getRepository());
data.add(entry);
} finally {
releaseWriteLock();
}
if (entry != null) {
getRepository().fireEntryAdded(entry, this);
}
return entry;
}
示例2: createBlobEntry
import com.rapidminer.repository.BlobEntry; //导入依赖的package包/类
@Override
public BlobEntry createBlobEntry(String name) throws RepositoryException {
// check for possible invalid name
if (!RepositoryLocation.isNameValid(name)) {
throw new RepositoryException(I18N.getMessage(I18N.getErrorBundle(), "repository.illegal_entry_name", name, getLocation()));
}
EntryResponse response = getRepository().getRepositoryService().createBlob(getPath(), name);
RemoteBlobEntry newBlob = new RemoteBlobEntry(response, this, getRepository());
if (this.entries != null) {
entries.add(newBlob);
Collections.sort(entries, nameComparator);
getRepository().fireEntryAdded(newBlob, this);
}
return newBlob;
}
示例3: getImportThread
import com.rapidminer.repository.BlobEntry; //导入依赖的package包/类
@Override
protected ProgressThread getImportThread(final RepositoryLocation entryLocation, final Folder parent) {
error = false;
ProgressThread importWorker = new ProgressThread("import_data") {
@Override
public void run() {
try {
parent.createBlobEntry(entryLocation.getName());
Entry newEntry = entryLocation.locateEntry();
if (newEntry == null) {
throw new RepositoryException("Creation of blob entry failed.");
}
BlobEntry blob = (BlobEntry) newEntry;
try (FileInputStream fileInputStream = new FileInputStream(source.getLocation().toFile());
OutputStream outputStream = blob.openOutputStream(getChooser().getMediaType())) {
byte[] buffer = new byte[1024 * 20];
int length;
while ((length = fileInputStream.read(buffer)) != -1) {
if (isCancelled()) {
break;
}
outputStream.write(buffer, 0, length);
}
outputStream.flush();
}
if (isCancelled()) {
blob.delete();
}
} catch (RepositoryException | IOException e) {
error = true;
SwingTools.showSimpleErrorMessage("import_blob_failed", e, e.getMessage());
}
}
};
importWorker.setIndeterminate(true);
return importWorker;
}
示例4: save
import com.rapidminer.repository.BlobEntry; //导入依赖的package包/类
@Override
public void save(BlobEntry entry) {
try {
save(entry.openOutputStream(LIBRARY_MIME_TYPE));
} catch (RepositoryException e) {
SwingTools.showSimpleErrorMessage("cannot_access_repository", e);
}
}
示例5: loadLibrary
import com.rapidminer.repository.BlobEntry; //导入依赖的package包/类
/**
* This method will load a library that has been stored into the given entry.
*
*/
public static OperatorLibrary loadLibrary(BlobEntry entry) throws Exception {
Document document = XMLTools.parse(entry.openInputStream());
String className = document.getDocumentElement().getAttribute(ATTRIBUTE_CLASS);
Constructor<?> constructor = Class.forName(className, false, Plugin.getMajorClassLoader()).getConstructor(
String.class, Element.class);
return (OperatorLibrary) constructor.newInstance(entry.getLocation().getAbsoluteLocation(),
document.getDocumentElement());
}
示例6: createBlobEntry
import com.rapidminer.repository.BlobEntry; //导入依赖的package包/类
@Override
public BlobEntry createBlobEntry(String name) throws RepositoryException {
// check for possible invalid name
if (!RepositoryLocation.isNameValid(name)) {
throw new RepositoryException(I18N.getMessage(I18N.getErrorBundle(), "repository.illegal_entry_name", name,
getLocation()));
}
BlobEntry entry = new SimpleBlobEntry(name, this, getRepository());
if (data != null) {
data.add(entry);
}
getRepository().fireEntryAdded(entry, this);
return entry;
}
示例7: getImportThread
import com.rapidminer.repository.BlobEntry; //导入依赖的package包/类
@Override
protected ProgressThread getImportThread(final RepositoryLocation entryLocation, final Folder parent) {
error = false;
ProgressThread importWorker = new ProgressThread("import_data") {
@Override
public void run() {
try {
parent.createBlobEntry(entryLocation.getName());
Entry newEntry = entryLocation.locateEntry();
if (newEntry == null) {
throw new RepositoryException("Creation of blob entry failed.");
}
BlobEntry blob = (BlobEntry) newEntry;
try (FileInputStream fileInputStream = new FileInputStream(source.getLocation().toFile());
OutputStream outputStream = blob.openOutputStream(getChooser().getMediaType())) {
byte[] buffer = new byte[1024 * 20];
int length;
while ((length = fileInputStream.read(buffer)) != -1) {
if (isCancelled()) {
break;
}
outputStream.write(buffer, 0, length);
}
outputStream.flush();
}
if (isCancelled()) {
blob.delete();
}
} catch (RepositoryException | IOException e) {
error = true;
SwingTools.showSimpleErrorMessage(wizard.getDialog(), "import_blob_failed", e, e.getMessage());
}
}
};
importWorker.setIndeterminate(true);
return importWorker;
}
示例8: save
import com.rapidminer.repository.BlobEntry; //导入依赖的package包/类
@Override
public void save(BlobEntry entry) {
try {
save(entry.openOutputStream(LIBRARY_MIME_TYPE));
} catch (RepositoryException e) {
SwingTools.showSimpleErrorMessage("cannot_access_repository", e);
}
}
示例9: loadLibrary
import com.rapidminer.repository.BlobEntry; //导入依赖的package包/类
/**
* This method will load a library that has been stored into the
* given entry.
*
*/
public static OperatorLibrary loadLibrary(BlobEntry entry) throws Exception {
Document document = XMLTools.parse(entry.openInputStream());
String className = document.getDocumentElement().getAttribute(ATTRIBUTE_CLASS);
Constructor<?> constructor = Class.forName(className, false, Plugin.getMajorClassLoader()).getConstructor(String.class, Element.class);
return (OperatorLibrary) constructor.newInstance(entry.getLocation().getAbsoluteLocation(), document.getDocumentElement());
}
示例10: createBlobEntry
import com.rapidminer.repository.BlobEntry; //导入依赖的package包/类
@Override
public BlobEntry createBlobEntry(String name) throws RepositoryException {
// check for possible invalid name
if (!RepositoryLocation.isNameValid(name)) {
throw new RepositoryException(I18N.getMessage(I18N.getErrorBundle(), "repository.illegal_entry_name", name, getLocation()));
}
BlobEntry entry = new SimpleBlobEntry(name, this, getRepository());
if (data != null) {
data.add(entry);
}
getRepository().fireEntryAdded(entry, this);
return entry;
}
示例11: ProcessRootOperator
import com.rapidminer.repository.BlobEntry; //导入依赖的package包/类
/** Creates a new process operator without reference to an process. */
public ProcessRootOperator(OperatorDescription description) {
this(description, null);
getTransformer().addRuleAtBeginning(new MDTransformationRule() {
@Override
public void transformMD() {
if (getProcess() == null) {
// can happen during loading
return;
}
ProcessContext context = getProcess().getContext();
if (getProcess().getProcessState() == Process.PROCESS_STATE_STOPPED) {
// We apply macros only if process is stopped so we dont break the process
// in case we have a meta data propagation while process runs (in which
// case it should be disabled anyway
getProcess().applyContextMacros();
}
for (int i = 0; i < context.getInputRepositoryLocations().size(); i++) {
String location = context.getInputRepositoryLocations().get(i);
if (location != null && location.length() > 0) {
if (i < getSubprocess(0).getInnerSources().getNumberOfPorts()) {
OutputPort port = getSubprocess(0).getInnerSources().getPortByIndex(i);
RepositoryLocation loc;
try {
loc = getProcess().resolveRepositoryLocation(location);
} catch (Exception e1) {
addError(new SimpleProcessSetupError(Severity.WARNING, getPortOwner(),
"repository_access_error", location, e1.toString()));
return;
}
try {
Entry entry = loc.locateEntry();
if (entry == null) {
addError(new SimpleProcessSetupError(Severity.WARNING, getPortOwner(),
"repository_location_does_not_exist", location));
} else if (entry instanceof IOObjectEntry) {
port.deliverMD(((IOObjectEntry) entry).retrieveMetaData());
} else if (entry instanceof BlobEntry) {
port.deliverMD(new MetaData(FileObject.class));
} else {
addError(new SimpleProcessSetupError(Severity.WARNING, getPortOwner(),
"repository_location_wrong_type", location, entry.getType(), "IOObject"));
}
} catch (RepositoryException e) {
addError(new SimpleProcessSetupError(Severity.WARNING, getPortOwner(),
"repository_access_error", location, e.getMessage()));
}
}
}
}
}
});
}
示例12: getType
import com.rapidminer.repository.BlobEntry; //导入依赖的package包/类
@Override
public String getType() {
return BlobEntry.TYPE_NAME;
}
示例13: createBlobEntry
import com.rapidminer.repository.BlobEntry; //导入依赖的package包/类
@Override
public BlobEntry createBlobEntry(String name) throws RepositoryException {
throw new RepositoryException("This is a read-only sample repository. Cannot create new entries.");
}
示例14: selectBlobEntryForStoring
import com.rapidminer.repository.BlobEntry; //导入依赖的package包/类
/**
* This method will show an Repository Entry chooser and returns the entry if the user has
* chosen an unused entry or confirmed to overwrite the existing. Otherwise null is returned.
*/
public static BlobEntry selectBlobEntryForStoring() {
String selectEntry = RepositoryLocationChooser.selectEntry(null, null, true);
return createBlobEntry(selectEntry);
}
示例15: loadInitialData
import com.rapidminer.repository.BlobEntry; //导入依赖的package包/类
/** Loads results from the repository if specified in the {@link ProcessContext}.
* @param firstPort Specifies the first port which is read from the ProcessContext. This
* enables the possibility to skip ports for which input is already specified via
* the input parameter of the run() method.
*/
protected void loadInitialData(int firstPort) throws UserError {
ProcessContext context = getContext();
if (context.getInputRepositoryLocations().isEmpty()) {
return;
}
getLogger().info("Loading initial data" + (firstPort > 0 ? " (starting at port " + (firstPort + 1) + ")" : "") + ".");
for (int i = firstPort; i < context.getInputRepositoryLocations().size(); i++) {
String location = context.getInputRepositoryLocations().get(i);
if (location == null || location.length() == 0) {
getLogger().fine("Input #" + (i + 1) + " not specified.");
} else {
if (i >= rootOperator.getSubprocess(0).getInnerSources().getNumberOfPorts()) {
getLogger().warning("No input port available for process input #" + (i + 1) + ": " + location);
} else {
OutputPort port = rootOperator.getSubprocess(0).getInnerSources().getPortByIndex(i);
RepositoryLocation loc;
try {
loc = resolveRepositoryLocation(location);
} catch (MalformedRepositoryLocationException e1) {
throw e1.makeUserError(rootOperator);
}
try {
Entry entry = loc.locateEntry();
if (entry == null) {
throw new UserError(rootOperator, 312, loc, "Entry " + loc + " does not exist.");
}
if (entry instanceof IOObjectEntry) {
getLogger().info("Assigning " + loc + " to input port " + port.getSpec() + ".");
port.deliver(((IOObjectEntry) entry).retrieveData(null));
} else if (entry instanceof BlobEntry) {
getLogger().info("Assigning " + loc + " to input port " + port.getSpec() + ".");
port.deliver(new RepositoryBlobObject(loc));
} else {
getLogger().info("Cannot assigning " + loc + " to input port " + port.getSpec() + ": Repository location does not reference an IOObject entry.");
throw new UserError(rootOperator, 312, loc, "Not an IOObject entry.");
}
} catch (RepositoryException e) {
throw new UserError(rootOperator, e, 312, loc, e.getMessage());
}
}
}
}
}