protected internal virtual void LoadDefinitions(DeploymentEntity deployment, IList <TDefinitionEntity> definitions, Core.Model.Properties properties) { foreach (var definition in definitions) { var deploymentId = deployment.Id; var definitionKey = definition.Key; var persistedDefinition = FindDefinitionByDeploymentAndKey(deploymentId, definitionKey); HandlePersistedDefinition(definition, persistedDefinition, deployment, properties); } }
/// <summary> /// 添加definition到持久层及上下文中 /// </summary> /// <param name="deployment"></param> /// <param name="definition"></param> /// <param name="properties"></param> protected internal virtual void RegisterDefinition(DeploymentEntity deployment, TDefinitionEntity definition, Core.Model.Properties properties) { DeploymentCache deploymentCache = DeploymentCache; // Add to cache AddDefinitionToDeploymentCache(deploymentCache, definition); DefinitionAddedToDeploymentCache(deployment, definition, properties); // Add to deployment for further usage deployment.AddDeployedArtifact(definition); }
protected internal virtual IList <TDefinitionEntity> ParseDefinitionResources(DeploymentEntity deployment, Core.Model.Properties properties) { IList <TDefinitionEntity> definitions = new List <TDefinitionEntity>(); foreach (ResourceEntity resource in deployment.Resources.Values) { LOG.DebugProcessingResource(resource.Name); if (IsResourceHandled(resource)) { var r = TransformResource(deployment, resource, properties); foreach (var item in r) { definitions.Add(item); } //((List<TDefinitionEntity>)definitions).AddRange(); } } return(definitions); }
/// <summary> /// Called after a definition was added to the deployment cache. /// </summary> /// <param name="deployment"> the deployment of the definition </param> /// <param name="definition"> the definition entity </param> protected internal virtual void DefinitionAddedToDeploymentCache(DeploymentEntity deployment, TDefinitionEntity definition, Core.Model.Properties properties) { // do nothing }
protected internal virtual void HandlePersistedDefinition(TDefinitionEntity definition, TDefinitionEntity persistedDefinition, DeploymentEntity deployment, Core.Model.Properties properties) { PersistedDefinitionLoaded(deployment, definition, persistedDefinition); UpdateDefinitionByPersistedDefinition(deployment, definition, persistedDefinition); RegisterDefinition(deployment, definition, properties); }
protected internal virtual void PersistDefinitions(DeploymentEntity deployment, IList <TDefinitionEntity> definitions, Core.Model.Properties properties) { foreach (var definition in definitions) { var definitionKey = definition.Key; var tenantId = deployment.TenantId; var latestDefinition = FindLatestDefinitionByKeyAndTenantId(definitionKey, tenantId); UpdateDefinitionByLatestDefinition(deployment, definition, latestDefinition); PersistDefinition(definition); RegisterDefinition(deployment, definition, properties); } }
protected internal virtual void PostProcessDefinitions(DeploymentEntity deployment, IList <TDefinitionEntity> definitions, Core.Model.Properties properties) { if (deployment.IsNew)//新的,写入持久层及上下文中 { PersistDefinitions(deployment, definitions, properties); } else//已有,从持久层加载到上下文中 { LoadDefinitions(deployment, definitions, properties); } }
/// <summary> /// Transform the resource entity into definition entities. /// </summary> /// <param name="deployment"> the deployment the resources belongs to </param> /// <param name="resource"> the resource to transform </param> /// <returns> a list of transformed definition entities </returns> protected internal abstract IList <TDefinitionEntity> TransformDefinitions(DeploymentEntity deployment, ResourceEntity resource, Core.Model.Properties properties);
//解析 protected internal virtual ICollection <TDefinitionEntity> TransformResource(DeploymentEntity deployment, ResourceEntity resource, Core.Model.Properties properties) { var resourceName = resource.Name; var definitions = TransformDefinitions(deployment, resource, properties); foreach (var definition in definitions) { definition.ResourceName = resourceName; String diagramResourceName = GetDiagramResourceForDefinition(deployment, resourceName, definition, deployment.Resources); if (diagramResourceName != null) { definition.DiagramResourceName = diagramResourceName; } } return(definitions); }