ENTAXY-634 release version 1.9.0
This commit is contained in:
@ -1,201 +1,175 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
ЛИЦЕНЗИЯ ОГРАНИЧЕННОГО ПРИМЕНЕНИЯ
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
Настоящий документ устанавливает для Пользователя условия применения Базовой (некоммерческой)
|
||||
версии лицензии для пробного использования программного обеспечения ENTAXY, принадлежащего
|
||||
Правообладателю – Обществу с ограниченной ответственностью "ЕМДЕВ" (ОГРН 1057810026658, ИНН
|
||||
7813313860, юридический адрес: 197022, Россия, г. Санкт-Петербург, ул. Профессора Попова,
|
||||
д. 23, литера В, помещение 3Н), расположенной в сети Интернет по адресу
|
||||
https://www.emdev.ru/about (далее - Компания).
|
||||
|
||||
1. Definitions.
|
||||
Используя или получая доступ к Программному обеспечению, или нажав «Я согласен с Условиями»
|
||||
(или аналогичную кнопку или флажок) после загрузки или установки Программного обеспечения,
|
||||
Пользователь выражает свое согласие на обязательность условий и ограничений, изложенных в
|
||||
настоящем документе, в противном случае, он должен не использовать или не получать доступ
|
||||
к Программному обеспечению.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
1. ТЕРМИНЫ И ОПРЕДЕЛЕНИЯ
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
a) ПО – Программное обеспечение, интеграционная шина «ЭНТАКСИ» (ENTAXY) в любой ее версии
|
||||
или редакции, исключительные права на которую принадлежат Правообладателю.
|
||||
b) Правообладатель (Компания) – ООО «ЕМДЕВ», ОГРН 1057810026658, ИНН 7813313860, исключительные
|
||||
права которого подтверждаются Свидетельством о государственной регистрации в Реестре программ
|
||||
для ЭВМ № 2021610848 от 19.01.2021 года.
|
||||
c) Пользователь – юридическое или физическое лицо, получившее через скачивание с сайта
|
||||
https://entaxy.ru или иным образом, дистрибутив ПО, пользующееся ПО.
|
||||
d) ИС – интеллектуальная собственность – закреплённое законом исключительное право, а также
|
||||
личные неимущественные права авторов произведений на результат интеллектуальной деятельности.
|
||||
e) Подписка – это коммерческое предложение Правообладателя, состоящее из Лицензии на использование
|
||||
ПО и доступа к технической поддержке программного обеспечения на срок Подписки. Подписка
|
||||
включает предоставление Пользователю неисключительного права использования ПО, в том числе
|
||||
получение обновлений функционала ПО и безопасности ПО, исправление ошибок ПО и получение
|
||||
патчей с обновлениями и исправлениями программного обеспечения. Подписка приобретается
|
||||
Пользователем на период времени, указанный в Сертификате. Количество подписок устанавливается
|
||||
для каждого Пользователя индивидуально в Сертификате.
|
||||
f) Сертификат – документ, выдаваемый Дистрибъютором или Авторизованным партнёром (Партнёром),
|
||||
подтверждающий факт приобретения физическим или юридическим лицом Подписки на программное
|
||||
обеспечение в ограниченном объёме и на определённый период времени.
|
||||
g) Лицензия (простая (неисключительная) – совокупность ограниченных прав использования ПО,
|
||||
предоставленных Пользователю согласно условиям Подписки.
|
||||
h) Библиотека – совокупность подпрограмм и объектов, используемых для разработки программного
|
||||
обеспечения.
|
||||
i) Исходный код – текст компьютерной программы на каком-либо языке программирования, состоящий
|
||||
из одного или нескольких файлов, который может быть прочтён человеком.
|
||||
j) Объектный код – файл (часть машинного кода) с промежуточным представлением отдельного модуля
|
||||
программы, полученный в результате обработки исходного кода, еще не связанный в полную программу.
|
||||
Это машинный код для одной конкретной библиотеки или модуля, который будет составлять готовый
|
||||
продукт.
|
||||
k) Некоммерческое использование – индивидуальное личное использование Пользователем программного
|
||||
обеспечения с целью обучения работе с Программным обеспечением, для оценки или демонстрации
|
||||
возможностей Программного обеспечения, при котором, Пользователем не извлекается коммерческая
|
||||
выгода и/или не идёт в доход денежное вознаграждение при использовании Программного обеспечения.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
2. ДОПУСТИМЫЕ СПОСОБЫ ИСПОЛЬЗОВАНИЯ ПРОГРАММНОГО ОБЕСПЕЧЕНИЯ
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
2.1. Правообладатель предоставляет Пользователю ограниченное право использования Программного
|
||||
обеспечения на условиях простой (неисключительной) лицензии в объёме, ограниченном правом
|
||||
воспроизведения полной рабочей версии программного обеспечения, новых версий программного обеспечения
|
||||
в памяти оборудования и его запуска на оборудовании в соответствии со ст. 1280 ГК РФ.
|
||||
2.2. Право на использование Программного обеспечения, предоставляемое Пользователю, носит
|
||||
неисключительный характер.
|
||||
2.3. Пользователю предоставляется всемирная, неисключительная, не подлежащая сублицензированию,
|
||||
лицензия на ограниченное использование Программного обеспечения.
|
||||
2.4. Пользователь, имеющий Базовую (некоммерческую) версию лицензии для пробного использования
|
||||
имеет право приобрести Подписку на программное обеспечение. В этом случае Пользователь обязан
|
||||
обратиться в службу поддержки Правообладателя по адресу: https://entaxy.ru/ для изменения
|
||||
вида лицензии с Базовой бесплатной версии на Подписки.
|
||||
2.5. Срок использования скачанной Пользователем базовой (некоммерческой) версии лицензии для
|
||||
пробного использования программного обеспечения – не ограничен.
|
||||
2.6. Использование Пользователем настоящего программного обеспечения в целях разработки,
|
||||
модификации, обновления другого ПО, принадлежащего третьим лицам, а не Правообладателю,
|
||||
без разрешения Правообладателя не допускается.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
3. АВТОРСКОЕ ПРАВО.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
3.1. Все авторские права, все права интеллектуальной собственности на Программное обеспечение
|
||||
и любые его копии принадлежат Правообладателю.
|
||||
3.2. Все авторские права, все права интеллектуальной собственности в отношении любого контента,
|
||||
к которому можно получить доступ с помощью Программного обеспечения, является собственностью
|
||||
соответствующего владельца контента и защищается применимым законодательством об авторском
|
||||
праве или другими законами и договорами об интеллектуальной собственности.
|
||||
3.3. Условия использования Программного обеспечения.
|
||||
Лицензия, предоставленная Пользователю, действительна только в том случае, если Пользователь
|
||||
придерживается следующих условий:
|
||||
3.3.1. Принятие уведомлений об авторских правах. Пользователю запрещается удалять или изменять
|
||||
какие-либо уведомления об авторских правах или лицензиях, которые появляются при использовании
|
||||
Программного обеспечения или на нем.
|
||||
3.3.2. Модификация. Пользователю запрещается модифицировать, изменять, декомпилировать,
|
||||
расшифровывать, дизассемблировать, переводить или реверсировать, перепроектировать
|
||||
Программное обеспечение.
|
||||
3.3.3. Распространение. Пользователю запрещается сублицензировать, передавать право использования
|
||||
ПО или иным образом распространять или предоставлять Программное обеспечение любой третьей стороне.
|
||||
3.3.4. SaaS. За исключением случаев, когда это разрешено Правообладателем, Пользователю запрещено
|
||||
использовать Программное обеспечение в коммерческих целях для оказания услуг третьим лицам.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
4. ОТВЕТСТВЕННОСТЬ ПРАВООБЛАДАТЕЛЯ ПРИ НАРУШЕНИИ ПОЛЬЗОВАТЕЛЕМ ПРАВ «ИС»
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
4.1. Правообладатель не несет никаких обязательств в отношении каких-либо претензий к Пользователю
|
||||
на предмет нарушения последним прав Интеллектуальной собственности, возникших в связи с
|
||||
использованием Пользователем:
|
||||
4.1.1. Любых компонентов программного обеспечения с открытым исходным кодом, включенных в
|
||||
Программное обеспечение;
|
||||
4.1.2. Любого нарушения правил использования Программного обеспечения, установленного условиями
|
||||
настоящего соглашения;
|
||||
4.1.3. Любого использования Программного обеспечения в сочетании с другими ПО, оборудованием,
|
||||
или данными, не предоставленными Пользователю Правообладателем;
|
||||
4.1.4. Любого изменения Программного обеспечения любым третьим лицом, а не Правообладателем.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
5. НАСТОЯЩИМ ПРАВООБЛАДАТЕЛЬ ЗАЯВЛЯЕТ, ЧТО ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ ПРЕДОСТАВЛЯЕТСЯ ПОЛЬЗОВАТЕЛЮ
|
||||
ПО ПРИНЦИПУ «AS IS» - «КАК ЕСТЬ». НИ ПРИ КАКИХ ОБСТОЯТЕЛЬСТВАХ ПРАВООБЛАДАТЕЛЬ НЕ ГАРАНТИРУЕТ
|
||||
И НЕ ОБЕЩАЕТ, ЧТО ПРЕДОСТАВЛЕННОЕ ИМ ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ БУДЕТ ПОДХОДИТЬ ИЛИ НЕ ПОДХОДИТЬ
|
||||
ДЛЯ КОНКРЕТНЫХ ЦЕЛЕЙ ПОЛЬЗОВАТЕЛЯ, ЧТО ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ БУДЕТ ОТВЕЧАТЬ ВСЕМ КОММЕРЧЕСКИМ
|
||||
И ЛИЧНЫМ СУБЪЕКТИВНЫМ ОЖИДАНИЯМ ПОЛЬЗОВАТЕЛЯ, ЧТО ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ БУДЕТ РАБОТАТЬ
|
||||
ИСПРАВНО, БЕЗ ТЕХНИЧЕСКИХ ОШИБОК, БЫСТРО И БЕСПЕРЕБОЙНО.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
6. ОГРАНИЧЕНИЕ ОТВЕТСТВЕННОСТИ.
|
||||
НИ ПРИ КАКИХ ОБСТОЯТЕЛЬСТВАХ ПРАВООБЛАДАТЕЛЬ ИЛИ ЕГО АФФИЛЛИРОВАННЫЕ ЛИЦА НЕ НЕСУТ ПЕРЕД ПОЛЬЗОВАТЕЛЕМ
|
||||
ОТВЕТСТВЕННОСТИ ЗА ЛЮБЫЕ ПРЯМЫЕ ИЛИ КОСВЕННЫЕ УБЫТКИ ПОЛЬЗОВАТЕЛЯ, ЕГО РАСХОДЫ ИЛИ РЕАЛЬНЫЙ УЩЕРБ,
|
||||
ВКЛЮЧАЯ, ПОМИМО ПРОЧЕГО, ПРОСТОИ; УТРАТУ БИЗНЕСА; УПУЩЕННУЮ ВЫГОДУ; НЕДОПОЛУЧЕННУЮ ПРИБЫЛЬ;
|
||||
ПОТЕРЮ ИЛИ ПОВРЕЖДЕНИЕ ДАННЫХ, ИМУЩЕСТВА И ИНОЕ.
|
||||
ОГРАНИЧЕНИЯ ПРИМЕНЯЮТСЯ НЕЗАВИСИМО ОТ ОСНОВАНИЯ НАСТУПЛЕНИЯ ОТВЕТСТВЕННОСТИ; В ТОМ ЧИСЛЕ ВСЛЕДСТВИЕ
|
||||
ДЕЙСТВИЯ ИЛИ БЕЗДЕЙСТВИЯ, НЕБРЕЖНОСТИ, УМЫСЛА, ПРЯМОГО ИЛИ КОСВЕННОГО; НЕОСТОРОЖНОСТИ; ЗАБЛУЖДЕНИЯ;
|
||||
КЛЕВЕТЫ; НАРУШЕНИЯ КОНФИДЕНЦИАЛЬНОСТИ ИЛИ ПРАВА ИНТЕЛЛЕКТУАЛЬНОЙ СОБСТВЕННОСТИ; ИЛИ ЛЮБОЕ ДРУГОЕ
|
||||
ОСНОВАНИЕ НАСТУПЛЕНИЯ ОТВЕТСТВЕННОСТИ.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
7. ОБЯЗАННОСТЬ ПОЛЬЗОВАТЕЛЯ:
|
||||
Не осуществлять самостоятельно и (или) с привлечением третьих лиц нижеследующие действия
|
||||
(включая, но не ограничиваясь) по:
|
||||
-дизассемблированию и (или) декомпилированию (преобразованию объектного кода в исходный код)
|
||||
Программного обеспечения;
|
||||
-модификации Программного обеспечения, в том числе вносить изменения в объектный код, исходный
|
||||
код Программного обеспечения, за исключением тех изменений, которые вносятся средствами,
|
||||
включёнными в Программное обеспечение и описанными непосредственно в документации к нему;
|
||||
-созданию условий для использования Программного обеспечения лицами, не имеющими прав на
|
||||
использование данного Программного обеспечения, включая (но не ограничиваясь) вмешательство
|
||||
третьих лиц в функционирование Программного обеспечения, предоставление третьим лицам доступа
|
||||
к исследованию и (или) замене настроек Программного обеспечения, включая его первичную установку;
|
||||
-распространению Программного обеспечения в целом или в части (включая приложенную к нему документацию).
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
8. БИБЛИОТЕКА ПО. ИСПОЛЬЗУЕМЫЕ ПРОГРАММНЫЕ СРЕДСТВА.
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
8.1. Настоящим, Правообладатель заверяет, что Библиотека программного обеспечения состоит из
|
||||
лицензионных продуктов, используемых на законных основаниях, а
|
||||
именно https://entaxy.ru/libs/licenses/root-aggregated.deps.
|
||||
8.2. Любые программные средства, применяемые Пользователем при работе с ПО, должны быть
|
||||
совместимы с библиотекой ПО, указанной в п.8.1. настоящего соглашения.
|
||||
8.3. Перечень внешних модулей ПО, указанный в п.8.1 настоящего соглашения, может изменяться
|
||||
Правообладателем в одностороннем порядке, в зависимости от выпуска релизов программного обеспечения,
|
||||
содержащих все изменения и дополнения программного обеспечения.
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
9. ВНЕСЕНИЕ ИЗМЕНЕНИЙ В ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ.
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
9.1. Программное обеспечение, интеграционная шина «ЭНТАКСИ» (ENTAXY) является свободно распространяемым
|
||||
программным обеспечением.
|
||||
9.2. Пользователь имеет право вносить изменения в исходный код программного обеспечения исключительно
|
||||
с согласия Правообладателя в порядке предложения изменений/правок/дополнений через механизм
|
||||
«Pull Requests» в открытом репозитории Правообладателя по адресу: https://git.entaxy.ru/entaxy/entaxy-public.
|
||||
9.3. Любые изменения программного обеспечения, осуществляемые Пользователем без соблюдения условий
|
||||
пункта 9.2. настоящего документа, являются нарушением авторских и смежных прав Правообладателя,
|
||||
прав интеллектуальной собственности Правообладателя и влекут применение к Пользователю мер
|
||||
ответственности в соответствии с условиями настоящей Лицензии, а также применимого законодательства
|
||||
Российской Федерации.
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
10. ЗАКЛЮЧИТЕЛЬНЫЕ ПОЛОЖЕНИЯ.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
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.
|
||||
10.1. В случае нарушения Пользователем любого из условий настоящей Лицензии, Правообладатель имеет
|
||||
право взыскать с Пользователя любые причинённые таким нарушением убытки, реальный ущерб,
|
||||
недополученную прибыль, упущенную выгоду, а также в случае нарушения Пользователем условий
|
||||
пункта 9.2 настоящего соглашения, в том числе, взыскать с Пользователя штраф в размере
|
||||
2 000 000 (Два миллиона) рублей за каждый установленный случай несанкционированного изменения
|
||||
исходного или объектного кода Программного обеспечения «Энтакси» (Entaxy).
|
||||
10.2. В рамках исполнения Пользователем обязательств по настоящей Лицензии, применимое
|
||||
законодательство – Российской Федерации.
|
||||
10.3. Если какое-либо положение настоящей Лицензии будет признано судом недействительным,
|
||||
остальные положения будут продолжать своё действие, а Пользователь будет обязан продолжать
|
||||
исполнять свои обязанности в соответствии с этими положениями.
|
||||
|
@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>ru.entaxy.esb.platform.runtime.base</groupId>
|
||||
<artifactId>objects-base</artifactId>
|
||||
<version>1.8.3</version>
|
||||
<version>1.9.0</version>
|
||||
</parent>
|
||||
<groupId>ru.entaxy.esb.platform.runtime.base.objects-base</groupId>
|
||||
<artifactId>objects-core</artifactId>
|
||||
@ -35,4 +35,4 @@
|
||||
<version>${karaf.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
</project>
|
||||
|
@ -4,21 +4,29 @@
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* 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
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* 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.
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.base.objects;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface EntaxyObject {
|
||||
|
||||
public interface HEADERS {
|
||||
@ -69,7 +77,47 @@ public interface EntaxyObject {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum OBJECT_RELATION {
|
||||
ASSOCIATION,
|
||||
AGGREGATION,
|
||||
COMPOSITION,
|
||||
DEPENDENCY,
|
||||
USE
|
||||
}
|
||||
|
||||
public enum OBJECT_RELATION_SCOPE {
|
||||
RUNTIME,
|
||||
DESIGN
|
||||
}
|
||||
|
||||
public interface RelationDescriptor {
|
||||
OBJECT_RELATION getType();
|
||||
String getName();
|
||||
String getGroup();
|
||||
|
||||
OBJECT_RELATION_SCOPE getScope();
|
||||
|
||||
default boolean isSubordinating() {
|
||||
return OBJECT_RELATION.AGGREGATION.equals(getType())
|
||||
|| OBJECT_RELATION.COMPOSITION.equals(getType());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public interface Relation extends RelationDescriptor {
|
||||
|
||||
EntaxyObject getSource();
|
||||
EntaxyObject getTarget();
|
||||
|
||||
boolean isDefinedInSource();
|
||||
|
||||
}
|
||||
|
||||
public interface CAPABILITIES {
|
||||
String ATTR_RELATION = "relation";
|
||||
}
|
||||
|
||||
public static interface BundleInfo {
|
||||
public long getBundleId();
|
||||
}
|
||||
@ -95,4 +143,11 @@ public interface EntaxyObject {
|
||||
public BundleInfo getBundleInfo();
|
||||
public String getConfiguration();
|
||||
|
||||
public boolean isProvided();
|
||||
public boolean isComplete();
|
||||
|
||||
public boolean isGhost();
|
||||
|
||||
public List<Relation> getRelations();
|
||||
public List<Relation> getIncomingRelations();
|
||||
}
|
||||
|
@ -4,17 +4,23 @@
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* 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
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* 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.
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.base.objects;
|
||||
@ -27,4 +33,7 @@ public interface EntaxyObjectService {
|
||||
|
||||
public EntaxyObject findObject(String objectId, String objectType);
|
||||
|
||||
public void addListener(EntaxyObjectServiceListener listener);
|
||||
|
||||
public void removeListener(EntaxyObjectServiceListener listener);
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* objects-core
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.base.objects;
|
||||
|
||||
public interface EntaxyObjectServiceListener {
|
||||
|
||||
void objectAdded(EntaxyObject object);
|
||||
void objectModified(EntaxyObject object);
|
||||
void objectRemoved(EntaxyObject object);
|
||||
|
||||
}
|
@ -4,17 +4,23 @@
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* 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
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* 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.
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.base.objects;
|
||||
|
@ -4,17 +4,23 @@
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* 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
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* 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.
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.base.objects;
|
||||
|
@ -4,17 +4,23 @@
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* 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
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* 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.
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.base.objects.service.impl;
|
||||
|
@ -4,25 +4,33 @@
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* 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
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* 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.
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.base.objects.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.osgi.framework.Bundle;
|
||||
@ -36,7 +44,10 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ru.entaxy.platform.base.objects.EntaxyObject;
|
||||
import ru.entaxy.platform.base.objects.EntaxyObject.OBJECT_RELATION;
|
||||
import ru.entaxy.platform.base.objects.EntaxyObjectService;
|
||||
import ru.entaxy.platform.base.objects.EntaxyObjectServiceListener;
|
||||
import ru.entaxy.platform.base.objects.service.impl.TrackedEntaxyObject.RelationDescriptor;
|
||||
import ru.entaxy.platform.base.objects.service.tracker.TrackedEntaxyObjectCustomizer;
|
||||
import ru.entaxy.platform.base.objects.service.tracker.TrackedEntaxyObjectCustomizerListener;
|
||||
import ru.entaxy.platform.base.support.osgi.tracker.BundleTrackerUtils;
|
||||
@ -51,11 +62,18 @@ public class EntaxyObjectServiceImpl implements EntaxyObjectService {
|
||||
|
||||
protected BundleTracker<List<TrackedEntaxyObject>> objectTracker;
|
||||
|
||||
protected Map<String, TrackedEntaxyObject> trackedObjects = new HashMap<>();
|
||||
protected Map<String, TrackedEntaxyObject> trackedObjects;
|
||||
|
||||
protected Object trackedObjectsLock = new Object();
|
||||
|
||||
protected List<EntaxyObjectServiceListener> listeners = new ArrayList<>();
|
||||
|
||||
@Activate
|
||||
public void activate(ComponentContext componentContext) {
|
||||
this.bundleContext = componentContext.getBundleContext();
|
||||
if (this.objectTracker != null)
|
||||
this.objectTracker.close();
|
||||
this.trackedObjects = new ConcurrentHashMap<>();
|
||||
openTracker();
|
||||
}
|
||||
|
||||
@ -72,12 +90,22 @@ public class EntaxyObjectServiceImpl implements EntaxyObjectService {
|
||||
|
||||
@Override
|
||||
public EntaxyObject findObject(String objectId, String objectType) {
|
||||
Optional<EntaxyObject> object = getObjects().stream()
|
||||
/* Optional<EntaxyObject> object = getObjects().stream()
|
||||
.filter(obj -> (obj.getObjectId().equals(objectId) && obj.getObjectType().equals(objectType)))
|
||||
.findFirst();
|
||||
return object.orElse(null);
|
||||
*/
|
||||
return this.trackedObjects.get(getFullId(objectId, objectType));
|
||||
}
|
||||
|
||||
protected String getFullId(String objectId, String objectType) {
|
||||
return objectId + ":" + objectType;
|
||||
}
|
||||
|
||||
protected String getFullId(TrackedEntaxyObject entaxyObject) {
|
||||
return getFullId(entaxyObject.getId(), entaxyObject.getType());
|
||||
}
|
||||
|
||||
protected void openTracker() {
|
||||
objectTracker = BundleTrackerUtils.<List<TrackedEntaxyObject>>createBuilder()
|
||||
.addFilter(
|
||||
@ -96,14 +124,167 @@ public class EntaxyObjectServiceImpl implements EntaxyObjectService {
|
||||
return bundleContext;
|
||||
}
|
||||
|
||||
public void addObjects(List<TrackedEntaxyObject> objects) {
|
||||
for (TrackedEntaxyObject object: objects)
|
||||
this.trackedObjects.put(object.getObjectId() + ":" + object.getObjectType(), object);
|
||||
@Override
|
||||
public void addListener(EntaxyObjectServiceListener listener) {
|
||||
this.listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(EntaxyObjectServiceListener listener) {
|
||||
this.listeners.remove(listener);
|
||||
}
|
||||
|
||||
synchronized protected Map<String, TrackedEntaxyObject> acquireTrackedObjects() {
|
||||
return trackedObjects;
|
||||
}
|
||||
|
||||
synchronized public void addObjects(List<TrackedEntaxyObject> objects) {
|
||||
for (TrackedEntaxyObject object: objects) {
|
||||
|
||||
synchronized (trackedObjectsLock) {
|
||||
|
||||
boolean isModified = false;
|
||||
|
||||
String fullId = getFullId(object.getId(), object.getType());
|
||||
if (acquireTrackedObjects().containsKey(fullId)) {
|
||||
// object was created as a placeholder via relations
|
||||
updateObject(acquireTrackedObjects().get(fullId), object);
|
||||
isModified = true;
|
||||
} else {
|
||||
// object is new
|
||||
acquireTrackedObjects().put(fullId, object);
|
||||
}
|
||||
|
||||
List<RelationDescriptor> relations = object.getRelationDescriptors();
|
||||
for (RelationDescriptor relationDescriptor: relations) {
|
||||
TrackedEntaxyObject targetByDescriptorObject = getOrCreateObject(relationDescriptor.targetId, relationDescriptor.targetType);
|
||||
|
||||
TrackedEntaxyObject relationSource = relationDescriptor.relationInverse
|
||||
?targetByDescriptorObject
|
||||
:object;
|
||||
|
||||
TrackedEntaxyObject relationTarget = relationDescriptor.relationInverse
|
||||
?object
|
||||
:targetByDescriptorObject;
|
||||
|
||||
relationSource.relation(relationTarget, relationDescriptor);
|
||||
|
||||
}
|
||||
|
||||
if (isModified)
|
||||
notifyModified(trackedObjects.get(fullId));
|
||||
else
|
||||
notifyAdded(trackedObjects.get(fullId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
synchronized protected TrackedEntaxyObject getOrCreateObject(String objectId, String objectType) {
|
||||
String fullId = getFullId(objectId, objectType);
|
||||
if (!this.trackedObjects.containsKey(fullId)) {
|
||||
TrackedEntaxyObject teo = TrackedEntaxyObject.create(null, objectId, objectType);
|
||||
teo.makeGhost();
|
||||
|
||||
this.trackedObjects.put(fullId, teo);
|
||||
|
||||
notifyAdded(teo);
|
||||
}
|
||||
return this.trackedObjects.get(fullId);
|
||||
}
|
||||
|
||||
protected void updateObject(TrackedEntaxyObject existing, TrackedEntaxyObject newOne) {
|
||||
final Map<String, RelationDescriptor> relationDescriptors = new HashMap<>();
|
||||
|
||||
existing.getRelationDescriptors().stream()
|
||||
.forEach(rd -> relationDescriptors.put(rd.relationName + ":" + rd.relationGroup, rd));
|
||||
newOne.getRelationDescriptors().stream()
|
||||
.forEach(rd -> relationDescriptors.put(rd.relationName + ":" + rd.relationGroup, rd));
|
||||
existing.updateFrom(newOne);
|
||||
existing.setRelationDescriptors(relationDescriptors.values().stream().collect(Collectors.toList()));
|
||||
|
||||
existing.unmakeGhost();
|
||||
}
|
||||
|
||||
public void removeObjects(List<TrackedEntaxyObject> objects) {
|
||||
for (TrackedEntaxyObject object: objects)
|
||||
this.trackedObjects.remove(object.getObjectId() + ":" + object.getObjectType());
|
||||
for (TrackedEntaxyObject object: objects) {
|
||||
String fullId = getFullId(object.getId(), object.getType());
|
||||
TrackedEntaxyObject realObject = this.trackedObjects.get(getFullId(object));
|
||||
if (realObject == null)
|
||||
continue;
|
||||
if (!realObject.hasRelations()) {
|
||||
this.trackedObjects.remove(fullId);
|
||||
notifyRemoved(realObject);
|
||||
continue;
|
||||
}
|
||||
// TODO more accurate processing must be implemented
|
||||
// depending on origins and directions of connections
|
||||
realObject.clear();
|
||||
realObject.makeGhost();
|
||||
}
|
||||
|
||||
clearGhosts();
|
||||
}
|
||||
|
||||
protected void clearGhosts() {
|
||||
List<TrackedEntaxyObject> ghosts = new ArrayList<>(
|
||||
trackedObjects.values().stream().filter(obj -> obj.isGhost)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
|
||||
List<TrackedEntaxyObject> ghostsToRemove = new ArrayList<>();
|
||||
int currentSize = -1;
|
||||
while (currentSize != ghosts.size()) {
|
||||
currentSize = ghosts.size();
|
||||
ghostsToRemove.clear();
|
||||
for (TrackedEntaxyObject ghost: ghosts) {
|
||||
|
||||
List<TrackedEntaxyObject> relatedObjects = ghost.getRelations().stream()
|
||||
.filter(rel -> !rel.isDefinedInSource())
|
||||
.filter(rel -> (OBJECT_RELATION.AGGREGATION.equals(rel.getType()) || OBJECT_RELATION.COMPOSITION.equals(rel.getType())))
|
||||
.map(rel -> trackedObjects.get(rel.getTarget().getObjectFullId()))
|
||||
.filter(obj -> (obj!=null))
|
||||
.filter(obj -> !obj.isGhost())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!relatedObjects.isEmpty())
|
||||
continue;
|
||||
|
||||
relatedObjects = ghost.getIncomingRelations().stream()
|
||||
.filter(rel -> rel.isDefinedInSource())
|
||||
.filter(rel -> (OBJECT_RELATION.DEPENDENCY.equals(rel.getType()) || OBJECT_RELATION.USE.equals(rel.getType())))
|
||||
.map(rel -> trackedObjects.get(rel.getSource().getObjectFullId()))
|
||||
.filter(obj -> (obj != null))
|
||||
.filter(obj -> !obj.isGhost())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!relatedObjects.isEmpty())
|
||||
continue;
|
||||
|
||||
ghostsToRemove.add(ghost);
|
||||
}
|
||||
|
||||
for (TrackedEntaxyObject ghost: ghostsToRemove) {
|
||||
ghosts.remove(ghost);
|
||||
trackedObjects.remove(ghost.getObjectFullId());
|
||||
notifyRemoved(ghost);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void notifyAdded(TrackedEntaxyObject object) {
|
||||
for (EntaxyObjectServiceListener listener: listeners)
|
||||
listener.objectAdded(object);
|
||||
}
|
||||
|
||||
protected void notifyModified(TrackedEntaxyObject object) {
|
||||
for (EntaxyObjectServiceListener listener: listeners)
|
||||
listener.objectModified(object);
|
||||
}
|
||||
|
||||
protected void notifyRemoved(TrackedEntaxyObject object) {
|
||||
for (EntaxyObjectServiceListener listener: listeners)
|
||||
listener.objectRemoved(object);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,36 +4,55 @@
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* 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
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* 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.
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.base.objects.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import ru.entaxy.platform.base.objects.EntaxyObject;
|
||||
import ru.entaxy.platform.base.support.CommonUtils;
|
||||
import ru.entaxy.platform.base.support.JSONUtils;
|
||||
|
||||
public class TrackedEntaxyObject implements EntaxyObject {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(TrackedEntaxyObject.class);
|
||||
|
||||
static public TrackedEntaxyObject create(BundleContext bundleContext, String objectId, String objectType) {
|
||||
log.debug("\n\t CREATING TrackedEntaxyObject: [{}]:[{}]", objectId, objectType);
|
||||
return new TrackedEntaxyObject(bundleContext, objectId, objectType);
|
||||
}
|
||||
|
||||
static public TrackedEntaxyObject create(BundleContext bundleContext, String objectId, String objectType, String scope) {
|
||||
log.debug("\n\t CREATING TrackedEntaxyObject: [{}]:[{}]", objectId, objectType);
|
||||
return new TrackedEntaxyObject(bundleContext, objectId, objectType, scope);
|
||||
}
|
||||
|
||||
@ -44,10 +63,25 @@ public class TrackedEntaxyObject implements EntaxyObject {
|
||||
protected String objectScope = "public";
|
||||
protected String factoryId = "UNKNOWN";
|
||||
|
||||
protected boolean isGhost = false;
|
||||
|
||||
protected JsonObject configuration;
|
||||
|
||||
protected BundleInfoImpl bundleInfoImpl;
|
||||
|
||||
protected boolean isProvided = false;
|
||||
|
||||
protected List<RelationDescriptor> relationDescriptors = new ArrayList<>();
|
||||
|
||||
public static final OBJECT_RELATION DEFAULT_RELATION = OBJECT_RELATION.AGGREGATION;
|
||||
|
||||
public static final OBJECT_RELATION_SCOPE DEFAULT_RELATION_SCOPE = OBJECT_RELATION_SCOPE.RUNTIME;
|
||||
|
||||
public static final boolean DEFAULT_RELATION_INVERSE = true;
|
||||
|
||||
protected Map<String, ObjectRelation> relations = new LinkedHashMap<>();
|
||||
protected List<Relation> incomingRelations = new ArrayList<>();
|
||||
|
||||
protected TrackedEntaxyObject(BundleContext bundleContext, String objectId, String objectType) {
|
||||
super();
|
||||
this.bundleContext = bundleContext;
|
||||
@ -90,6 +124,14 @@ public class TrackedEntaxyObject implements EntaxyObject {
|
||||
return (this.configuration == null?"{}":this.configuration.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Relation> getRelations() {
|
||||
return this.relations.values()
|
||||
.stream()
|
||||
.map(r -> (Relation)r)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public TrackedEntaxyObject bundle(Bundle bundleValue) {
|
||||
this.bundleInfoImpl = new BundleInfoImpl(bundleContext, bundleValue.getBundleId());
|
||||
return this;
|
||||
@ -109,6 +151,269 @@ public class TrackedEntaxyObject implements EntaxyObject {
|
||||
this.configuration = new JsonObject();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProvided() {
|
||||
return isProvided;
|
||||
}
|
||||
|
||||
public void setProvided(boolean isProvided) {
|
||||
this.isProvided = isProvided;
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean isComplete() {
|
||||
return (this.bundleContext != null) && (this.configuration != null);
|
||||
}
|
||||
|
||||
public void relation(TrackedEntaxyObject target, RelationDescriptor descriptor) {
|
||||
ObjectRelation rel = new ObjectRelation();
|
||||
rel.source = this;
|
||||
rel.target = target;
|
||||
rel.type = descriptor.relationType;
|
||||
rel.scope = descriptor.relationScope;
|
||||
rel.name = descriptor.relationName;
|
||||
rel.group = descriptor.relationGroup;
|
||||
rel.isDefinedInSource = !descriptor.relationInverse;
|
||||
this.relations.put(rel.getUniqueId(), rel);
|
||||
target.incomingRelation(rel);
|
||||
}
|
||||
|
||||
public void removeRelation(ObjectRelation relation) {
|
||||
this.relations.remove(relation.getUniqueId());
|
||||
}
|
||||
|
||||
public void incomingRelation(Relation relation) {
|
||||
this.incomingRelations.add(relation);
|
||||
}
|
||||
|
||||
public void removeIncomingRelation(Relation relation) {
|
||||
this.incomingRelations.remove(relation);
|
||||
}
|
||||
|
||||
public boolean hasRelations() {
|
||||
return !this.relations.isEmpty() || !this.incomingRelations.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Relation> getIncomingRelations() {
|
||||
return incomingRelations;
|
||||
}
|
||||
|
||||
public void relationDescription(String descriptor) {
|
||||
RelationDescriptor rd = createRelationDescription(descriptor);
|
||||
String message = "\n\tPARSING: ".concat(descriptor).concat("; RESULT: ");
|
||||
if (rd != null) {
|
||||
this.relationDescriptors.add(rd);
|
||||
message = message.concat(rd.toString());
|
||||
} else {
|
||||
message = message.concat("null");
|
||||
}
|
||||
log.debug(message);
|
||||
}
|
||||
|
||||
protected RelationDescriptor createRelationDescription(String descriptor) {
|
||||
String[] parsed = descriptor.split(":");
|
||||
RelationDescriptor rd = new RelationDescriptor();
|
||||
|
||||
if (parsed.length < 2)
|
||||
return null;
|
||||
|
||||
rd.targetId = parsed[0];
|
||||
rd.targetType = parsed[1];
|
||||
|
||||
if (parsed.length < 3)
|
||||
return rd;
|
||||
rd.relationName = CommonUtils.getValid(parsed[2], "relation");
|
||||
|
||||
|
||||
if (parsed.length < 4)
|
||||
return rd;
|
||||
if (!parseRelationType(parsed[3], rd)) {
|
||||
// old-style relation descriptor without relation type
|
||||
|
||||
rd.relationType = DEFAULT_RELATION;
|
||||
rd.relationInverse = DEFAULT_RELATION_INVERSE;
|
||||
|
||||
rd.relationGroup = CommonUtils.getValid(parsed[3], "");
|
||||
return rd;
|
||||
}
|
||||
|
||||
if (parsed.length < 5)
|
||||
return rd;
|
||||
rd.relationGroup = CommonUtils.getValid(parsed[4], "");
|
||||
|
||||
return rd;
|
||||
}
|
||||
|
||||
protected boolean parseRelationType(String data, RelationDescriptor rd) {
|
||||
if (!CommonUtils.isValid(data))
|
||||
return false;
|
||||
boolean inverse = data.startsWith("-");
|
||||
String type = inverse?data.substring(1):data;
|
||||
|
||||
String typeToParse = type;
|
||||
String scopeToParse = "";
|
||||
int ind = type.indexOf("/");
|
||||
if (ind>0) {
|
||||
typeToParse = type.substring(0, ind);
|
||||
scopeToParse = type.substring(ind+1);
|
||||
}
|
||||
|
||||
try {
|
||||
rd.relationType = OBJECT_RELATION.valueOf(typeToParse.toUpperCase());
|
||||
rd.relationInverse = inverse;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
rd.relationScope = OBJECT_RELATION_SCOPE.valueOf(scopeToParse.toUpperCase());
|
||||
} catch (Exception e) {
|
||||
// ignore: use default scope
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<RelationDescriptor> getRelationDescriptors() {
|
||||
return relationDescriptors;
|
||||
}
|
||||
|
||||
public void setRelationDescriptors(List<RelationDescriptor> relationDescriptors) {
|
||||
this.relationDescriptors = relationDescriptors;
|
||||
}
|
||||
|
||||
public void updateFrom(TrackedEntaxyObject newOne) {
|
||||
this.objectScope = newOne.getScope();
|
||||
this.bundleContext = newOne.bundleContext;
|
||||
this.bundle(this.bundleContext.getBundle(newOne.getBundleInfo().getBundleId()));
|
||||
this.configuration = newOne.configuration;
|
||||
this.factoryId = newOne.factoryId;
|
||||
this.setProvided(newOne.isProvided);
|
||||
this.setRelationDescriptors(newOne.getRelationDescriptors());
|
||||
this.relations.putAll(newOne.relations);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.objectScope = "";
|
||||
this.bundleContext = null;
|
||||
this.bundleInfoImpl = null;
|
||||
this.configuration = null;
|
||||
this.factoryId = "";
|
||||
this.setProvided(false);
|
||||
}
|
||||
|
||||
public void makeGhost() {
|
||||
this.isGhost = true;
|
||||
List<String> idsToRemove = new ArrayList<>();
|
||||
|
||||
for (ObjectRelation rel: this.relations.values()) {
|
||||
if (rel.isDefinedInSource())
|
||||
idsToRemove.add(rel.getUniqueId());
|
||||
rel.target.removeIncomingRelation((Relation)rel);
|
||||
}
|
||||
for (String id: idsToRemove)
|
||||
this.relations.remove(id);
|
||||
|
||||
List<Relation> relationsToRemove = new ArrayList<>();
|
||||
for (Relation rel: this.incomingRelations) {
|
||||
if (!rel.isDefinedInSource()) {
|
||||
if (rel instanceof ObjectRelation) {
|
||||
((ObjectRelation)rel).source.removeRelation((ObjectRelation)rel);
|
||||
relationsToRemove.add(rel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Relation rel: relationsToRemove)
|
||||
this.incomingRelations.remove(rel);
|
||||
}
|
||||
|
||||
public void unmakeGhost() {
|
||||
this.isGhost = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGhost() {
|
||||
return isGhost;
|
||||
}
|
||||
|
||||
|
||||
protected static class RelationDescriptor {
|
||||
|
||||
String targetId;
|
||||
String targetType;
|
||||
|
||||
String relationName = "relation";
|
||||
OBJECT_RELATION relationType = DEFAULT_RELATION;
|
||||
boolean relationInverse = false;
|
||||
String relationGroup = "";
|
||||
|
||||
OBJECT_RELATION_SCOPE relationScope = DEFAULT_RELATION_SCOPE;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return targetId.concat(":")
|
||||
.concat(targetType).concat(":")
|
||||
.concat(relationName).concat(":")
|
||||
.concat(relationInverse?"-":"")
|
||||
.concat(relationType.name()).concat("/").concat(relationScope.name()).concat(":")
|
||||
.concat(relationGroup);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected static class ObjectRelation implements Relation {
|
||||
|
||||
TrackedEntaxyObject source;
|
||||
TrackedEntaxyObject target;
|
||||
OBJECT_RELATION type;
|
||||
String name;
|
||||
String group;
|
||||
|
||||
OBJECT_RELATION_SCOPE scope;
|
||||
|
||||
boolean isDefinedInSource = true;
|
||||
|
||||
@Override
|
||||
public EntaxyObject getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntaxyObject getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OBJECT_RELATION getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OBJECT_RELATION_SCOPE getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefinedInSource() {
|
||||
return isDefinedInSource;
|
||||
}
|
||||
|
||||
public String getUniqueId() {
|
||||
return type.name().concat("/").concat(scope.name()).concat(":").concat(name).concat(":").concat(group).concat(":").concat(target.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,17 +4,23 @@
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* 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
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* 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.
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.base.objects.service.tracker;
|
||||
@ -26,15 +32,21 @@ import java.util.Map;
|
||||
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleEvent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ru.entaxy.platform.base.objects.EntaxyObject;
|
||||
import ru.entaxy.platform.base.objects.service.impl.EntaxyObjectServiceImpl;
|
||||
import ru.entaxy.platform.base.objects.service.impl.TrackedEntaxyObject;
|
||||
import ru.entaxy.platform.base.support.CommonUtils;
|
||||
import ru.entaxy.platform.base.support.osgi.bundle.BundleCapabilityHelper;
|
||||
import ru.entaxy.platform.base.support.osgi.bundle.CapabilityDescriptor;
|
||||
import ru.entaxy.platform.base.support.osgi.tracker.UniformBundleTrackerCustomizer;
|
||||
|
||||
public class TrackedEntaxyObjectCustomizer extends UniformBundleTrackerCustomizer<List<TrackedEntaxyObject>> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(TrackedEntaxyObjectCustomizer.class);
|
||||
|
||||
protected EntaxyObjectServiceImpl objectServiceImpl;
|
||||
|
||||
public TrackedEntaxyObjectCustomizer(EntaxyObjectServiceImpl objectServiceImpl) {
|
||||
@ -46,6 +58,8 @@ public class TrackedEntaxyObjectCustomizer extends UniformBundleTrackerCustomize
|
||||
protected List<TrackedEntaxyObject> createManagedObject(Bundle bundle, BundleEvent event,
|
||||
Map<String, List<?>> filterResults) {
|
||||
|
||||
log.debug("\n\tPROCESS BUNDLE: [{}]; tracker: [{}]", bundle.getBundleId(), this);
|
||||
|
||||
List<TrackedEntaxyObject> result = new ArrayList<>();
|
||||
|
||||
String objectsHeader = bundle.getHeaders().get(EntaxyObject.HEADERS.GENERATED_OBJECTS);
|
||||
@ -54,6 +68,8 @@ public class TrackedEntaxyObjectCustomizer extends UniformBundleTrackerCustomize
|
||||
String[] objects = objectsHeader.split(",");
|
||||
String[] configs = configHeader.split(",");
|
||||
|
||||
BundleCapabilityHelper capabilityHelper = new BundleCapabilityHelper(bundle);
|
||||
|
||||
for (int i=0; i<objects.length; i++) {
|
||||
|
||||
String[] objectData = objects[i].split(":");
|
||||
@ -77,10 +93,37 @@ public class TrackedEntaxyObjectCustomizer extends UniformBundleTrackerCustomize
|
||||
obj = TrackedEntaxyObject.create(
|
||||
objectServiceImpl.getBundleContext(), objectData[0], objectData[1]
|
||||
);
|
||||
|
||||
CapabilityDescriptor capability = capabilityHelper.findObjectDeclaration(objectData[0], objectData[1]);
|
||||
if (capability != null) {
|
||||
obj.setProvided(true);
|
||||
Object relationData = capability.getAttributes().get(EntaxyObject.CAPABILITIES.ATTR_RELATION);
|
||||
if (relationData != null) {
|
||||
if (relationData instanceof List) {
|
||||
List relationList = (List)relationData;
|
||||
for (Object relation: relationList)
|
||||
if (relation != null)
|
||||
obj.relationDescription(relation.toString());
|
||||
} else
|
||||
if (relationData instanceof String)
|
||||
obj.relationDescription((String)relationData);
|
||||
}
|
||||
}
|
||||
|
||||
obj.bundle(bundle).configuration(configuration);
|
||||
result.add(obj);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
synchronized public List<TrackedEntaxyObject> addingBundle(Bundle bundle, BundleEvent event) {
|
||||
if (listener != null) {
|
||||
synchronized (listener) {
|
||||
return super.addingBundle(bundle, event);
|
||||
}
|
||||
}
|
||||
return super.addingBundle(bundle, event);
|
||||
}
|
||||
}
|
||||
|
@ -4,17 +4,23 @@
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* 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
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* 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.
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.base.objects.service.tracker;
|
||||
|
@ -4,17 +4,23 @@
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* 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
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* 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.
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.base.objects.shell;
|
||||
|
@ -4,56 +4,169 @@
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* 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
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* 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.
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.base.objects.shell;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.karaf.shell.api.action.Action;
|
||||
import org.apache.karaf.shell.api.action.Command;
|
||||
import org.apache.karaf.shell.api.action.Option;
|
||||
import org.apache.karaf.shell.api.action.lifecycle.Service;
|
||||
import org.apache.karaf.shell.support.table.ShellTable;
|
||||
|
||||
import ru.entaxy.platform.base.objects.EntaxyObject;
|
||||
import ru.entaxy.platform.base.objects.EntaxyObject.OBJECT_RELATION;
|
||||
import ru.entaxy.platform.base.objects.shell.SimpleObjectTree.SimpleObjectTreeHelperCommon;
|
||||
import ru.entaxy.platform.base.objects.shell.SimpleObjectTree.SimpleObjectTreeNode;
|
||||
|
||||
@Service
|
||||
@Command(name = "object-list", scope = EntaxyObjectServiceSupport.OBJECTS_SCOPE)
|
||||
public class ListObjects extends EntaxyObjectServiceSupport implements Action {
|
||||
|
||||
@Option(name = "-t", aliases = {"--tree"}, description = "Display factory tree")
|
||||
boolean asTree;
|
||||
|
||||
@Override
|
||||
public Object execute() throws Exception {
|
||||
|
||||
ShellTable shellTable = new ShellTable();
|
||||
shellTable.column("Id");
|
||||
shellTable.column("Type");
|
||||
shellTable.column("Provided");
|
||||
shellTable.column("Complete");
|
||||
shellTable.column("Scope");
|
||||
shellTable.column("Full Id");
|
||||
shellTable.column("Factory Id");
|
||||
shellTable.column("Bundle Id");
|
||||
shellTable.column("Factory");
|
||||
shellTable.column("Bundle");
|
||||
|
||||
if (!asTree) {
|
||||
|
||||
for (EntaxyObject object: objectService.getObjects())
|
||||
shellTable.addRow().addContent(
|
||||
(object.isGhost()
|
||||
?"? "
|
||||
:""
|
||||
) + object.getId(),
|
||||
object.getType(),
|
||||
(object.isProvided()?"*":""),
|
||||
(object.isComplete()?"*":""),
|
||||
object.getScope(),
|
||||
object.getObjectFullId(),
|
||||
object.getFactoryId(),
|
||||
object.getBundleInfo()==null
|
||||
?""
|
||||
:object.getBundleInfo().getBundleId()
|
||||
);
|
||||
} else {
|
||||
SimpleObjectTree<EntaxyObject> tree = new SimpleObjectTree<>(new EntaxyObjectHelper());
|
||||
tree.load(objectService.getObjects());
|
||||
for (SimpleObjectTreeNode<EntaxyObject> node: tree.root.children)
|
||||
addRowToTable(shellTable, node);
|
||||
}
|
||||
|
||||
for (EntaxyObject object: objectService.getObjects())
|
||||
shellTable.addRow().addContent(
|
||||
object.getId(),
|
||||
object.getType(),
|
||||
object.getScope(),
|
||||
object.getObjectFullId(),
|
||||
object.getFactoryId(),
|
||||
object.getBundleInfo().getBundleId()
|
||||
);
|
||||
|
||||
shellTable.print(System.out);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getLevelPrefix(SimpleObjectTreeNode<EntaxyObject> node) {
|
||||
String result = "";
|
||||
for (int i=0; i<node.getLevel()-1; i++)
|
||||
result = result.concat(" ");
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void addRowToTable(ShellTable table, SimpleObjectTreeNode<EntaxyObject> node) {
|
||||
if (node.getObject() == null) {
|
||||
table.addRow().addContent(
|
||||
getLevelPrefix(node) + node.getId().split(":")[0]
|
||||
, getLevelPrefix(node) + node.getId().split(":")[1]
|
||||
, ""
|
||||
, ""
|
||||
, ""
|
||||
, node.getId()
|
||||
, ""
|
||||
, ""
|
||||
);
|
||||
|
||||
} else {
|
||||
EntaxyObject object = node.getObject();
|
||||
table.addRow().addContent(
|
||||
getLevelPrefix(node) + (object.isGhost()
|
||||
?"? "
|
||||
:""
|
||||
) + object.getId()
|
||||
, object.getType()
|
||||
, booleanToString(object.isProvided())
|
||||
, booleanToString(object.isComplete())
|
||||
, object.getScope()
|
||||
, object.getObjectFullId()
|
||||
, object.getFactoryId()
|
||||
, (object.isGhost()?"":object.getBundleInfo().getBundleId())
|
||||
);
|
||||
}
|
||||
for (SimpleObjectTreeNode<EntaxyObject> child: node.children) {
|
||||
addRowToTable(table, child);
|
||||
}
|
||||
}
|
||||
|
||||
protected String booleanToString(boolean b) {
|
||||
return b?"*":"";
|
||||
}
|
||||
|
||||
protected class EntaxyObjectHelper extends SimpleObjectTreeHelperCommon<EntaxyObject> {
|
||||
|
||||
@Override
|
||||
public String getId(EntaxyObject object) {
|
||||
return object.getObjectFullId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentId(EntaxyObject object) {
|
||||
final String fullId = object.getObjectFullId();
|
||||
List<EntaxyObject.Relation> candidates = objectService.getObjects()
|
||||
.stream()
|
||||
.filter(obj -> !obj.getRelations().isEmpty())
|
||||
.map(obj -> obj.getRelations())
|
||||
.flatMap(List :: stream)
|
||||
.filter(r -> r.isSubordinating())
|
||||
.filter(r -> fullId.equals(r.getTarget().getObjectFullId()))
|
||||
.collect(Collectors.toList());
|
||||
if (candidates.isEmpty())
|
||||
return null;
|
||||
EntaxyObject parent = null;
|
||||
for (EntaxyObject.Relation relation: candidates)
|
||||
if (relation.getType().equals(OBJECT_RELATION.COMPOSITION)) {
|
||||
parent = relation.getSource();
|
||||
break;
|
||||
}
|
||||
|
||||
parent = candidates.get(0).getSource();
|
||||
|
||||
return parent.getObjectFullId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,17 +4,23 @@
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* 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
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* 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.
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.base.objects.shell;
|
||||
|
@ -4,17 +4,23 @@
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* 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
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* 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.
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.base.objects.shell;
|
||||
|
@ -0,0 +1,64 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.base.objects.shell;
|
||||
|
||||
import org.apache.karaf.shell.api.action.Command;
|
||||
import org.apache.karaf.shell.api.action.lifecycle.Service;
|
||||
import org.apache.karaf.shell.support.table.ShellTable;
|
||||
|
||||
import ru.entaxy.platform.base.objects.EntaxyObject;
|
||||
|
||||
@Service
|
||||
@Command(name = "object-relations", scope = EntaxyObjectServiceSupport.OBJECTS_SCOPE)
|
||||
public class ObjectRelations extends ObjectAwareCommand {
|
||||
|
||||
@Override
|
||||
public Object doExecute() throws Exception {
|
||||
|
||||
ShellTable shellTable = new ShellTable();
|
||||
shellTable.column("Name");
|
||||
shellTable.column("Type");
|
||||
shellTable.column("Scope");
|
||||
shellTable.column("Target");
|
||||
shellTable.column("Subord");
|
||||
shellTable.column("Group");
|
||||
|
||||
for (EntaxyObject.Relation relation: entaxyObject.getRelations())
|
||||
shellTable.addRow().addContent(
|
||||
relation.getName(),
|
||||
relation.getType().name(),
|
||||
relation.getScope().name(),
|
||||
relation.getTarget().getObjectFullId(),
|
||||
(relation.isSubordinating()?"*":""),
|
||||
relation.getGroup()
|
||||
);
|
||||
|
||||
shellTable.print(System.out);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* objects-core
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.base.objects.shell;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import ru.entaxy.platform.base.support.CommonUtils;
|
||||
|
||||
// TODO move to base-support
|
||||
public class SimpleObjectTree<T> {
|
||||
|
||||
Map<String, SimpleObjectTreeNode<T>> allNodes = new HashMap<>();
|
||||
|
||||
SimpleObjectTreeHelper<T> helper;
|
||||
|
||||
SimpleObjectTreeNode<T> root;
|
||||
|
||||
public SimpleObjectTree(SimpleObjectTreeHelper<T> helper) {
|
||||
this.helper = helper;
|
||||
this.root = helper.createNode("@root");
|
||||
}
|
||||
|
||||
public void load(List<T> objects) {
|
||||
|
||||
for (T object: objects) {
|
||||
SimpleObjectTreeNode<T> node = get(helper.getId(object));
|
||||
node.object = object;
|
||||
if (CommonUtils.isValid(helper.getParentId(object)))
|
||||
get(helper.getParentId(object)).addChild(node);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public SimpleObjectTreeNode<T> get(String id) {
|
||||
if (!allNodes.containsKey(id)) {
|
||||
SimpleObjectTreeNode<T> node = helper.createNode(id);
|
||||
root.addChild(node);
|
||||
allNodes.put(id, node);
|
||||
}
|
||||
return allNodes.get(id);
|
||||
}
|
||||
|
||||
|
||||
public static class SimpleObjectTreeNode<T> {
|
||||
|
||||
String id;
|
||||
T object;
|
||||
|
||||
List<SimpleObjectTreeNode<T>> children = new ArrayList<>();
|
||||
|
||||
SimpleObjectTreeNode<T> parent;
|
||||
|
||||
public SimpleObjectTreeNode (String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void addChild(SimpleObjectTreeNode<T> child) {
|
||||
this.children.add(child);
|
||||
if (child.parent != null)
|
||||
child.parent.children.remove(child);
|
||||
child.parent = this;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
if (parent == null)
|
||||
return 0;
|
||||
return parent.getLevel() + 1;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public T getObject() {
|
||||
return object;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static interface SimpleObjectTreeHelper<T> {
|
||||
|
||||
String getId(T object);
|
||||
String getParentId(T object);
|
||||
|
||||
SimpleObjectTreeNode<T> createNode(T object);
|
||||
SimpleObjectTreeNode<T> createNode(String id);
|
||||
}
|
||||
|
||||
public static abstract class SimpleObjectTreeHelperCommon<T> implements SimpleObjectTreeHelper<T> {
|
||||
|
||||
@Override
|
||||
public SimpleObjectTreeNode<T> createNode(String id) {
|
||||
SimpleObjectTreeNode<T> result = new SimpleObjectTreeNode<>(id);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleObjectTreeNode<T> createNode(T object) {
|
||||
SimpleObjectTreeNode<T> result = new SimpleObjectTreeNode<>(getId(object));
|
||||
result.object = object;
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -4,17 +4,23 @@
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* 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
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* 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.
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.base.objects.shell.completers;
|
||||
|
@ -4,17 +4,23 @@
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* ==========
|
||||
* 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
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* 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.
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.base.objects.storage.impl;
|
||||
|
Reference in New Issue
Block a user