use of com.epam.pipeline.controller.vo.EntityVO in project cloud-pipeline by epam.
the class MetadataManager method updateMetadataItemKeys.
@Transactional(propagation = Propagation.REQUIRED)
public MetadataEntry updateMetadataItemKeys(MetadataVO metadataVO) {
validateMetadata(metadataVO);
EntityVO entity = metadataVO.getEntity();
checkEntityExistence(entity.getEntityId(), entity.getEntityClass());
MetadataEntry metadataToSave = metadataEntryMapper.toMetadataEntry(metadataVO);
MetadataEntry existingMetadata = listMetadataItem(metadataToSave.getEntity(), false);
if (existingMetadata == null) {
LOGGER.debug("Could not find such metadata. A new one will be created.");
metadataDao.registerMetadataItem(metadataToSave);
} else {
existingMetadata.getData().putAll(metadataToSave.getData());
metadataDao.uploadMetadataItem(existingMetadata);
}
return metadataDao.loadMetadataItem(entity);
}
use of com.epam.pipeline.controller.vo.EntityVO in project cloud-pipeline by epam.
the class MetadataManager method findMetadataEntryByNameOrId.
public MetadataEntry findMetadataEntryByNameOrId(String identifier, AclClass entityClass) {
MetadataEntry metadataEntry = new MetadataEntry();
EntityVO entity = new EntityVO(loadEntityId(identifier, entityClass), entityClass);
metadataEntry.setEntity(entity);
metadataEntry.setData(Collections.emptyMap());
return metadataEntry;
}
use of com.epam.pipeline.controller.vo.EntityVO in project cloud-pipeline by epam.
the class FolderCrudManager method loadByNameOrId.
/**
* Tries to find a {@link Folder} entity by some pathOrIdentifier.
* If identifier is a number, it is interpreted as ID and will be loaded from DB by primary key.
* Otherwise pathOrIdentifier is interpreted as full path to folder like:
* /root/parent/folder-name
* and method will try to resolve folder hierarchy from this path.
* @param pathOrIdentifier specifies folder to look for
* @return {@link Folder} entity if present
* @throws IllegalArgumentException if {@link Folder} pathOrIdentifier not found
*/
@Override
public Folder loadByNameOrId(String pathOrIdentifier) {
Folder folder = null;
String path = pathOrIdentifier;
try {
folder = folderDao.loadFolder(Long.parseLong(path));
} catch (NumberFormatException e) {
LOGGER.trace(e.getMessage(), e);
}
if (folder == null) {
Long parentId = null;
if (path.startsWith("/")) {
path = path.substring(1);
}
if (path.endsWith("/")) {
path = path.substring(0, path.length() - 1);
}
String[] pathComponents = path.split("/");
for (String name : pathComponents) {
folder = loadByNameAndParentId(name, parentId);
if (folder == null) {
break;
} else {
parentId = folder.getId();
}
}
}
Assert.notNull(folder, messageHelper.getMessage(MessageConstants.ERROR_FOLDER_NOT_FOUND, path));
folder.setHasMetadata(this.metadataManager.hasMetadata(new EntityVO(folder.getId(), AclClass.FOLDER)));
return folder;
}
use of com.epam.pipeline.controller.vo.EntityVO in project cloud-pipeline by epam.
the class FolderCrudManager method load.
/**
* Loads {@link Folder} specified by id parameter
* @param id to find
* @return {@link Folder} entity if present
* @throws IllegalArgumentException if {@link Folder} id not found
*/
@Override
public Folder load(Long id) {
Folder folder = folderDao.loadFolder(id);
Assert.notNull(folder, messageHelper.getMessage(MessageConstants.ERROR_FOLDER_NOT_FOUND, id));
folder.setHasMetadata(metadataManager.hasMetadata(new EntityVO(id, AclClass.FOLDER)));
return folder;
}
use of com.epam.pipeline.controller.vo.EntityVO in project cloud-pipeline by epam.
the class PipelineManager method loadByRepoUrl.
public Pipeline loadByRepoUrl(String url) {
Optional<Pipeline> loadedPipeline = pipelineDao.loadPipelineByRepoUrl(url);
Pipeline pipeline = loadedPipeline.orElseThrow(() -> new IllegalArgumentException(messageHelper.getMessage(MessageConstants.ERROR_PIPELINE_WITH_URL_NOT_FOUND, url)));
setCurrentVersion(pipeline);
pipeline.setHasMetadata(this.metadataManager.hasMetadata(new EntityVO(pipeline.getId(), AclClass.PIPELINE)));
return pipeline;
}
Aggregations