本文整理汇总了Java中com.haulmont.cuba.core.entity.FileDescriptor.setName方法的典型用法代码示例。如果您正苦于以下问题:Java FileDescriptor.setName方法的具体用法?Java FileDescriptor.setName怎么用?Java FileDescriptor.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.haulmont.cuba.core.entity.FileDescriptor
的用法示例。
在下文中一共展示了FileDescriptor.setName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadImageFromFileStorage
import com.haulmont.cuba.core.entity.FileDescriptor; //导入方法依赖的package包/类
private void loadImageFromFileStorage() {
// A file descriptor entity is usually stored in the database and referenced by an attribute of your data
// model entity. Here we simply create it for the purpose of the example.
FileDescriptor imageFile = metadata.create(FileDescriptor.class);
imageFile.setId(UUID.fromString("61a6a1ee-f13a-f44f-0201-c2f9b3288305"));
imageFile.setName("platform-logo.png");
imageFile.setCreateDate(new Date(1427857200503L));
imageFile.setExtension("png");
byte[] bytes = null;
try {
bytes = fileStorageService.loadFile(imageFile);
} catch (FileStorageException e) {
showNotification("Unable to load image file", NotificationType.HUMANIZED);
}
if (bytes != null) {
imageFromFileStorage.setSource(imageFile.getName(), new ByteArrayInputStream(bytes));
imageFromFileStorage.setType(Embedded.Type.IMAGE);
} else {
imageFromFileStorage.setVisible(false);
}
}
示例2: getFileDescriptor
import com.haulmont.cuba.core.entity.FileDescriptor; //导入方法依赖的package包/类
@Override
public FileDescriptor getFileDescriptor(UUID fileId, String name) {
File file = getFile(fileId);
if (file == null) {
return null;
}
Metadata metadata = AppBeans.get(Metadata.NAME);
FileDescriptor fDesc = metadata.create(FileDescriptor.class);
fDesc.setSize(file.length());
fDesc.setExtension(FilenameUtils.getExtension(name));
fDesc.setName(name);
fDesc.setCreateDate(timeSource.currentTimestamp());
return fDesc;
}
示例3: setUp
import com.haulmont.cuba.core.entity.FileDescriptor; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
fileDescr = new FileDescriptor();
fileDescr.setCreateDate(new Date());
fileDescr.setSize((long) FILE_CONTENT.length());
fileDescr.setName("AmazonFileStorageTest");
fileDescr.setExtension("txt");
fileDescr2 = new FileDescriptor();
fileDescr2.setCreateDate(new Date());
fileDescr2.setSize((long) FILE_CONTENT.length());
fileDescr2.setName("AmazonFileStorageTest");
fileStorageAPI = new AmazonS3FileStorage();
fileStorageAPI.amazonS3Config = AppBeans.get(Configuration.class).getConfig(AmazonS3Config.class);
}
示例4: createFileDescriptor
import com.haulmont.cuba.core.entity.FileDescriptor; //导入方法依赖的package包/类
protected FileDescriptor createFileDescriptor(@Nullable String fileName, long size) {
FileDescriptor fd = metadata.create(FileDescriptor.class);
if (Strings.isNullOrEmpty(fileName)) {
fileName = fd.getId().toString();
}
fd.setName(fileName);
fd.setExtension(FilenameUtils.getExtension(fileName));
fd.setSize(size);
fd.setCreateDate(timeSource.currentTimestamp());
return fd;
}
示例5: getFileDescriptor
import com.haulmont.cuba.core.entity.FileDescriptor; //导入方法依赖的package包/类
protected FileDescriptor getFileDescriptor(HttpServletRequest request, HttpServletResponse response) throws IOException {
String name = request.getParameter("name");
if (name == null) {
log.error("'name' request parameter is not specified");
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return null;
}
String ext = request.getParameter("ext");
if (ext == null) {
log.error("'ext' request parameter is not specified");
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return null;
}
String size = request.getParameter("size");
FileDescriptor fd = metadata.create(FileDescriptor.class);
fd.setName(name);
fd.setExtension(ext);
fd.setCreateDate(timeSource.currentTimestamp());
if (size != null) {
fd.setSize(Long.parseLong(size));
}
return fd;
}
示例6: createAttachmentFileDescriptor
import com.haulmont.cuba.core.entity.FileDescriptor; //导入方法依赖的package包/类
protected FileDescriptor createAttachmentFileDescriptor(SendingAttachment attachment) {
FileDescriptor contentFile = metadata.create(FileDescriptor.class);
contentFile.setCreateDate(timeSource.currentTimestamp());
contentFile.setName(attachment.getName());
contentFile.setExtension(FilenameUtils.getExtension(attachment.getName()));
contentFile.setSize((long) attachment.getContent().length);
return contentFile;
}
示例7: createBodyFileDescriptor
import com.haulmont.cuba.core.entity.FileDescriptor; //导入方法依赖的package包/类
protected FileDescriptor createBodyFileDescriptor(SendingMessage message, byte[] bodyBytes) {
FileDescriptor contentTextFile = metadata.create(FileDescriptor.class);
contentTextFile.setCreateDate(timeSource.currentTimestamp());
contentTextFile.setName("Email_" + message.getId() + "." + BODY_FILE_EXTENSION);
contentTextFile.setExtension(BODY_FILE_EXTENSION);
contentTextFile.setSize((long) bodyBytes.length);
return contentTextFile;
}
示例8: onBeforeInsert
import com.haulmont.cuba.core.entity.FileDescriptor; //导入方法依赖的package包/类
@Override
public void onBeforeInsert(Server entity, EntityManager entityManager) {
EntityManager em = persistence.getEntityManager();
FileDescriptor related = new FileDescriptor();
related.setName("Related");
System.out.println(">>>>> persist related: " + related.getId());
em.persist(related);
entity.setData(related.getId().toString());
}
示例9: onBeforeUpdate
import com.haulmont.cuba.core.entity.FileDescriptor; //导入方法依赖的package包/类
@Override
public void onBeforeUpdate(Server entity, EntityManager entityManager) {
EntityManager em = persistence.getEntityManager();
UUID relatedId = UUID.fromString(entity.getData());
FileDescriptor related = em.find(FileDescriptor.class, relatedId);
if (related != null) {
related.setName("Related updated");
System.out.println(">>>>> update related: " + relatedId);
} else
throw new RuntimeException("Related not found: " + relatedId);
}
示例10: fileUploadSucceed
import com.haulmont.cuba.core.entity.FileDescriptor; //导入方法依赖的package包/类
@Override
public void fileUploadSucceed(FileUploadField.FileUploadSucceedEvent e) {
FileDescriptor fd = getItem();
fd.setName(uploadField.getFileName());
fd.setCreateDate(timeSource.currentTimestamp());
fd.setExtension(FilenameUtils.getExtension(uploadField.getFileName()));
FileUploadingAPI fileUploading = AppBeans.get(FileUploadingAPI.NAME);
File file = fileUploading.getFile(uploadField.getFileId());
fd.setSize(file.length());
okBtn.setEnabled(true);
nameField.requestFocus();
needSave = true;
}