public ActionResultContextFacade ExecuteServiceAction(IOidTranslation serviceName, string actionName, ArgumentsContextFacade arguments) { return(MapErrors(() => { ActionContext actionContext = GetInvokeActionOnService(serviceName, actionName); return ExecuteAction(actionContext, arguments); })); }
public ActionResultContextFacade ExecuteObjectAction(IOidTranslation objectId, string actionName, ArgumentsContextFacade arguments) { return(MapErrors(() => { ActionContext actionContext = GetInvokeActionOnObject(objectId, actionName); return ExecuteAction(actionContext, arguments); })); }
private T InvokeAction <T>(IObjectFacade nakedObject, IActionFacade action, FormCollection parameters, out bool valid) { ArgumentsContextFacade ac; IOidTranslation oid = Facade.OidTranslator.GetOidTranslation(nakedObject); ActionResultContextFacade contextFacade; if (ActionExecutingAsContributed(action, nakedObject) && action.ParameterCount == 1) { // contributed action being invoked with a single parm that is the current target // no dialog - go straight through ac = new ArgumentsContextFacade { Values = new Dictionary <string, object>(), ValidateOnly = false }; contextFacade = Facade.ExecuteObjectAction(oid, action.Id, ac); } else { ac = GetParameterValues(action, new ObjectAndControlData { Form = parameters }); contextFacade = Facade.ExecuteObjectAction(oid, action.Id, ac); } valid = contextFacade.HasResult; if (valid) { return(GetResult <T>(contextFacade)); } return(default(T)); }
public PropertyContextFacade DeleteFromCollection(IOidTranslation objectId, string propertyName, ArgumentContextFacade argument) { return(MapErrors(() => { PropertyContext context = SetupPropertyContext(GetObjectAsNakedObject(objectId), propertyName, argument.Value); var property = (OneToManyAssociation)context.Property; return ChangeCollection(context, property.validToRemove, property.removeElement, argument); })); }
public object GetDomainObjectByOid(IOidTranslation objectId) { if (objectId == null) { return null; } var oid = objectId.GetOid(this); return GetAdapterByOid(oid.Value as IOid).GetDomainObject(); }
private INakedObjectAdapter GetAdapterByOidTranslation(IOidTranslation objectId) { if (objectId == null) { return null; } var oid = objectId.GetOid(this); return GetAdapterByOid(oid.Value as IOid); }
public UriMtHelper(IOidStrategy oidStrategy, HttpRequestMessage req, IObjectFacade objectFacade) : this(oidStrategy, req) { this.objectFacade = objectFacade; spec = objectFacade.Specification; IOidTranslation oid = oidStrategy.FrameworkFacade.OidTranslator.GetOidTranslation(objectFacade); cachedId = oid.InstanceId; CachedType = oid.DomainType; }
public PropertyContextFacade GetProperty(IOidTranslation oid, string propertyName) { return(MapErrors(() => { PropertyContext pc = GetProperty(GetObjectAsNakedObject(oid), propertyName); return new PropertyContextFacade { Target = new ObjectFacade(pc.Target, this), Property = new AssociationFacade(pc.Property, pc.Target, this) }; })); }
public object GetServiceByServiceName(IOidTranslation serviceName) { Type type = ValidateServiceId(serviceName); try { return FacadeUtils.GetServicesInternal().Single(s => s.getSpecification().getFullName() == type.FullName).getObject(); } catch (Exception e) { throw new ServiceResourceNotFoundNOSException(serviceName.DomainType, e); } }
public object GetDomainObjectByOid(IOidTranslation objectId) { if (objectId == null) { return(null); } var oid = objectId.GetOid(this); return(GetAdapterByOid(oid.Value as IOid).GetDomainObject()); }
public object GetServiceByServiceName(IOidTranslation serviceName) { Type type = ValidateServiceId(serviceName); try { return(FacadeUtils.GetServicesInternal().Single(s => s.getSpecification().getFullName() == type.FullName).getObject()); } catch (Exception e) { throw new ServiceResourceNotFoundNOSException(serviceName.DomainType, e); } }
private INakedObjectAdapter GetAdapterByOidTranslation(IOidTranslation objectId) { if (objectId == null) { return(null); } var oid = objectId.GetOid(this); return(GetAdapterByOid(oid.Value as IOid)); }
public UriMtHelper(IOidStrategy oidStrategy, HttpRequestMessage req, ActionContextFacade actionContext) : this(oidStrategy, req) { action = actionContext.Action; objectFacade = actionContext.Target; spec = objectFacade.Specification; IOidTranslation oid = oidStrategy.FrameworkFacade.OidTranslator.GetOidTranslation(objectFacade); cachedId = oid.InstanceId; CachedType = oid.DomainType; }
public ActionContextFacade GetObjectAction(IOidTranslation objectId, string actionName) { return(MapErrors(() => { if (string.IsNullOrEmpty(actionName.Trim())) { throw new BadRequestNOSException(); } NakedObject nakedObject = GetObjectAsNakedObject(objectId); return GetAction(actionName, nakedObject).ToActionContextFacade(this); })); }
public UriMtHelper(IOidStrategy oidStrategy, HttpRequestMessage req, IObjectFacade objectFacade, string instanceId) : this(oidStrategy, req) { this.objectFacade = objectFacade; spec = objectFacade.Specification; if (objectFacade.Specification.IsParseable) { throw new ArgumentException($"Cannot build URI for parseable specification : {objectFacade.Specification.FullName}"); } IOidTranslation oid = oidStrategy.FrameworkFacade.OidTranslator.GetOidTranslation(objectFacade); cachedId = instanceId; CachedType = oid.DomainType; }
public UriMtHelper(IOidStrategy oidStrategy, HttpRequestMessage req, PropertyContextFacade propertyContext) : this(oidStrategy, req) { assoc = propertyContext.Property; objectFacade = propertyContext.Target; spec = objectFacade.Specification; if (objectFacade.Specification.IsParseable) { throw new ArgumentException($"Cannot build URI for parseable specification : {objectFacade.Specification.FullName}"); } IOidTranslation oid = oidStrategy.FrameworkFacade.OidTranslator.GetOidTranslation(objectFacade); cachedId = propertyContext.Target.IsTransient ? "" : oid.InstanceId; CachedType = oid.DomainType; }
private Type ValidateId(IOidTranslation objectId, Action onError) { if (string.IsNullOrEmpty(objectId.DomainType.Trim())) { throw new BadRequestNOSException(); } Type type = GetType(objectId.DomainType); if (type == null) { onError(); } return(type); }
private static ObjectRepresentation CreateObjectWithOptionals(IOidStrategy oidStrategy, ObjectContextFacade objectContext, HttpRequestMessage req, RestControlFlags flags) { IOidTranslation oid = oidStrategy.FrameworkFacade.OidTranslator.GetOidTranslation(objectContext.Target); var props = new List <OptionalProperty>(); if (objectContext.Specification.IsService) { props.Add(new OptionalProperty(JsonPropertyNames.ServiceId, oid.DomainType)); } else { props.Add(new OptionalProperty(JsonPropertyNames.InstanceId, oid.InstanceId)); props.Add(new OptionalProperty(JsonPropertyNames.DomainType, oid.DomainType)); } return(CreateWithOptionals <ObjectRepresentation>(new object[] { oidStrategy, req, objectContext, flags }, props)); }
private ITypeSpec GetServiceTypeSpecByServiceName(IOidTranslation id) { var type = ValidateServiceId(id); ITypeSpec spec; try { spec = framework.MetamodelManager.GetSpecification(type); } catch (Exception e) { throw new ServiceResourceNotFoundNOSException(type.ToString(), e); } if (spec == null) { throw new ServiceResourceNotFoundNOSException(type.ToString()); } return(spec); }
public object GetDomainObjectByOid(IOidTranslation objectId) { Type type = ValidateObjectId(objectId); string[] keys = GetKeys(objectId.InstanceId, type); NakedObjectSpecification spec = [email protected]().loadSpecification(type.FullName); NakedObject pattern = [email protected]().createTransientInstance(spec); PropertyInfo p = pattern.getObject().GetType().GetProperty("Id"); ((WholeNumber) p.GetValue(pattern.getObject(), null)).setValue(int.Parse(keys.First())); var criteria = new TitleCriteria(spec, pattern.titleString(), false); TypedNakedCollection results = [email protected]().findInstances(criteria); if (results.size() == 0) { throw new ObjectResourceNotFoundNOSException(objectId.ToString()); } return results.elementAt(0).getObject(); }
public object GetDomainObjectByOid(IOidTranslation objectId) { Type type = ValidateObjectId(objectId); string[] keys = GetKeys(objectId.InstanceId, type); NakedObjectSpecification spec = [email protected]().loadSpecification(type.FullName); NakedObject pattern = [email protected]().createTransientInstance(spec); PropertyInfo p = pattern.getObject().GetType().GetProperty("Id"); ((WholeNumber)p.GetValue(pattern.getObject(), null)).setValue(int.Parse(keys.First())); var criteria = new TitleCriteria(spec, pattern.titleString(), false); TypedNakedCollection results = [email protected]().findInstances(criteria); if (results.size() == 0) { throw new ObjectResourceNotFoundNOSException(objectId.ToString()); } return(results.elementAt(0).getObject()); }
public IObjectFacade GetObjectFacadeByOid(IOidTranslation objectId) { var adapter = GetAdapterByOidTranslation(objectId); return(adapter == null ? null : ObjectFacade.Wrap(adapter, FrameworkFacade, framework)); }
public object GetDomainObjectByOid(IOidTranslation objectId) { var adapter = GetAdapterByOidTranslation(objectId); return(adapter == null ? null : GetAdapterByOidTranslation(objectId).GetDomainObject()); }
private ObjectContext GetObjectInternal(IOidTranslation oid) { NakedObject nakedObject = GetObjectAsNakedObject(oid); return(GetObjectContext(nakedObject)); }
private ObjectContext GetServiceInternal(IOidTranslation serviceName) { NakedObject nakedObject = GetServiceAsNakedObject(serviceName); return(GetObjectContext(nakedObject)); }
private NakedObject GetServiceAsNakedObject(IOidTranslation serviceName) { object obj = oidStrategy.GetServiceByServiceName(serviceName); return([email protected]().getAdapterFor(obj)); }
public ObjectContextFacade GetService(IOidTranslation serviceName) { return(MapErrors(() => GetServiceInternal(serviceName).ToObjectContextFacade(this))); }
public IObjectFacade GetObjectFacadeByOid(IOidTranslation objectId) { throw new NotImplementedException(); }
public ITypeFacade GetServiceTypeByServiceName(IOidTranslation id) => new TypeFacade(GetServiceTypeSpecByServiceName(id), FrameworkFacade, framework);
public object GetDomainObjectByOid(IOidTranslation objectId) { var adapter = GetAdapterByOidTranslation(objectId); return adapter == null ? null : GetAdapterByOidTranslation(objectId).GetDomainObject(); }
private Type ValidateObjectId(IOidTranslation objectId) { return ValidateId(objectId, () => { throw new ObjectResourceNotFoundNOSException(objectId + ": Type not found" ); }); }
private ActionContext GetInvokeActionOnObject(IOidTranslation objectId, string actionName) { NakedObject nakedObject = GetObjectAsNakedObject(objectId); return(GetAction(actionName, nakedObject)); }
public object GetServiceByServiceName(IOidTranslation serviceName) { var oid = serviceName.GetSid(this); return(GetAdapterByOid(oid?.Value as IOid).GetDomainObject()); }
protected static Type ValidateObjectId(IOidTranslation objectId) { return ValidateId(objectId, () => { throw new ObjectResourceNotFoundNOSException(objectId.ToString()); }); }
public IObjectFacade GetObjectFacadeByOid(IOidTranslation objectId) { var adapter = GetAdapterByOidTranslation(objectId); return adapter == null ? null : ObjectFacade.Wrap(adapter, FrameworkFacade, framework); }
private ActionContext GetInvokeActionOnService(IOidTranslation serviceName, string actionName) { NakedObject nakedObject = GetServiceAsNakedObject(serviceName); return(GetAction(actionName, nakedObject)); }
public object GetDomainObjectByOid(IOidTranslation objectId) { throw new NotImplementedException(); }
public PropertyContextFacade DeleteProperty(IOidTranslation objectId, string propertyName, ArgumentContextFacade argument) { return(MapErrors(() => ChangeProperty(GetObjectAsNakedObject(objectId), propertyName, argument))); }
public object GetServiceByServiceName(IOidTranslation serviceName) { throw new NotImplementedException(); }
public object GetServiceByServiceName(IOidTranslation serviceName) { var oid = serviceName.GetSid(this); return GetAdapterByOid(oid.Value as IOid).GetDomainObject(); }
private static Type ValidateId(IOidTranslation objectId, Action onError) { if (string.IsNullOrEmpty(objectId.DomainType.Trim())) { throw new BadRequestNOSException(); } Type type = GetType(objectId.DomainType); if (type == null) { onError(); } return type; }
private Type ValidateObjectId(IOidTranslation objectId) { return(ValidateId(objectId, () => { throw new ObjectResourceNotFoundNOSException(objectId + ": Type not found"); })); }
private static string Encode(IOidTranslation loid) { return loid == null ? null : loid.Encode(); }
private NakedObject GetObjectAsNakedObject(IOidTranslation objectId) { object obj = oidStrategy.GetDomainObjectByOid(objectId); return([email protected]().getAdapterFor(obj)); }