import {FeatureFlagsService, Features} from "../../../../shared/services/featureFlag/feature-flags.service";
import {NgRedux} from "@angular-redux/store";
import {AppState} from "../../../../shared/store/reducers";
+import {SharedTreeService} from "../shared.tree.service";
@Injectable()
export class ObjectToInstanceTreeService {
- constructor(private _objectToTreeService: ObjectToTreeService, private _errorMsgService: ErrorMsgService, private store: NgRedux<AppState>) {
+ constructor(private _objectToTreeService: ObjectToTreeService, private _errorMsgService: ErrorMsgService,
+ private store: NgRedux<AppState>, private _sharedTreeService: SharedTreeService) {
this.numberOfFailed = 0;
this.numberOfElements = 0;
this.numberOfFailed = 0;
this.numberOfElements = 0;
let _this = this;
- const firstLevelOptions: ILevelNodeInfo[] = _this._objectToTreeService.getFirstLevelOptions();
+ const serviceModelId:string = serviceInstance.modelInfo.modelVersionId;
+ const firstLevelOptions: ILevelNodeInfo[] = _this._objectToTreeService.getFirstLevelOptions(serviceInstance.isAlaCarte);
for (let option of firstLevelOptions) {
_.forOwn(serviceInstance[option.name], function (instance, modelName) {
- nodes.push(_this.getNodeInstance(modelName, null, instance, serviceHierarchy, option));
+ nodes.push(_this.getNodeInstance(modelName, null, instance, serviceHierarchy, option, serviceModelId));
});
}
return this.sortElementsByPosition(nodes);
* @param instance
* @param serviceHierarchy - The service Hierarchy store
* @param option
+ * @param serviceModelId
* @param parentType
****************************************************************/
- getNodeInstance(modelName: string, parentModel: any, instance: any, serviceHierarchy, option: ILevelNodeInfo, parentType ?: string) {
- const model = option.getModel(modelName, instance, serviceHierarchy);
-
- let optionalNodes = option.createInstanceTreeNode(instance, model, parentModel, modelName);
+ getNodeInstance(modelName: string, parentModel: any, instance: any, serviceHierarchy, option: ILevelNodeInfo, serviceModelId: string, parentType ?: string) {
+ const instanceModel = this._sharedTreeService.modelByIdentifiers(
+ serviceHierarchy, option.name,
+ this._sharedTreeService.modelUniqueNameOrId(instance), modelName
+ );
+ const model = option.getModel(instanceModel);
+
+ let optionalNodes = option.createInstanceTreeNode(instance, model, parentModel, modelName, serviceModelId);
this.increaseNumberOfFailed(optionalNodes);
this.increaseNumberOfExcitingElements();
let nodes: any[] = _.isArray(optionalNodes) ? optionalNodes : [optionalNodes];
for (let node of nodes) {
node = this.addingExtraDataToNode(node, modelName, parentModel, instance, serviceHierarchy, option, parentType);
- let children = this.addNextInstanceTreeNode(instance, model, option, node, serviceHierarchy);
+ let children = this.addNextInstanceTreeNode(instance, model, option, node, serviceHierarchy, serviceModelId);
if (!_.isNil(children) && children.length > 0) {
node.children = this.sortElementsByPosition(children);
}
node.parentType = !_.isNil(parentType) ? parentType : "";
node.updatePoistionFunction = option.updatePosition;
node.position = option.getNodePosition(instance, node.dynamicModelName);
+ node.modelTypeName = option.name;
node.getModel = option.getModel.bind(option);
node.getInfo = !_.isNil(option.getInfo) ? option.getInfo.bind(option) : ()=>{};
node.componentInfoType = option.componentInfoType;
* @param levelNodeInfo
* @param parentNode
* @param serviceHierarchy - The service Hierarchy store
+ * @param serviceModelId
****************************************************************/
- addNextInstanceTreeNode(parentInstance, parentModel, levelNodeInfo: ILevelNodeInfo, parentNode, serviceHierarchy): any[] {
+ addNextInstanceTreeNode(parentInstance, parentModel, levelNodeInfo: ILevelNodeInfo, parentNode, serviceHierarchy, serviceModelId: string): any[] {
if (!_.isNil(levelNodeInfo.childNames)&& levelNodeInfo.childNames.length > 0) {
const that = this;
parentNode.children = [];
let nextLevelNodeInfo = levelNodeInfo.getNextLevelObject.apply(that, [childName]);
Object.keys(parentInstance[childName]).map((modelName) => {
let nextLevelInstance = parentInstance[childName][modelName];
- let nodes: any[] | any = that.getNodeInstance(modelName, parentModel, nextLevelInstance, serviceHierarchy, nextLevelNodeInfo, parentType);
+ let nodes: any[] | any = that.getNodeInstance(modelName, parentModel, nextLevelInstance, serviceHierarchy, nextLevelNodeInfo, serviceModelId, parentType);
if (_.isArray(nodes)) {
parentNode.children = parentNode.children.concat(nodes);
} else {