本文整理汇总了Java中omero.model.FileAnnotation类的典型用法代码示例。如果您正苦于以下问题:Java FileAnnotation类的具体用法?Java FileAnnotation怎么用?Java FileAnnotation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileAnnotation类属于omero.model包,在下文中一共展示了FileAnnotation类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listFilesAttachedToContainerShouldConvertNullsToEmptyResult
import omero.model.FileAnnotation; //导入依赖的package包/类
@Test
public void listFilesAttachedToContainerShouldConvertNullsToEmptyResult() throws ServerError {
metadataPrxMock.returns(null).loadSpecifiedAnnotationsLinkedTo(
FileAnnotation.class.getName(),
null,
null,
ContainerType.project.getModelClass().getName(),
Lists.newArrayList(1L),
null);
Map<Long, Collection<FileAnnotationData>> result =
annotationService.listFilesAttachedToContainer(
ContainerType.project.getModelClass(), 1L);
assertNotNull(result, "Non-null results expected");
assertTrue(result.isEmpty(), "Empty results expected");
sessionMock.assertInvoked().getMetadataService();
metadataPrxMock.assertInvoked().loadSpecifiedAnnotationsLinkedTo(
FileAnnotation.class.getName(),
null,
null,
ContainerType.project.getModelClass().getName(),
Lists.newArrayList(1L),
null);
}
示例2: loadAllAnnotations
import omero.model.FileAnnotation; //导入依赖的package包/类
/**
* Gets all annotations existing in all projects from OMERO server.
*
* @param entry Object of class ServiceFactoryPrx.
* @return Returns a list of all all annotations contain in all projects from OMERO server.
* @throws ServerError root server exception
*/
private List<Annotation> loadAllAnnotations(ServiceFactoryPrx entry) throws ServerError {
long userId = entry.getAdminService().getEventContext().userId;
List<String> nsToInclude = new ArrayList<String>();
List<String> nsToExclude = new ArrayList<String>();
ParametersI param = new ParametersI();
param.exp(omero.rtypes.rlong(userId));
IMetadataPrx proxy = entry.getMetadataService();
// retrieve all annotations
List<Annotation> annotations = proxy.loadSpecifiedAnnotations(FileAnnotation.class.getName(), nsToInclude, nsToExclude, param);
return annotations;
}
示例3: listFilesAttachedToContainer
import omero.model.FileAnnotation; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
public Map<Long, Collection<FileAnnotationData>> listFilesAttachedToContainer(
Class<? extends IObject> containerClass,
Long containerId) throws ServerError {
Check.notNull(containerId, "containerId");
Check.notNull(containerClass, "containerClass");
Map<Long, Collection<FileAnnotationData>> result = Collections.emptyMap();
Map<Long, List<Annotation>> fileAnnotationsLinkedToContainers =
getSession().getMetadataService().loadSpecifiedAnnotationsLinkedTo(
FileAnnotation.class.getName(),
null,
null,
containerClass.getName(),
Lists.newArrayList(containerId),
null);
if (null != fileAnnotationsLinkedToContainers) {
result = DataObject.asPojos(fileAnnotationsLinkedToContainers);
}
log.debug("fileAnnotationsLinkedToContainers: id={} type={} list={}",
containerId, containerClass.getName(), result);
return result;
}
示例4: listFilesAttachedToContainerShouldReturnEmptyResultWhenNoFileFound
import omero.model.FileAnnotation; //导入依赖的package包/类
@Test
public void listFilesAttachedToContainerShouldReturnEmptyResultWhenNoFileFound() throws ServerError {
Map<Long, Collection<FileAnnotationData>> expected = Collections.emptyMap();
metadataPrxMock.returns(expected).loadSpecifiedAnnotationsLinkedTo(
FileAnnotation.class.getName(),
null,
null,
ContainerType.project.getModelClass().getName(),
Lists.newArrayList(1L),
null);
Map<Long, Collection<FileAnnotationData>> result =
annotationService.listFilesAttachedToContainer(
ContainerType.project.getModelClass(), 1L);
assertNotNull(result, "Non-null results expected");
assertTrue(result.isEmpty(), "Empty results expected");
sessionMock.assertInvoked().getMetadataService();
metadataPrxMock.assertInvoked().loadSpecifiedAnnotationsLinkedTo(
FileAnnotation.class.getName(),
null,
null,
ContainerType.project.getModelClass().getName(),
Lists.newArrayList(1L),
null);
}
示例5: listFilesAttachedToContainer
import omero.model.FileAnnotation; //导入依赖的package包/类
@Test
public void listFilesAttachedToContainer() throws ServerError {
// fixture
OriginalFileI originalFile = new OriginalFileI();
originalFile.setPath(omero.rtypes.rstring("original_file.csv"));
FileAnnotation fileAnnotation = new FileAnnotationI();
fileAnnotation.setFile(originalFile);
Map<Long, Collection<FileAnnotation>> fixture = Maps.newHashMap();
fixture.put(1L, Lists.newArrayList(fileAnnotation));
metadataPrxMock.returns(fixture).loadSpecifiedAnnotationsLinkedTo(
FileAnnotation.class.getName(),
null,
null,
ContainerType.project.getModelClass().getName(),
Lists.newArrayList(1L),
null);
Map<Long, Collection<FileAnnotationData>> result =
annotationService.listFilesAttachedToContainer(
ContainerType.project.getModelClass(), 1L);
assertNotNull(result, "Non-null results expected");
assertEquals(result.size(), 1, "1 result expected");
Collection<FileAnnotationData> values = result.get(1L);
FileAnnotationData pojo = getOnlyElement(values);
assertEquals(pojo.getContentAsString(), "original_file.csv", "Wrong annotation name");
sessionMock.assertInvoked().getMetadataService();
metadataPrxMock.assertInvoked().loadSpecifiedAnnotationsLinkedTo(
FileAnnotation.class.getName(),
null,
null,
ContainerType.project.getModelClass().getName(),
Lists.newArrayList(1L),
null);
}
示例6: readAllAttachedFiles
import omero.model.FileAnnotation; //导入依赖的package包/类
/**
* Gets all attached files in all projects from OMERO server.
*
* @param entry Object of class ServiceFactoryPrx.
* @param annotations Object of class ServiceFactoryPrx.
* @param INC Integer value represents the length of the byte stream.
* @throws ServerError root server exception.
* @throws FileNotFoundException
* @throws IOException
*/
private File readAllAttachedFiles(ServiceFactoryPrx entry, List<Annotation> annotations, int INC) throws ServerError, FileNotFoundException, IOException {
Iterator<Annotation> j = annotations.iterator();
Annotation annotation;
FileAnnotationData fa;
RawFileStorePrx store = null;
String tempDirectory = System.getProperty("java.io.tmpdir");
String downloadFolderName = "VizardousOmeroDownloads";
downloadFolder = new File(tempDirectory + File.separator + downloadFolderName);
if (!downloadFolder.exists()) {
downloadFolder.mkdirs(); // Create directory if it doesn't exist
} else {
// TODO Buggy
downloadFolder.deleteOnExit(); // Delete folder when VM terminates
}
while (j.hasNext()) {
annotation = j.next();
if ( annotation instanceof FileAnnotation ) {
fa = new FileAnnotationData((FileAnnotation) annotation);
if (!fa.getFileFormat().equals(FileAnnotationData.XML)) {
continue;
}
// Set location for files
File file = new File(downloadFolder, fa.getFileName());
// Create file if it does not exist
if (!file.createNewFile()) {
continue; // Don't open streams if it already exists
} else {
file.deleteOnExit(); // Delete the files when VM terminates
}
FileOutputStream stream = new FileOutputStream(file);
store = entry.createRawFileStore();
store.setFileId(fa.getFileID());
int offset = 0;
long size = fa.getFileSize();
try {
for (offset = 0; (offset+INC) < size;) {
stream.write(store.read(offset, INC));
offset += INC;
}
} finally {
stream.write(store.read(offset, (int) (size-offset)));
stream.close();
}
}
}
store.close();
return downloadFolder;
}