Package er.extensions.eof

Examples of er.extensions.eof.ERXKeyFilter$Delegate


    for (String toOneRelationshipName : classDescription.toOneRelationshipKeys()) {
      ERXKey<Object> key = new ERXKey<Object>(toOneRelationshipName);
      if (filter.matches(key, ERXKey.Type.ToOneRelationship)) {
        EOClassDescription destinationClassDescription = classDescription.classDescriptionForDestinationKey(key.key());
        ERXKeyFilter destinationFilter = filter._filterForKey(key);
        NSDictionary<String, Object> destinationSchema = ERXRestSchema.schemaPropertiesForEntityNamed(destinationClassDescription.entityName(), destinationFilter, entities);
        if (destinationSchema != null) {
          properties.setObjectForKey(destinationSchema, key.key());
        }
        else {
          // MS: Recursive reference to an entity .... wtf do we do.
        }
        /*
         * HashMap property = new HashMap(); property.put("$ref", relationship.destinationEntity().name());
         * properties.put(relationship.name(), property);
         */
      }
    }

    for (String toManyRelationshipName : classDescription.toManyRelationshipKeys()) {
      ERXKey<Object> key = new ERXKey<Object>(toManyRelationshipName);
      if (filter.matches(key, ERXKey.Type.ToManyRelationship)) {
        EOClassDescription destinationClassDescription = classDescription.classDescriptionForDestinationKey(key.key());
        ERXKeyFilter destinationFilter = filter._filterForKey(key);
        NSDictionary<String, Object> destinationSchema = ERXRestSchema.schemaPropertiesForEntityNamed(destinationClassDescription.entityName(), destinationFilter, entities);
        if (destinationSchema != null) {
          properties.setObjectForKey(destinationSchema, key.key());
        }
        else {
View Full Code Here


  }

  @Override
  public WOActionResults createAction() throws Throwable {
    checkPassword();
    ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
    MApplication application = create(filter);
    siteConfig().addApplication_W(application);
    return response(application, filter);
  }
View Full Code Here

    }
    return response(ERXHttpStatusCodes.OK);
  }

  public ERXKeyFilter instanceFilter() {
    ERXKeyFilter filter = ERXKeyFilter.filterWithNone();
    filter.include("applicationName");
    filter.include("id");
    filter.include("host.name");
    filter.include("port");
    filter.include("deaths");
    filter.include("isRefusingNewSessions");
    filter.include("isScheduled");
    filter.include("schedulingHourlyStartTime");
    filter.include("schedulingDailyStartTime");
    filter.include("schedulingWeeklyStartTime");
    filter.include("schedulingType");
    filter.include("schedulingStartDay");
    filter.include("schedulingInterval");
    filter.include("transactions");
    filter.include("activeSessions");
    filter.include("averageIdlePeriod");
    filter.include("avgTransactionTime");
    filter.include("isAutoRecovering");
    return filter;
  }
View Full Code Here

        EOEditingContext editingContext = ERXEC.newEditingContext(_osc);
        editingContext.lock();
        try {
            NSArray<Company> cs = new NSArray<Company>(Company.createCompany(editingContext, "Mike"));
            ERXRestFormat format = new ERXRestFormat("json", new ERXXmlRestParser(), new ERXXmlRestWriter(), new ERXRestFormatDelegate("id", "type", "nil", true, true, true, true, true));
            ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
            filter.include("nonModelAttribute");
            assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<companies type=\"array\">\n" + "  <company type=\"company\">\n" + "    <name>Mike</name>\n" + "    <revenue nil=\"true\"/>\n" + "    <non_model_attribute>NonModelAttribute</non_model_attribute>\n" + "  </company>\n" + "</companies>\n", format.toString(EOClassDescription.classDescriptionForEntityName(Company.ENTITY_NAME), cs, filter, new ERXRestContext(editingContext)));
        }
        finally {
            editingContext.unlock();
            editingContext.dispose();
View Full Code Here

        EOEditingContext editingContext = ERXEC.newEditingContext(_osc);
        editingContext.lock();
        try {
            NSArray<Company> cs = new NSArray<Company>(Company.createCompany(editingContext, "Mike"));
            ERXRestFormat format = new ERXRestFormat("json", new ERXXmlRestParser(), new ERXXmlRestWriter(), new ERXRestFormatDelegate("id", "type", "nil", false, true, true, true, true));
            ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
            filter.include("nonModelAttribute");
            assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<companies type=\"array\">\n" + "  <company type=\"company\">\n" + "    <name>Mike</name>\n" + "    <revenue/>\n" + "    <non_model_attribute>NonModelAttribute</non_model_attribute>\n" + "  </company>\n" + "</companies>\n", format.toString(EOClassDescription.classDescriptionForEntityName(Company.ENTITY_NAME), cs, filter, new ERXRestContext(editingContext)));
        }
        finally {
            editingContext.unlock();
            editingContext.dispose();
View Full Code Here

        EOEditingContext editingContext = ERXEC.newEditingContext(_osc);
        editingContext.lock();
        try {
            NSArray<Company> cs = new NSArray<Company>(Company.createCompany(editingContext, "Mike"));
            ERXRestFormat format = new ERXRestFormat("json", new ERXXmlRestParser(), new ERXXmlRestWriter(), new ERXRestFormatDelegate("id", "type", "nil", false, true, true, false, true));
            ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
            filter.include("nonModelAttribute");
            assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<companies type=\"company\">\n" + "  <company type=\"company\">\n" + "    <name>Mike</name>\n" + "    <revenue/>\n" + "    <non_model_attribute>NonModelAttribute</non_model_attribute>\n" + "  </company>\n" + "</companies>\n", format.toString(EOClassDescription.classDescriptionForEntityName(Company.ENTITY_NAME), cs, filter, new ERXRestContext(editingContext)));
        }
        finally {
            editingContext.unlock();
            editingContext.dispose();
View Full Code Here

        EOEditingContext editingContext = ERXEC.newEditingContext(_osc);
        editingContext.lock();
        try {
            NSArray<Company> cs = new NSArray<Company>(Company.createCompany(editingContext, "Mike"));
            ERXRestFormat format = new ERXRestFormat("json", new ERXXmlRestParser(), new ERXXmlRestWriter(), new ERXRestFormatDelegate("id", "type", "nil", false, true, true, false, false));
            ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
            filter.include("nonModelAttribute");
            assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<companies>\n" + "  <company>\n" + "    <name>Mike</name>\n" + "    <revenue/>\n" + "    <non_model_attribute>NonModelAttribute</non_model_attribute>\n" + "  </company>\n" + "</companies>\n", format.toString(EOClassDescription.classDescriptionForEntityName(Company.ENTITY_NAME), cs, filter, new ERXRestContext(editingContext)));
        }
        finally {
            editingContext.unlock();
            editingContext.dispose();
View Full Code Here

    public void testEOAndNonModelAttribute() {
        EOEditingContext editingContext = ERXEC.newEditingContext(_osc);
        editingContext.lock();
        try {
            Company c = Company.createCompany(editingContext, "Company");
            ERXKeyFilter filter = ERXKeyFilter.filterWithAll();
            filter.include("nonModelAttribute");
            assertEquals("{\"type\":\"Company\",\"name\":\"Company\",\"revenue\":null,\"employees\":[],\"nonModelAttribute\":\"NonModelAttribute\"}\n", ERXRestFormat.json().toString(c, filter));
        }
        finally {
            editingContext.unlock();
            editingContext.dispose();
View Full Code Here

    public void testEOAndNonModelRelationship() {
        EOEditingContext editingContext = ERXEC.newEditingContext(_osc);
        editingContext.lock();
        try {
            Company c = Company.createCompany(editingContext, "Company");
            ERXKeyFilter filter = ERXKeyFilter.filterWithAll();
            filter.include("nonModelAttribute");
            filter.include("manufacturers");
            assertEquals("{\"type\":\"Company\",\"name\":\"Company\",\"revenue\":null,\"employees\":[],\"nonModelAttribute\":\"NonModelAttribute\",\"manufacturers\":[{\"id\":\"Mini\",\"type\":\"Manufacturer\"},{\"id\":\"Porsche\",\"type\":\"Manufacturer\"},{\"id\":\"Toyota\",\"type\":\"Manufacturer\"}]}\n", ERXRestFormat.json().toString(c, filter));
        }
        finally {
            editingContext.unlock();
            editingContext.dispose();
View Full Code Here

        try {
            Person p = Person.createPerson(editingContext, "Mike");
            Company c = Company.createCompany(editingContext, "Company");
            p.setCompanyRelationship(c);

            ERXKeyFilter filter = ERXKeyFilter.filterWithAllRecursive();
            filter.setAnonymousUpdateEnabled(true);

            ERXRestFormat.json().parse("{\"name\":\"Mike Updated\",\"company\":{\"name\":\"Company Updated\"}}").updateObjectWithFilter(p, filter, new ERXRestContext(editingContext));
            assertEquals("Mike Updated", p.name());
            assertSame(c, p.company());
            assertEquals("Company Updated", p.company().name());
View Full Code Here

TOP

Related Classes of er.extensions.eof.ERXKeyFilter$Delegate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.