-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #381 from com-pas/develop
Update Main
- Loading branch information
Showing
25 changed files
with
1,247 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/DataTypeTemplatesService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// SPDX-FileCopyrightText: 2024 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons; | ||
|
||
import org.lfenergy.compas.scl2007b4.model.*; | ||
|
||
import static org.lfenergy.compas.sct.commons.util.CommonConstants.MOD_DO_NAME; | ||
import static org.lfenergy.compas.sct.commons.util.CommonConstants.STVAL_DA_NAME; | ||
|
||
public class DataTypeTemplatesService { | ||
|
||
final LnodeTypeService lnodeTypeService = new LnodeTypeService(); | ||
final DoTypeService doTypeService = new DoTypeService(); | ||
final DoService doService = new DoService(); | ||
|
||
/** | ||
* verify if DO(name=Mod)/DA(name=stVal) exists in DataTypeTemplate | ||
* @param dtt TDataTypeTemplates where Data object and Data attribute exists | ||
* @param lNodeTypeId LNode Type ID where Data object exists | ||
* DataTypeTemplates model : | ||
* <DataTypeTemplates> | ||
* <LNodeType lnClass="LNodeTypeClass" id="LNodeTypeID"> | ||
* <DO name="Mod" type="DOModTypeID" ../> | ||
* </LNodeType> | ||
* ... | ||
* <DOType cdc="DOTypeCDC" id="DOModTypeID"> | ||
* <DA name="stVal" ../> | ||
* </DOType> | ||
* </DataTypeTemplates> | ||
* @return true if the Data Object (Mod) and Data attribute (stVal) present, false otherwise | ||
*/ | ||
public boolean isDoModAndDaStValExist(TDataTypeTemplates dtt, String lNodeTypeId) { | ||
return lnodeTypeService.findLnodeType(dtt, lNodeType -> lNodeTypeId.equals(lNodeType.getId())) | ||
.map(lNodeType -> doService.findDo(lNodeType, tdo -> MOD_DO_NAME.equals(tdo.getName())) | ||
.map(tdo -> doTypeService.findDoType(dtt, doType -> tdo.getType().equals(doType.getId())) | ||
.map(doType -> doType.getSDOOrDA().stream() | ||
.filter(sdoOrDa -> sdoOrDa.getClass().equals(TDA.class)) | ||
.map(TDA.class::cast) | ||
.anyMatch(tda -> STVAL_DA_NAME.equals(tda.getName()))) | ||
.orElse(false)) | ||
.orElse(false)) | ||
.orElse(false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.