DXL DOORs Нужна помощь в применении фильтра с помощью петли

Итак, я только что понял, что текущий фильтр, который я использовал, работает правильно, только если первая строка, которую он находит, неверна.

Module m = current
Object o = current
Filter f

load view "Standard view"

//column attribute Object Type
insert(column 3)
attribute(column 3, "Object Type")
width(column 3, 100)

f1 = attribute "Object Type" == "Requirement"
f2 = attribute "Object Type" == "Derived Requirement"
f3 = contains(attribute "Object Text", "(Testing) ", true)

for o in m do 
{
f = (f1 || f2) && !(f3)
}
set f
filtering on
refresh current

Пример: это будет моя текущая таблица (не очень хорош в создании таблицы)

ID|        Module Information            |Object Type
__|______________________________________|____________________
1 | (Teting) this is the incorrect format| Requirements 
__|______________________________________|____________________ 
2 | (Testing) this is also correct format| Derived Requirements  
  | (Test) this is incorrect format      |
__|______________________________________|____________________
3 | (Testing) this is the correct format | Requirements  
  | (Testing) this is the correct format |
__|______________________________________|____________________
4 | (Testing) this is the correct format | Requirements  
  | (Teting) this is incorrect format    |
__|______________________________________|____________________

Поэтому, если бы я запустил свой скрипт здесь, он показал бы мне только

ID|        Module Information            |Object Type
__|______________________________________|____________________
1 | (Teting) this is the incorrect format| Requirements 

и не то, что я надеялся, это покажет мне:

ID|        Module Information            |Object Type
__|______________________________________|____________________
1 | (Teting) this is the incorrect format| Requirements 
__|______________________________________|____________________ 
2 | (Testing) this is also correct format| Derived Requirements  
  | (Test) this is incorrect format      |
__|______________________________________|____________________
4 | (Testing) this is the correct format | Requirements  
  | (Teting) this is incorrect format    |
__|______________________________________|____________________

Итак, как мне показать правильный вид? Я предполагаю, что это как-то связано с зацикливанием
фильтра "Текст объекта содержит", но я не уверен, как я могу это сделать.


person James Swan    schedule 25.10.2016    source источник
comment
Любая информация о том, как поступить с этим, будет оценена   -  person James Swan    schedule 26.10.2016


Ответы (1)


Насколько я могу судить, ваш DXL работает отлично. Однако вы можете немного изменить свой вопрос.

Во-первых, ваш DXL проверяет, является ли Object Type «Требованием» или «Производным требованием», тогда как ваши тестовые данные содержат «Требованиеs» и «Производное требованиеs».

Во-вторых, ваш код f = (f1 || f2) && !(f3) проверяет, является ли тип объекта либо Requirement, либо Derived Requirement, а также не содержит "(Testing)" нигде в тексте объекта. Ваш код делает это и, таким образом, не даст вам ожидаемого результата, так как последние три объекта содержат текст "(Testing)".

Я предполагаю, что вам нужно проверить, что не все строки содержат "(Testing)", а не ни одного. В этом случае код будет примерно таким:

Module m = current
Object o = current
Regexp REGEX_INVALID = regexp2("\\(Testing\\)")
Regexp REGEX_VALID = regexp2("\\(.*\\)")
Buffer searchText = create
Buffer original = create

//Returns true if Object Text contains any one or more pairs of brackets that do not match (Testing)
bool filterObjectText(string objText)
{
    searchText = objText
    original = objText

    while(REGEX_VALID searchText)
    {
        if (REGEX_INVALID searchText)
        {
            int offset = null
            int subStrLength = null
            findPlainText(tempStringOf(searchText), "(Testing)", offset, subStrLength, true)
            searchText = searchText[offset + subStrLength:]
        }
        else
        {
            return true
        }
    }

    return false
}

filtering off

for o in m do 
{
    string objectType = o."Object Type"
    string objectText = o."Object Text"

    if ((objectType == "Requirements" || objectType == "Derived Requirements") && filterObjectText(objectText))
    {
        accept o
    }
    else
    {
        reject o
    }
}

filtering on
refresh current
person J Lewis    schedule 04.07.2017