release version 1.10.0
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>ru.entaxy.esb.platform.runtime.base</groupId>
|
||||
<artifactId>objects-base</artifactId>
|
||||
<version>1.9.0</version>
|
||||
<version>1.10.0</version>
|
||||
</parent>
|
||||
<groupId>ru.entaxy.esb.platform.runtime.base.objects-base</groupId>
|
||||
<artifactId>objects-core</artifactId>
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 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
|
||||
@ -28,126 +28,151 @@ package ru.entaxy.platform.base.objects;
|
||||
import java.util.List;
|
||||
|
||||
public interface EntaxyObject {
|
||||
|
||||
public interface HEADERS {
|
||||
|
||||
String ENTAXY_GENERATED = "Entaxy-Generated";
|
||||
String MAIN_OBJECT = "Entaxy-Main-Object";
|
||||
String GENERATED_OBJECTS = "Entaxy-Generated-Object";
|
||||
// public static final String HEADER_MAIN_OBJECT_ID = "Entaxy-Main-Object-Id";
|
||||
// public static final String HEADER_MAIN_OBJECT_TYPE = "Entaxy-Main-Object-Type";
|
||||
// public static final String HEADER_MAIN_OBJECT_FACTORY_ID = "Entaxy-Main-Object-Factory";
|
||||
// public static final String HEADER_OBJECT_ID = "Entaxy-Generated-Object";
|
||||
// public static final String HEADER_OBJECT_TYPE = "Entaxy-Generated-Object-Type";
|
||||
String GENERATED_OBJECTS_CONFIG = "Entaxy-Generated-Object-Configuration";
|
||||
public interface HEADERS {
|
||||
|
||||
}
|
||||
|
||||
public interface FIELDS {
|
||||
|
||||
public static final String FACTORY_ID = "factoryId";
|
||||
public static final String SCOPE = "scope";
|
||||
|
||||
public static final String OBJECT_ID = "objectId";
|
||||
public static final String OBJECT_TYPE = "type";
|
||||
|
||||
public static final String IS_REF = "isRef";
|
||||
public static final String IS_BACK_REF = "isBackRef";
|
||||
public static final String IS_REF_BY_VALUE_ONLY = "isRefByValueOnly";
|
||||
public static final String REF_FIELD = "refField";
|
||||
|
||||
public static final String DEFAULT_VALUE = "defaultValue";
|
||||
|
||||
public static final String PROPERTIES = "properties";
|
||||
String ENTAXY_GENERATED = "Entaxy-Generated";
|
||||
String MAIN_OBJECT = "Entaxy-Main-Object";
|
||||
String GENERATED_OBJECTS = "Entaxy-Generated-Object";
|
||||
// public static final String HEADER_MAIN_OBJECT_ID = "Entaxy-Main-Object-Id";
|
||||
// public static final String HEADER_MAIN_OBJECT_TYPE = "Entaxy-Main-Object-Type";
|
||||
// public static final String HEADER_MAIN_OBJECT_FACTORY_ID = "Entaxy-Main-Object-Factory";
|
||||
// public static final String HEADER_OBJECT_ID = "Entaxy-Generated-Object";
|
||||
// public static final String HEADER_OBJECT_TYPE = "Entaxy-Generated-Object-Type";
|
||||
String GENERATED_OBJECTS_CONFIG = "Entaxy-Generated-Object-Configuration";
|
||||
|
||||
public static final String FIELDS_TO_PUBLISH = "##publish";
|
||||
}
|
||||
|
||||
public interface OBJECT_TYPES {
|
||||
|
||||
public static final String ENTAXY_RUNTIME_TYPE_PREFIX = "entaxy.runtime.";
|
||||
|
||||
public static final String PROFILE = ENTAXY_RUNTIME_TYPE_PREFIX + "profile";
|
||||
public static final String CONNECTOR = ENTAXY_RUNTIME_TYPE_PREFIX + "connector";
|
||||
public static final String CONNECTION = ENTAXY_RUNTIME_TYPE_PREFIX + "connection";
|
||||
public static final String DEFAULT_ROUTE = ENTAXY_RUNTIME_TYPE_PREFIX + "default-route";
|
||||
|
||||
public static boolean isRuntimeType(String typeName) {
|
||||
return (typeName!=null) && typeName.startsWith(ENTAXY_RUNTIME_TYPE_PREFIX);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
public String getId();
|
||||
public String getType();
|
||||
@Deprecated
|
||||
public default String getObjectId() {
|
||||
return getId();
|
||||
};
|
||||
@Deprecated
|
||||
public default String getObjectType() {
|
||||
return getType();
|
||||
};
|
||||
|
||||
public default String getObjectFullId() {
|
||||
return getId() + ":" + getType();
|
||||
};
|
||||
|
||||
public String getScope();
|
||||
|
||||
public String getFactoryId();
|
||||
public BundleInfo getBundleInfo();
|
||||
public String getConfiguration();
|
||||
|
||||
public boolean isProvided();
|
||||
public boolean isComplete();
|
||||
|
||||
public boolean isGhost();
|
||||
|
||||
public List<Relation> getRelations();
|
||||
public List<Relation> getIncomingRelations();
|
||||
public interface FIELDS {
|
||||
|
||||
public static final String FACTORY_ID = "factoryId";
|
||||
public static final String SCOPE = "scope";
|
||||
|
||||
public static final String OBJECT_ID = "objectId";
|
||||
public static final String OBJECT_TYPE = "type";
|
||||
|
||||
public static final String IS_REF = "isRef";
|
||||
public static final String IS_BACK_REF = "isBackRef";
|
||||
public static final String IS_REF_BY_VALUE_ONLY = "isRefByValueOnly";
|
||||
public static final String REF_FIELD = "refField";
|
||||
|
||||
public static final String DEFAULT_VALUE = "defaultValue";
|
||||
|
||||
public static final String PROPERTIES = "properties";
|
||||
|
||||
public static final String FIELDS_TO_PUBLISH = "##publish";
|
||||
}
|
||||
|
||||
public interface OBJECT_TYPES {
|
||||
|
||||
public static final String ENTAXY_RUNTIME_TYPE_PREFIX = "entaxy.runtime.";
|
||||
|
||||
public static final String PROFILE = ENTAXY_RUNTIME_TYPE_PREFIX + "profile";
|
||||
public static final String CONNECTOR = ENTAXY_RUNTIME_TYPE_PREFIX + "connector";
|
||||
public static final String CONNECTION = ENTAXY_RUNTIME_TYPE_PREFIX + "connection";
|
||||
public static final String DEFAULT_ROUTE = ENTAXY_RUNTIME_TYPE_PREFIX + "default-route";
|
||||
|
||||
public static boolean isRuntimeType(String typeName) {
|
||||
return (typeName != null) && typeName.startsWith(ENTAXY_RUNTIME_TYPE_PREFIX);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum OBJECT_RELATION {
|
||||
ASSOCIATION,
|
||||
AGGREGATION,
|
||||
COMPOSITION,
|
||||
DEPENDENCY,
|
||||
USE
|
||||
}
|
||||
|
||||
public interface OBJECT_SCOPE {
|
||||
|
||||
String PRIVATE = "private";
|
||||
String PROTECTED = "protected";
|
||||
String PUBLIC = "public";
|
||||
|
||||
}
|
||||
|
||||
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_DISPLAY_NAME = "displayName";
|
||||
String ATTR_RELATION = "relation";
|
||||
String ATTR_SCOPE = "scope";
|
||||
String ATTR_OWNER = "owner";
|
||||
}
|
||||
|
||||
public static interface BundleInfo {
|
||||
public long getBundleId();
|
||||
}
|
||||
|
||||
public String getId();
|
||||
|
||||
public String getType();
|
||||
|
||||
@Deprecated
|
||||
public default String getObjectId() {
|
||||
return getId();
|
||||
};
|
||||
|
||||
@Deprecated
|
||||
public default String getObjectType() {
|
||||
return getType();
|
||||
};
|
||||
|
||||
public default String getObjectFullId() {
|
||||
return getId() + ":" + getType();
|
||||
};
|
||||
|
||||
public String getDisplayName();
|
||||
|
||||
public String getScope();
|
||||
|
||||
public String getOwner();
|
||||
|
||||
public String getFactoryId();
|
||||
|
||||
public BundleInfo getBundleInfo();
|
||||
|
||||
public String getConfiguration();
|
||||
|
||||
public boolean isProvided();
|
||||
|
||||
public boolean isComplete();
|
||||
|
||||
public boolean isGhost();
|
||||
|
||||
public List<Relation> getRelations();
|
||||
|
||||
public List<Relation> getIncomingRelations();
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* objects-core
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 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
|
||||
@ -144,11 +144,13 @@ public class EntaxyObjectServiceImpl implements EntaxyObjectService {
|
||||
synchronized (trackedObjectsLock) {
|
||||
|
||||
boolean isModified = false;
|
||||
TrackedEntaxyObject existing = object;
|
||||
|
||||
String fullId = getFullId(object.getId(), object.getType());
|
||||
if (acquireTrackedObjects().containsKey(fullId)) {
|
||||
// object was created as a placeholder via relations
|
||||
updateObject(acquireTrackedObjects().get(fullId), object);
|
||||
existing = acquireTrackedObjects().get(fullId);
|
||||
isModified = true;
|
||||
} else {
|
||||
// object is new
|
||||
@ -161,10 +163,10 @@ public class EntaxyObjectServiceImpl implements EntaxyObjectService {
|
||||
|
||||
TrackedEntaxyObject relationSource = relationDescriptor.relationInverse
|
||||
?targetByDescriptorObject
|
||||
:object;
|
||||
:existing;
|
||||
|
||||
TrackedEntaxyObject relationTarget = relationDescriptor.relationInverse
|
||||
?object
|
||||
?existing
|
||||
:targetByDescriptorObject;
|
||||
|
||||
relationSource.relation(relationTarget, relationDescriptor);
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 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
|
||||
@ -44,376 +44,416 @@ 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);
|
||||
}
|
||||
private static final Logger log = LoggerFactory.getLogger(TrackedEntaxyObject.class);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
protected BundleContext bundleContext;
|
||||
|
||||
protected String objectId;
|
||||
protected String objectType;
|
||||
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;
|
||||
static public TrackedEntaxyObject create(BundleContext bundleContext, String objectId, String objectType) {
|
||||
log.debug("\n\t CREATING TrackedEntaxyObject: [{}]:[{}]", objectId, objectType);
|
||||
return new TrackedEntaxyObject(bundleContext, objectId, objectType);
|
||||
}
|
||||
|
||||
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;
|
||||
this.objectId = objectId;
|
||||
this.objectType = 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);
|
||||
}
|
||||
|
||||
protected TrackedEntaxyObject(BundleContext bundleContext, String objectId, String objectType, String scope) {
|
||||
this(bundleContext, objectId, objectType);
|
||||
this.objectScope = scope;
|
||||
}
|
||||
protected BundleContext bundleContext;
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.objectId;
|
||||
}
|
||||
protected String objectId;
|
||||
protected String objectType;
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return this.objectType;
|
||||
}
|
||||
protected String displayName;
|
||||
|
||||
@Override
|
||||
public String getScope() {
|
||||
return this.objectScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFactoryId() {
|
||||
return this.factoryId;
|
||||
}
|
||||
protected String objectScope = EntaxyObject.OBJECT_SCOPE.PUBLIC;
|
||||
|
||||
@Override
|
||||
public BundleInfo getBundleInfo() {
|
||||
return this.bundleInfoImpl;
|
||||
}
|
||||
protected String objectOwner = "";
|
||||
|
||||
@Override
|
||||
public String getConfiguration() {
|
||||
return (this.configuration == null?"{}":this.configuration.toString());
|
||||
}
|
||||
protected String factoryId = "UNKNOWN";
|
||||
|
||||
@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;
|
||||
};
|
||||
|
||||
public TrackedEntaxyObject configuration(String configurationValue) {
|
||||
|
||||
try {
|
||||
this.configuration = JSONUtils.getJsonRootObject(configurationValue);
|
||||
if (this.configuration.has(EntaxyObject.FIELDS.FACTORY_ID))
|
||||
this.factoryId = this.configuration.get(EntaxyObject.FIELDS.FACTORY_ID).getAsString();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
if (this.configuration == null)
|
||||
this.configuration = new JsonObject();
|
||||
|
||||
return this;
|
||||
}
|
||||
protected boolean isGhost = false;
|
||||
|
||||
@Override
|
||||
public boolean isProvided() {
|
||||
return isProvided;
|
||||
}
|
||||
protected JsonObject configuration;
|
||||
|
||||
public void setProvided(boolean isProvided) {
|
||||
this.isProvided = isProvided;
|
||||
};
|
||||
protected BundleInfoImpl bundleInfoImpl;
|
||||
|
||||
@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);
|
||||
}
|
||||
protected boolean isProvided = false;
|
||||
|
||||
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;
|
||||
}
|
||||
protected List<RelationDescriptor> relationDescriptors = new ArrayList<>();
|
||||
|
||||
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");
|
||||
|
||||
public static final OBJECT_RELATION DEFAULT_RELATION = OBJECT_RELATION.AGGREGATION;
|
||||
|
||||
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;
|
||||
public static final OBJECT_RELATION_SCOPE DEFAULT_RELATION_SCOPE = OBJECT_RELATION_SCOPE.RUNTIME;
|
||||
|
||||
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;
|
||||
}
|
||||
public static final boolean DEFAULT_RELATION_INVERSE = true;
|
||||
|
||||
try {
|
||||
rd.relationScope = OBJECT_RELATION_SCOPE.valueOf(scopeToParse.toUpperCase());
|
||||
} catch (Exception e) {
|
||||
// ignore: use default scope
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<RelationDescriptor> getRelationDescriptors() {
|
||||
return relationDescriptors;
|
||||
}
|
||||
protected Map<String, ObjectRelation> relations = new LinkedHashMap<>();
|
||||
protected List<Relation> incomingRelations = new ArrayList<>();
|
||||
|
||||
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);
|
||||
}
|
||||
protected TrackedEntaxyObject(BundleContext bundleContext, String objectId, String objectType) {
|
||||
super();
|
||||
this.bundleContext = bundleContext;
|
||||
this.objectId = objectId;
|
||||
this.objectType = objectType;
|
||||
}
|
||||
|
||||
public void unmakeGhost() {
|
||||
this.isGhost = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGhost() {
|
||||
return isGhost;
|
||||
}
|
||||
protected TrackedEntaxyObject(BundleContext bundleContext, String objectId, String objectType, String scope) {
|
||||
this(bundleContext, objectId, objectType);
|
||||
this.objectScope = scope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.objectId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return this.objectType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return CommonUtils.isValid(this.displayName)
|
||||
? this.displayName
|
||||
: getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getScope() {
|
||||
return this.objectScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwner() {
|
||||
return this.objectOwner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFactoryId() {
|
||||
return this.factoryId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BundleInfo getBundleInfo() {
|
||||
return this.bundleInfoImpl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfiguration() {
|
||||
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;
|
||||
};
|
||||
|
||||
public TrackedEntaxyObject configuration(String configurationValue) {
|
||||
|
||||
try {
|
||||
this.configuration = JSONUtils.getJsonRootObject(configurationValue);
|
||||
if (this.configuration.has(EntaxyObject.FIELDS.FACTORY_ID))
|
||||
this.factoryId = this.configuration.get(EntaxyObject.FIELDS.FACTORY_ID).getAsString();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
if (this.configuration == null)
|
||||
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");
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
if (parsed.length < 4)
|
||||
return rd;
|
||||
if (!parseRelationType(parsed[3], rd)) {
|
||||
// old-style relation descriptor without relation type
|
||||
|
||||
@Override
|
||||
public OBJECT_RELATION getType() {
|
||||
return type;
|
||||
}
|
||||
rd.relationType = DEFAULT_RELATION;
|
||||
rd.relationInverse = DEFAULT_RELATION_INVERSE;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
rd.relationGroup = CommonUtils.getValid(parsed[3], "");
|
||||
return rd;
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
||||
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.objectOwner = newOne.getOwner();
|
||||
this.bundleContext = newOne.bundleContext;
|
||||
this.bundle(this.bundleContext.getBundle(newOne.getBundleInfo().getBundleId()));
|
||||
this.configuration = newOne.configuration;
|
||||
this.factoryId = newOne.factoryId;
|
||||
this.displayName = newOne.displayName;
|
||||
this.setProvided(newOne.isProvided);
|
||||
this.setRelationDescriptors(newOne.getRelationDescriptors());
|
||||
this.relations.putAll(newOne.relations);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.objectScope = "";
|
||||
this.objectOwner = "";
|
||||
this.displayName = null;
|
||||
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;
|
||||
}
|
||||
|
||||
public TrackedEntaxyObject scope(String scope) {
|
||||
this.objectScope = scope;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TrackedEntaxyObject owner(String owner) {
|
||||
this.objectOwner = owner;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TrackedEntaxyObject displayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 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
|
||||
@ -45,85 +45,85 @@ import ru.entaxy.platform.base.support.osgi.tracker.UniformBundleTrackerCustomiz
|
||||
|
||||
public class TrackedEntaxyObjectCustomizer extends UniformBundleTrackerCustomizer<List<TrackedEntaxyObject>> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(TrackedEntaxyObjectCustomizer.class);
|
||||
|
||||
protected EntaxyObjectServiceImpl objectServiceImpl;
|
||||
|
||||
public TrackedEntaxyObjectCustomizer(EntaxyObjectServiceImpl objectServiceImpl) {
|
||||
super();
|
||||
this.objectServiceImpl = objectServiceImpl;
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
String configHeader = bundle.getHeaders().get(EntaxyObject.HEADERS.GENERATED_OBJECTS_CONFIG);
|
||||
|
||||
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(":");
|
||||
String configuration = configs[i];
|
||||
if (CommonUtils.isValid(configuration)) {
|
||||
byte[] bytes = Base64.getDecoder().decode(configuration);
|
||||
configuration = new String(bytes);
|
||||
} else {
|
||||
configuration = "{}";
|
||||
}
|
||||
|
||||
TrackedEntaxyObject obj;
|
||||
if (objectData.length>2)
|
||||
obj = TrackedEntaxyObject.create(
|
||||
objectServiceImpl.getBundleContext()
|
||||
, objectData[0]
|
||||
, objectData[1]
|
||||
, objectData[2]
|
||||
);
|
||||
else
|
||||
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);
|
||||
}
|
||||
private static final Logger log = LoggerFactory.getLogger(TrackedEntaxyObjectCustomizer.class);
|
||||
|
||||
protected EntaxyObjectServiceImpl objectServiceImpl;
|
||||
|
||||
public TrackedEntaxyObjectCustomizer(EntaxyObjectServiceImpl objectServiceImpl) {
|
||||
super();
|
||||
this.objectServiceImpl = objectServiceImpl;
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
String configHeader = bundle.getHeaders().get(EntaxyObject.HEADERS.GENERATED_OBJECTS_CONFIG);
|
||||
|
||||
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(":");
|
||||
String configuration = configs[i];
|
||||
if (CommonUtils.isValid(configuration)) {
|
||||
byte[] bytes = Base64.getDecoder().decode(configuration);
|
||||
configuration = new String(bytes);
|
||||
} else {
|
||||
configuration = "{}";
|
||||
}
|
||||
|
||||
String scope = EntaxyObject.OBJECT_SCOPE.PUBLIC;
|
||||
|
||||
TrackedEntaxyObject obj;
|
||||
if (objectData.length > 2)
|
||||
scope = objectData[2];
|
||||
obj = TrackedEntaxyObject.create(
|
||||
objectServiceImpl.getBundleContext(), objectData[0], objectData[1], scope);
|
||||
|
||||
CapabilityDescriptor capability = capabilityHelper.findObjectDeclaration(objectData[0], objectData[1]);
|
||||
if (capability != null) {
|
||||
obj.setProvided(true);
|
||||
obj.displayName(capability.getAttributes().getOrDefault(EntaxyObject.CAPABILITIES.ATTR_DISPLAY_NAME, "")
|
||||
.toString());
|
||||
obj.owner(capability.getAttributes().getOrDefault(EntaxyObject.CAPABILITIES.ATTR_OWNER, "")
|
||||
.toString());
|
||||
obj.scope(capability.getAttributes().getOrDefault(EntaxyObject.CAPABILITIES.ATTR_SCOPE, scope)
|
||||
.toString());
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 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
|
||||
@ -43,130 +43,144 @@ import ru.entaxy.platform.base.objects.shell.SimpleObjectTree.SimpleObjectTreeNo
|
||||
@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");
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
shellTable.print(System.out);
|
||||
|
||||
return null;
|
||||
}
|
||||
@Option(name = "-t", aliases = {"--tree"}, description = "Display factory tree")
|
||||
boolean asTree;
|
||||
|
||||
protected String getLevelPrefix(SimpleObjectTreeNode<EntaxyObject> node) {
|
||||
String result = "";
|
||||
for (int i=0; i<node.getLevel()-1; i++)
|
||||
result = result.concat(" ");
|
||||
return result;
|
||||
}
|
||||
@Option(name = "-f", aliases = {"--show-full-id"}, description = "Show full Id")
|
||||
boolean showFullId = false;
|
||||
|
||||
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;
|
||||
}
|
||||
@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");
|
||||
if (showFullId)
|
||||
shellTable.column("Full Id");
|
||||
shellTable.column("Factory");
|
||||
shellTable.column("Bundle");
|
||||
|
||||
if (!asTree) {
|
||||
|
||||
for (EntaxyObject object : objectService.getObjects())
|
||||
if (showFullId) {
|
||||
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 {
|
||||
shellTable.addRow().addContent(
|
||||
(object.isGhost()
|
||||
? "? "
|
||||
: "") + object.getId(),
|
||||
object.getType(),
|
||||
(object.isProvided() ? "*" : ""),
|
||||
(object.isComplete() ? "*" : ""),
|
||||
object.getScope(),
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
if (showFullId) {
|
||||
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()));
|
||||
} else {
|
||||
table.addRow().addContent(
|
||||
getLevelPrefix(node) + (object.isGhost()
|
||||
? "? "
|
||||
: "") + object.getId(),
|
||||
object.getType(), booleanToString(object.isProvided()), booleanToString(object.isComplete()),
|
||||
object.getScope(), 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
parent = candidates.get(0).getSource();
|
||||
|
||||
return parent.getObjectFullId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 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
|
||||
@ -35,30 +35,41 @@ import ru.entaxy.platform.base.objects.EntaxyObject;
|
||||
@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);
|
||||
@Override
|
||||
public Object doExecute() throws Exception {
|
||||
|
||||
return null;
|
||||
}
|
||||
ShellTable shellTable = new ShellTable();
|
||||
shellTable.column("Name");
|
||||
shellTable.column("Direction");
|
||||
shellTable.column("Type");
|
||||
shellTable.column("Scope");
|
||||
shellTable.column("Target/Source");
|
||||
shellTable.column("Subord");
|
||||
shellTable.column("Group");
|
||||
|
||||
for (EntaxyObject.Relation relation : entaxyObject.getRelations())
|
||||
shellTable.addRow().addContent(
|
||||
relation.getName(),
|
||||
"outgoing ->",
|
||||
relation.getType().name(),
|
||||
relation.getScope().name(),
|
||||
relation.getTarget().getObjectFullId(),
|
||||
(relation.isSubordinating() ? "*" : ""),
|
||||
relation.getGroup());
|
||||
|
||||
for (EntaxyObject.Relation relation : entaxyObject.getIncomingRelations())
|
||||
shellTable.addRow().addContent(
|
||||
relation.getName(),
|
||||
"incoming <-",
|
||||
relation.getType().name(),
|
||||
relation.getScope().name(),
|
||||
relation.getSource().getObjectFullId(),
|
||||
(relation.isSubordinating() ? "*" : ""),
|
||||
relation.getGroup());
|
||||
|
||||
shellTable.print(System.out);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* objects-core
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* test-producers
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* Copyright (C) 2020 - 2024 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
|
||||
|
Reference in New Issue
Block a user