Parse.com: Check if Class exists - parse-platform

Is there a way to check if a Class with a certain name exists in Parse?
In my db I am creating classes on the fly and want to check if a Class exists before querying it.
I know one way would be to store all the names of the class in a dedicated class just with the names of the created classes and then to query that. I am wondering if there is a more direct approach

I think there is not yet a method implemented to check if the class exist. What you can do, is do a query on the class name and if it returns an empty list of objects, it is fair to assume that the class does not exist.

You can make a get request on the "schema api" for the class whose existence you want to check.
If the class is not found then an error message is returned clearly stating that the class doesn't exist/ not found.
Here is the link showing how to make a fetch request on the class schema:
http://parseplatform.github.io/docs/rest/guide/#fetch-the-schema
Hope it helps!

Related

What name should gRPC messages have to avoid conflicts with internal classes?

I have a class Book and its information needs to be passed on gRPC.
message Book {
...
}
But if I use this name there will be conflicts between one class and the other. Is there a convention on this? What name for I use for the gRPC equivalents?
Any meaningful and consistent name will be fine. This problem is not specific to protobuf/gRPC. Often times, we will have an entity class called Book and the corresponding DTO (data transfer object) BookDto with more or less same fields. We add the Dto to the entity class name to create BookDto.
This protobuf messages are basically these DTOs. You can follow the same.
You can use the Book name and access via the qualified path to avoid the conflict. You know this and I hope you do not like it.
Is it really a Book object? It might be a BookSearchRequest to query some books and you might expect BookSearchResponse from your gRPC service.

How to debug an entity's validation mapping in Symfony 2.4?

I would like to determine whether an entity property is required or not.
Does anyone know how to access all of the constraints for a given entity property?
I want to check if the NotBlank constraint is active for a certain propery.
information:
You can check the mapping information for a class (or object) with the help of the service:
validator.mapping.class_metadata_factory
The underlying class is:
Symfony\Component\Validator\Mapping\ClassMetadataFactory
The service provides a method getMetadataFor() that allows you to obtain the active mapping metadata for a class (or object).
This method returns an instance of...
Symfony\Component\Validator\Mapping\ClassMetadata
... that provides a getPropertyMetadata(string $property) method that returns the Metadata for a given property name.
example usage:
Inside a controller (or any other ContainerAware instance) you can do:
$factory = $this->container->get('validator.mapping.class_metadata_factory');
$classMetadata = $factory->getMetadataFor('Your\Bundle\Entity\Name');
$propertyMetadata = $classMetadata->getPropertyMetadata('propertyName');
View the list of Supported Validation Constraints Reference from Symfony web site
You can try ladybug bundle. It is very easy to use and shows in detail and nicely to see all properties and info inside an object.

Class 'Foo' not found laravel 3 task

Error: Class 'Ibooks_Controller' not found in/Users/winas/workspace/media_admin/media_books/application/tasks/sample.php
Class that produces error: class Sample_Task extends Ibooks_Controller
Ibooks_Controller path: /Users/winas/workspace/media_admin/media_books/application/controllers/ibooks.php
How can I properly call the function that Ibooks_controller have inside of sample.php
you can't extend a Controller when making a Task. And more importantly, it would be something really bad to do.
I don't know what it is that you're trying to do, but if you want to access any data, you should use models and/or libraries for that.
Besides that, a short explanation on why the class is not found.
Laravel only autoloads files/classes that are in the "models" and "libraries" directories. (There might be more)
Controllers are only loaded when a Route request that controller to be loaded. And will only then search for which controller to load.
If you need to load classes that are not in one of the standard auto-loaded classes, you can load it using the Laravel Autoloader class:
http://three.laravel.com/docs/loading

Issue with Openrasta's Get methods' precedence in resource handler

I am new to openRasta framework. I have a resource called Project.I have 2 different types of GET to be done on this resource as i need different info on these two GETs.My configuration is like this
ResourceSpace.Has.ResourcesOfType<IList<Project>>()
.AtUri("/projects")
.And.AtUri("/miniprojects")
.HandledBy<ProjectHandler>()
.AsJsonDataContract()
.And.AsXmlDataContract();
and my methods in Handler are as below
[HttpOperation(HttpMethod.GET, ForUriName = "/projects")]
public OperationResult GetProjectsList()
{
}
[HttpOperation(HttpMethod.GET, ForUriName = "/miniprojects")]
public OperationResult GetMiniProjectList()
{
}
Whenever i am doing some GET on this resource, whatever my URL is for example http://localhost/projects or http://localhost/miniprojects) the very first method with GetXXX name in handler class gets called every time. When I changed the sequence of the GetXXX methods in handler file the other method gets called.
So my question is, does sequence of methods in Handler determines which GetXXX method to be called? Moreover, I specified different "ForUriName" in the HttpOperation attribute for each GetXXX method as mentioned in the snippet, but still the sequence took the precedence.
Can any one help me in resolving this issue? Or let me know if I am missing anything.
Thanks in advance.
If threre is no way do make the distinction between two URIs then we don't guarantee any order at all.
If you really want to use URI routes in this way (as opposed to model different resources), then your uri needs to be registered with a name
.AtUri("/miniprojects").Named("miniprojects")
The Named bit needs to match the attribute
[HttpOperation(ForUriName="miniprojects")]

No need to extend class/library in codeigniter

I would like to check if my assumption about codeigniter is right ?
We would normally extend a class when we are trying to include more functionality to the core, such as MY_Controller extends Controller, MY_Model extends Model etc...
But for example, if we are in the checkout library retrieving some checkout info(eg, product_id), we can just $this->load->library('product_lib',array('product_id'=>$product_id)) and we can easily $this->product_lib->product_name etc... from the checkout library right?
The $this->load thing is kind of equivalent to "hard code" checkout library to extend product_lib(class checkout_lib extends product_lib) to be able to use whatever methods/variables there is in the product_lib.
Please enlighten me.
In CodeIgniter $this->load is like having a resource manager (e.g. resourceManager->load("path/to/file")) and it takes care of loading the library, and passing any arguments you specify and such, easily allowing you to quickly get to using it.
So if you have a variable named product_name in your product_lib then yes calling $this->product_lib->product_name will be accessing that variable.
Really it just places the library into an array with the library name as the key and the instance of the library as the value so calling $this->product_lib is really calling something similar to $loadedLibraries['product_lib'] and returning the instance.
I hope that answers what you are asking, I'm quite tired and could have miss understood you question.
I think you misunderstood the OO paradigm and the way CI work.
$this->load is same with instantiate an object of the library/model, or load the helper file. CI have some sort of management to see if the helper/library/model already uploaded or not.
In other hand, the extends is used when defining a class, to tell PHP that the class will be inherit the parent class properties and method. A class is a blue print of object it will produce.
Maybe you can start by understanding the OO concept first. You can read this as a start, and see the reference used there.

Resources