diff --git a/metadata-service-dev-core/src/main/java/com/inspur/edp/lcm/metadata/core/MdRecentOpService.java b/metadata-service-dev-core/src/main/java/com/inspur/edp/lcm/metadata/core/MdRecentOpService.java index 28d517b00369f7b6e5425d15f918d7b7860c900e..257f4128bd5caf11eac11fd072535dca28f18cac 100644 --- a/metadata-service-dev-core/src/main/java/com/inspur/edp/lcm/metadata/core/MdRecentOpService.java +++ b/metadata-service-dev-core/src/main/java/com/inspur/edp/lcm/metadata/core/MdRecentOpService.java @@ -22,6 +22,7 @@ import com.inspur.edp.lcm.metadata.common.Utils; import com.inspur.edp.lcm.metadata.common.configuration.MetadataServiceHelper; import com.inspur.edp.lcm.metadata.core.dao.MdRecentOpDao; import com.inspur.edp.lcm.metadata.core.domain.GspMdRecentOp; +import com.inspur.edp.lcm.metadata.core.domain.GspMdRecentOpDto; import com.inspur.edp.lcm.metadata.devcommon.ManagerUtils; import com.inspur.edp.lcm.metadata.inner.api.WsService; import com.inspur.edp.lcm.metadata.inner.api.utils.WsUtils; @@ -112,7 +113,7 @@ public class MdRecentOpService { * @param boId 业务对象id * @return */ - public List getRecnetMdOp(String boId) { + public List getRecnetMdOp(String boId) { if (Objects.isNull(boId)) { return null; } @@ -132,7 +133,11 @@ public class MdRecentOpService { //根据可新建的元数据类型过滤 List typeList = loadShowMdRecentOpTypeList(); - return gspMdRecentOpList.stream().filter(opInfo -> typeList.contains(opInfo.getMdPath().substring(opInfo.getMdPath().lastIndexOf(".")))).sorted(Comparator.comparing(GspMdRecentOp::getLastModifiedTime).reversed()).collect(Collectors.toList()); + List mdRecentOpDtoList = gspMdRecentOpList.stream().filter(opInfo -> typeList.contains(opInfo.getMdPath().substring(opInfo.getMdPath().lastIndexOf(".")))) + .sorted(Comparator.comparing(GspMdRecentOp::getLastModifiedTime).reversed()) + .map(gspMdRecentOp -> new GspMdRecentOpDto(gspMdRecentOp)) + .collect(Collectors.toList()); + return mdRecentOpDtoList; } /** diff --git a/metadata-service-dev-core/src/main/java/com/inspur/edp/lcm/metadata/core/MetadataCoreManager.java b/metadata-service-dev-core/src/main/java/com/inspur/edp/lcm/metadata/core/MetadataCoreManager.java index 3b81cd441ae026ea265116906286d6c35dfe60c0..c37f5827cf9cf8258fcc52d7311ee858ed7e52fe 100644 --- a/metadata-service-dev-core/src/main/java/com/inspur/edp/lcm/metadata/core/MetadataCoreManager.java +++ b/metadata-service-dev-core/src/main/java/com/inspur/edp/lcm/metadata/core/MetadataCoreManager.java @@ -36,6 +36,7 @@ import com.inspur.edp.lcm.metadata.api.entity.MetadataPackage; import com.inspur.edp.lcm.metadata.api.entity.MetadataPackageHeader; import com.inspur.edp.lcm.metadata.api.entity.MetadataPackageVersion; import com.inspur.edp.lcm.metadata.api.entity.MetadataProject; +import com.inspur.edp.lcm.metadata.api.entity.MetadataProperties; import com.inspur.edp.lcm.metadata.api.entity.MetadataReference; import com.inspur.edp.lcm.metadata.api.entity.MetadataType; import com.inspur.edp.lcm.metadata.api.entity.OperationEnum; @@ -71,6 +72,7 @@ import com.inspur.edp.lcm.metadata.api.service.FileService; import com.inspur.edp.lcm.metadata.api.service.MdpkgService; import com.inspur.edp.lcm.metadata.api.service.MetadataRTService; import com.inspur.edp.lcm.metadata.api.service.RefCommonService; +import com.inspur.edp.lcm.metadata.common.SerializerUtils; import com.inspur.edp.lcm.metadata.common.context.RuntimeContext; import com.inspur.edp.metadata.rtcustomization.api.entity.Metadata4RefPageQueryParam; import com.inspur.edp.metadata.rtcustomization.api.entity.Metadata4RefPageQueryResult; @@ -684,11 +686,13 @@ public class MetadataCoreManager { String cacheMetadataNameKey = mdRelativePath + ".metadataName_"+currentLanguage; String cacheMetadataIdKey = mdRelativePath + ".metadataId"; String cacheMetadataCodeKey = mdRelativePath + ".metadataCode"; + String cacheMetadataPropertiesKey = mdRelativePath + ".metadataProperties"; // 缓存文件key集合中移除 deletedPropKeySet.remove(cacheLastChangeOnKey); deletedPropKeySet.remove(cacheMetadataNameKey); deletedPropKeySet.remove(cacheMetadataIdKey); deletedPropKeySet.remove(cacheMetadataCodeKey); + deletedPropKeySet.remove(cacheMetadataPropertiesKey); // 获取缓存中的 元数据更新时间 和元数据文件的更新时间 String lastChangeOn = properties.getProperty(cacheLastChangeOnKey); @@ -704,6 +708,7 @@ public class MetadataCoreManager { String metadataNameProperty = properties.getProperty(cacheMetadataNameKey); String metadataIdProperty = properties.getProperty(cacheMetadataIdKey); String metadataCodeProperty = properties.getProperty(cacheMetadataCodeKey); + String metadataProperties = properties.getProperty(cacheMetadataPropertiesKey); // 若文件更新时间未发生改变且 缓存中存在元数据名称(防止数据缺失),则使用缓存中的元数据名称 if (fileLastModify.equals(lastChangeOn) && StringUtils.hasLength(metadataNameProperty) @@ -712,6 +717,9 @@ public class MetadataCoreManager { metadataDto.setName(metadataNameProperty); metadataDto.setId(metadataIdProperty); metadataDto.setCode(metadataCodeProperty); + if (StringUtils.hasText(metadataProperties)) { + metadataDto.setProperties(SerializerUtils.deserialize(metadataProperties, MetadataProperties.class)); + } } else { if (".dbo".equals(extension)) { AbstractDatabaseObject databaseObject = databaseObjectService.getDatabaseObject(metadataPath); @@ -724,6 +732,7 @@ public class MetadataCoreManager { metadataDto.setName(metadataWithoutContent.getHeader().getName()); metadataDto.setId(metadataWithoutContent.getHeader().getId()); metadataDto.setCode(metadataWithoutContent.getHeader().getCode()); + metadataDto.setProperties(metadataWithoutContent.getProperties()); } // 标识缓存文件需要更新 isPropertisNeedChange = true; @@ -733,6 +742,9 @@ public class MetadataCoreManager { properties.setProperty(cacheMetadataNameKey, metadataDto.getName()); properties.setProperty(cacheMetadataIdKey, metadataDto.getId()); properties.setProperty(cacheMetadataCodeKey, metadataDto.getCode()); + if(metadataDto.getProperties() != null){ + properties.setProperty(cacheMetadataPropertiesKey, SerializerUtils.serialize(metadataDto.getProperties())); + } } // 若存在元数据名称过滤条件, 则判断是否符合 diff --git a/metadata-service-dev-core/src/main/java/com/inspur/edp/lcm/metadata/core/domain/GspMdRecentOpDto.java b/metadata-service-dev-core/src/main/java/com/inspur/edp/lcm/metadata/core/domain/GspMdRecentOpDto.java new file mode 100644 index 0000000000000000000000000000000000000000..2d4d4539b10ecf52dbb9130ed72aa7e257525aee --- /dev/null +++ b/metadata-service-dev-core/src/main/java/com/inspur/edp/lcm/metadata/core/domain/GspMdRecentOpDto.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.inspur.edp.lcm.metadata.core.domain; + +import com.inspur.edp.lcm.metadata.api.entity.MetadataProperties; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import java.time.LocalDateTime; + +/** + * 记录用户最近打开元数据操作 + */ +@Data +public class GspMdRecentOpDto { + private String id; + // 用户id + private String userId; + // 工作空间id + private String wsId; + // 业务对象id + private String boID; + // 元数据全路径 + private String mdPath; + // 元数据编号 + private String mdCode; + // 元数据名称 + private String mdName; + private LocalDateTime createdTime; + private LocalDateTime lastModifiedTime; + /** + * 元数据属性 + */ + private MetadataProperties properties; + + public GspMdRecentOpDto() { + } + public GspMdRecentOpDto(GspMdRecentOp gspMdRecentOp) { + this.id = gspMdRecentOp.getId(); + this.userId = gspMdRecentOp.getUserId(); + this.wsId = gspMdRecentOp.getWsId(); + this.boID = gspMdRecentOp.getBoID(); + this.mdPath = gspMdRecentOp.getMdPath(); + this.mdCode = gspMdRecentOp.getMdCode(); + this.mdName = gspMdRecentOp.getMdName(); + this.createdTime = gspMdRecentOp.getCreatedTime(); + this.lastModifiedTime = gspMdRecentOp.getLastModifiedTime(); + } + +} diff --git a/metadata-service-dev-webapi/src/main/java/com/inspur/edp/lcm/metadata/webapi/MetadataServiceWebApi.java b/metadata-service-dev-webapi/src/main/java/com/inspur/edp/lcm/metadata/webapi/MetadataServiceWebApi.java index aa22da5d48bfed86d261aadcca9d52fc1450524c..7ba946d256b6cb38ec9545982ac28a4f11692e97 100644 --- a/metadata-service-dev-webapi/src/main/java/com/inspur/edp/lcm/metadata/webapi/MetadataServiceWebApi.java +++ b/metadata-service-dev-webapi/src/main/java/com/inspur/edp/lcm/metadata/webapi/MetadataServiceWebApi.java @@ -48,6 +48,7 @@ import com.inspur.edp.lcm.metadata.common.util.ClassifierUtils; import com.inspur.edp.lcm.metadata.core.MdRecentOpService; import com.inspur.edp.lcm.metadata.core.MetadataProjectCoreService; import com.inspur.edp.lcm.metadata.core.domain.GspMdRecentOp; +import com.inspur.edp.lcm.metadata.core.domain.GspMdRecentOpDto; import com.inspur.edp.lcm.metadata.core.thread.BoGraphThreadLocalHolder; import com.inspur.edp.lcm.metadata.devcommon.ManagerUtils; import com.inspur.edp.lcm.metadata.spi.MdExtendRuleSerializer; @@ -293,8 +294,8 @@ public class MetadataServiceWebApi { @GET @Path("/mdrecentop") - public List getRecnetMdOp(@QueryParam(value = "boId") String boId, @DefaultValue("")@QueryParam(value = "path") String path) { - List recnetMdOpList = getMdRecentOpService().getRecnetMdOp(boId); + public List getRecnetMdOp(@QueryParam(value = "boId") String boId, @DefaultValue("")@QueryParam(value = "path") String path) { + List recnetMdOpList = getMdRecentOpService().getRecnetMdOp(boId); if(!CollectionUtils.isEmpty(recnetMdOpList) && StringUtils.hasText(path)){ List metadataListInBoForIDE = getMetadataService().getMetadataListInBoForIDE(path, null, null); if(!CollectionUtils.isEmpty(metadataListInBoForIDE)){ @@ -302,6 +303,7 @@ public class MetadataServiceWebApi { metadataListInBoForIDE.forEach(metadataDto -> { if(metadataDto.getRelativePath().equals(recnetMdOp.getMdPath())){ recnetMdOp.setMdName(metadataDto.getName()); + recnetMdOp.setProperties(metadataDto.getProperties()); return; } });