org.joinedworkz.common.info.ImplementedFeatureMapping Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-base Show documentation
Show all versions of common-base Show documentation
DSL based modeling framework - facilities common base
package org.joinedworkz.common.info;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import org.joinedworkz.core.model.CmnComponentFeature;
import org.joinedworkz.core.model.CmnConsumedFeature;
import org.joinedworkz.core.model.CmnConsumedResourceOperation;
import org.joinedworkz.core.model.CmnImplementedFeature;
import org.joinedworkz.core.model.CmnObject;
import org.joinedworkz.core.model.CmnOperation;
import org.joinedworkz.core.model.CmnProvidedAction;
import org.joinedworkz.core.model.CmnProvidedFeature;
import org.joinedworkz.core.model.CmnProvidedFeatureImplementation;
import org.joinedworkz.core.model.CmnProvidedOperation;
import org.joinedworkz.core.model.CmnProvidedResource;
import org.joinedworkz.core.model.CmnProvidedService;
import org.joinedworkz.core.model.CmnResourceOperation;
import org.joinedworkz.core.model.ux.CmnPage;
public class ImplementedFeatureMapping {
private Map implementationInfos = new LinkedHashMap<>();
private Map implementedFeatures = new LinkedHashMap<>();
public void putImplementation(CmnProvidedResource providedFeature, CmnResourceOperation resourceOperation, CmnImplementedFeature implementedFeature) {
putImplementationWithKey(providedFeature, resourceOperation, implementedFeature);
}
public void putImplementation(CmnProvidedService providedService, CmnOperation operation, CmnImplementedFeature implementedFeature) {
putImplementationWithKey(providedService, operation, implementedFeature);
}
public void putImplementation(CmnPage providedPage, CmnProvidedAction action, CmnImplementedFeature implementedFeature) {
putImplementationWithKey(providedPage, action, implementedFeature);
}
public void putImplementation(CmnProvidedOperation providedFeature, CmnOperation operation, CmnImplementedFeature implementedFeature) {
putImplementationWithKey(providedFeature, operation, implementedFeature);
}
public void putImplementation(CmnProvidedFeature providedFeature, CmnProvidedFeatureImplementation implementedFeature) {
implementedFeatures.put(providedFeature, implementedFeature);
}
protected void putImplementationWithKey(CmnComponentFeature providedFeature, CmnObject keyObject, CmnImplementedFeature implementedFeature) {
ImplementationInfo info = implementationInfos.get(providedFeature);
if (info == null) {
info = new ImplementationInfo();
implementationInfos.put(providedFeature, info);
}
info.putImplementation(keyObject, implementedFeature);
}
public Collection getImplementedFeatures(CmnProvidedFeature providedFeature) {
ImplementationInfo info = implementationInfos.get(providedFeature);
if (info != null) {
return info.getImplementedFeatures();
}
return Collections.emptyList();
}
public CmnImplementedFeature getImplementedFeature(CmnProvidedFeature providedFeature, CmnResourceOperation resourceOperation) {
ImplementationInfo info = implementationInfos.get(providedFeature);
if (info != null) {
return info.getImplementedFeature(resourceOperation);
}
return null;
}
public CmnImplementedFeature getImplementedFeature(CmnProvidedService providedService, CmnOperation operation) {
ImplementationInfo info = implementationInfos.get(providedService);
if (info != null) {
return info.getImplementedFeature(operation);
}
return null;
}
public CmnImplementedFeature getImplementedFeature(CmnPage page, CmnProvidedAction action) {
ImplementationInfo info = implementationInfos.get(page);
if (info != null) {
return info.getImplementedFeature(action);
}
return null;
}
public CmnProvidedFeatureImplementation getImplementedFeature(CmnProvidedFeature providedFeature) {
return implementedFeatures.get(providedFeature);
}
public CmnProvidedFeatureImplementation getImplementedFeature(CmnConsumedFeature consumedFeature) {
if (consumedFeature instanceof CmnConsumedResourceOperation) {
return getImplementedFeature(consumedFeature.getTargetFeature(), ((CmnConsumedResourceOperation)consumedFeature).getResourceOperation());
} else {
// Collection implementedFeatures = getImplementedFeatures(consumedFeature.getTargetFeature());
// if (!implementedFeatures.isEmpty()) {
// return implementedFeatures.iterator().next();
// }
}
return implementedFeatures.get(consumedFeature.getTargetFeature());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy