Beispiel #1
0
        public object GetServiceByServiceName(string serviceName)
        {
            NakedObject service = GetServiceByServiceNameInternal(serviceName);

            if (service == null)
            {
                throw new ServiceResourceNotFoundNOSException(serviceName);
            }
            return(service.getObject());
        }
Beispiel #2
0
        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());
        }
Beispiel #3
0
        public object GetDomainObjectByOid(string oid)
        {
            long idAsLong;

            if (!long.TryParse(oid, out idAsLong))
            {
                // check if it's a service
                NakedObject service = GetServiceByServiceNameInternal(oid);

                if (service == null)
                {
                    throw new BadRequestNOSException();
                }
                return(service.getObject());
            }
            var serialOid = new SerialOid(idAsLong);

            NakedObject adapter = [email protected]().getAdapterFor(serialOid);

            return(adapter.getObject());
        }