Package org.apache.syncope.client.to

Examples of org.apache.syncope.client.to.SchemaTO


        assertEquals(schemaTO, newSchemaTO);
    }

    @Test
    public void createWithNotPermittedName() {
        SchemaTO schemaTO = new SchemaTO();
        schemaTO.setName("failedLogins");
        schemaTO.setType(SchemaType.String);

        try {
            restTemplate.postForObject(BASE_URL + "schema/user/create", schemaTO, SchemaTO.class);
            fail("This should not be reacheable");
        } catch (SyncopeClientCompositeErrorException scce) {
View Full Code Here


        }
    }

    @Test
    public void createREnumWithoutEnumeration() {
        SchemaTO schemaTO = new SchemaTO();
        schemaTO.setName("enumcheck");
        schemaTO.setType(SchemaType.Enum);

        try {
            restTemplate.postForObject(BASE_URL + "schema/role/create", schemaTO, SchemaTO.class);
            fail("This should not be reacheable");
        } catch (SyncopeClientCompositeErrorException scce) {
View Full Code Here

        }
    }

    @Test
    public void createUEnumWithoutEnumeration() {
        SchemaTO schemaTO = new SchemaTO();
        schemaTO.setName("enumcheck");
        schemaTO.setType(SchemaType.Enum);

        try {
            restTemplate.postForObject(BASE_URL + "schema/user/create", schemaTO, SchemaTO.class);
            fail("This should not be reacheable");
        } catch (SyncopeClientCompositeErrorException scce) {
View Full Code Here

        }
    }

    @Test
    public void delete() {
        SchemaTO deletedSchema =
            restTemplate.getForObject(BASE_URL + "schema/user/delete/cool.json", SchemaTO.class);
        assertNotNull(deletedSchema);
        SchemaTO firstname = null;
        try {
            firstname = restTemplate.getForObject(BASE_URL + "schema/user/read/cool.json", SchemaTO.class);
        } catch (HttpClientErrorException e) {
            assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
        }
View Full Code Here

        }
    }

    @Test
    public void update() {
        SchemaTO schemaTO = restTemplate.getForObject(BASE_URL + "schema/role/read/icon.json", SchemaTO.class);
        assertNotNull(schemaTO);

        SchemaTO updatedTO = restTemplate.postForObject(BASE_URL + "schema/role/update", schemaTO, SchemaTO.class);
        assertEquals(schemaTO, updatedTO);

        updatedTO.setType(SchemaType.Date);
        try {
            restTemplate.postForObject(BASE_URL + "schema/role/update", updatedTO, SchemaTO.class);
            fail("This should not be reacheable");
        } catch (SyncopeClientCompositeErrorException scce) {
            SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidRSchema);
View Full Code Here

        }
    }

    @Test
    public void issue258() {
        SchemaTO schemaTO = new SchemaTO();
        schemaTO.setName("schema_issue258");
        schemaTO.setType(SchemaType.Double);

        schemaTO = restTemplate.postForObject(BASE_URL + "schema/user/create", schemaTO, SchemaTO.class);
        assertNotNull(schemaTO);

        UserTO userTO = UserTestITCase.getSampleTO("issue258@syncope.apache.org");
        AttributeTO attrTO = new AttributeTO();
        attrTO.setSchema(schemaTO.getName());
        attrTO.addValue("1.2");
        userTO.addAttribute(attrTO);

        userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
        assertNotNull(userTO);

        schemaTO.setType(SchemaType.Long);
        try {
            restTemplate.postForObject(BASE_URL + "schema/user/update", schemaTO, SchemaTO.class);
            fail("This should not be reacheable");
        } catch (SyncopeClientCompositeErrorException scce) {
            SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidUSchema);
View Full Code Here

        }
    }

    @Test
    public void issue259() {
        SchemaTO schemaTO = new SchemaTO();
        schemaTO.setName("schema_issue259");
        schemaTO.setUniqueConstraint(true);
        schemaTO.setType(SchemaType.Long);

        schemaTO = restTemplate.postForObject(BASE_URL + "schema/user/create", schemaTO, SchemaTO.class);
        assertNotNull(schemaTO);

        UserTO userTO = UserTestITCase.getSampleTO("issue259@syncope.apache.org");
        AttributeTO attrTO = new AttributeTO();
        attrTO.setSchema(schemaTO.getName());
        attrTO.addValue("1");
        userTO.addAttribute(attrTO);

        userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
        assertNotNull(userTO);
View Full Code Here

        assertNotNull(userTO);
    }

    @Test
    public void issue260() {
        SchemaTO schemaTO = new SchemaTO();
        schemaTO.setName("schema_issue260");
        schemaTO.setType(SchemaType.Double);
        schemaTO.setUniqueConstraint(true);

        schemaTO = restTemplate.postForObject(BASE_URL + "schema/user/create", schemaTO, SchemaTO.class);
        assertNotNull(schemaTO);

        UserTO userTO = UserTestITCase.getSampleTO("issue260@syncope.apache.org");
        AttributeTO attrTO = new AttributeTO();
        attrTO.setSchema(schemaTO.getName());
        attrTO.addValue("1.2");
        userTO.addAttribute(attrTO);

        userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
        assertNotNull(userTO);

        schemaTO.setUniqueConstraint(false);
        try {
            restTemplate.postForObject(BASE_URL + "schema/user/update", schemaTO, SchemaTO.class);
            fail("This should not be reacheable");
        } catch (SyncopeClientCompositeErrorException scce) {
            SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidUSchema);
View Full Code Here

    @Test
    public void testLists() throws IOException {

        List<SchemaTO> schemas = new ArrayList<SchemaTO>();
        SchemaTO schemaTO = new SchemaTO();
        schemaTO.setName("name1");
        schemas.add(schemaTO);
        schemaTO = new SchemaTO();
        schemaTO.setName("name2");
        schemas.add(schemaTO);

        ObjectMapper mapper = new ObjectMapper();

        StringWriter writer = new StringWriter();
View Full Code Here

    }

    @Override
    public void setSchemaModalPage(final PageReference callerPageRef, final ModalWindow window,
            AbstractBaseBean schemaTO, final boolean createFlag) {
        final SchemaTO schema;
        if (schemaTO != null && schemaTO instanceof SchemaTO) {
            schema = (SchemaTO) schemaTO;
        } else {
            schema = new SchemaTO();
        }

        final Form schemaForm = new Form("form");

        schemaForm.setModel(new CompoundPropertyModel(schema));
        schemaForm.setOutputMarkupId(Boolean.TRUE);

        final AjaxTextFieldPanel name =
                new AjaxTextFieldPanel("name", getString("name"), new PropertyModel<String>(schema, "name"));

        name.addRequiredLabel();
        name.setEnabled(createFlag);

        final AjaxTextFieldPanel conversionPattern = new AjaxTextFieldPanel("conversionPattern",
                getString("conversionPattern"), new PropertyModel<String>(schema, "conversionPattern"));

        final IModel<List<String>> validatorsList = new LoadableDetachableModel<List<String>>() {

            private static final long serialVersionUID = 5275935387613157437L;

            @Override
            protected List<String> load() {
                return restClient.getAllValidatorClasses();
            }
        };

        final AjaxDropDownChoicePanel<String> validatorClass = new AjaxDropDownChoicePanel<String>("validatorClass",
                getString("validatorClass"), new PropertyModel(schema, "validatorClass"));

        ((DropDownChoice) validatorClass.getField()).setNullValid(true);
        validatorClass.setChoices(validatorsList.getObject());

        final AjaxDropDownChoicePanel<SchemaType> type = new AjaxDropDownChoicePanel<SchemaType>("type",
                getString("type"), new PropertyModel(schema, "type"));
        type.setChoices(Arrays.asList(SchemaType.values()));
        type.addRequiredLabel();

        final MultiValueSelectorPanel<String> enumerationValues =
                new MultiValueSelectorPanel<String>("enumerationValues",
                new Model(),
                new AjaxTextFieldPanel("panel", "enumerationValues", new Model(null)).addRequiredLabel());
        schemaForm.add(enumerationValues);

        enumerationValues.setModelObject((Serializable) getEnumValuesAsList(schema.getEnumerationValues()));

        final MultiValueSelectorPanel<String> enumerationKeys =
                new MultiValueSelectorPanel<String>("enumerationKeys",
                new Model(),
                new AjaxTextFieldPanel("panel", "enumerationKeys", new Model(null)));
        schemaForm.add(enumerationKeys);

        enumerationKeys.setModelObject((Serializable) getEnumValuesAsList(schema.getEnumerationKeys()));

        if (schema != null && SchemaType.Enum.equals(((SchemaTO) schema).getType())) {
            enumerationValues.setEnabled(Boolean.TRUE);
            enumerationKeys.setEnabled(Boolean.TRUE);
        } else {
            enumerationValues.setEnabled(Boolean.FALSE);
            enumerationKeys.setEnabled(Boolean.FALSE);
        }

        type.getField().add(new AjaxFormComponentUpdatingBehavior("onchange") {

            private static final long serialVersionUID = -1107858522700306810L;

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
                if (SchemaType.Enum.ordinal() == Integer.parseInt(type.getField().getValue())) {
                    enumerationValues.setEnabled(Boolean.TRUE);
                    enumerationValues.setModelObject((Serializable) getEnumValuesAsList(schema.getEnumerationValues()));

                    enumerationKeys.setEnabled(Boolean.TRUE);
                    enumerationKeys.setModelObject((Serializable) getEnumValuesAsList(schema.getEnumerationKeys()));
                } else {
                    final List<String> values = new ArrayList<String>();
                    values.add("");

                    enumerationValues.setEnabled(Boolean.FALSE);
                    enumerationValues.setModelObject((Serializable) values);

                    final List<String> keys = new ArrayList<String>();
                    keys.add("");

                    enumerationKeys.setEnabled(Boolean.FALSE);
                    enumerationKeys.setModelObject((Serializable) keys);
                }

                target.add(schemaForm);
            }
        });

        final AutoCompleteTextField mandatoryCondition = new AutoCompleteTextField("mandatoryCondition") {

            private static final long serialVersionUID = -2428903969518079100L;

            @Override
            protected Iterator getChoices(String input) {
                List<String> choices = new ArrayList<String>();

                if (Strings.isEmpty(input)) {
                    choices = Collections.emptyList();
                    return choices.iterator();
                }

                if ("true".startsWith(input.toLowerCase())) {
                    choices.add("true");
                } else if ("false".startsWith(input.toLowerCase())) {
                    choices.add("false");
                }

                return choices.iterator();
            }
        };

        mandatoryCondition.add(new AjaxFormComponentUpdatingBehavior("onchange") {

            private static final long serialVersionUID = -1107858522700306810L;

            @Override
            protected void onUpdate(AjaxRequestTarget art) {
            }
        });

        final AjaxCheckBoxPanel multivalue = new AjaxCheckBoxPanel("multivalue", getString("multivalue"),
                new PropertyModel<Boolean>(schema, "multivalue"));

        final AjaxCheckBoxPanel readonly = new AjaxCheckBoxPanel("readonly", getString("readonly"),
                new PropertyModel<Boolean>(schema, "readonly"));

        final AjaxCheckBoxPanel uniqueConstraint = new AjaxCheckBoxPanel("uniqueConstraint",
                getString("uniqueConstraint"), new PropertyModel<Boolean>(schema, "uniqueConstraint"));

        final AjaxButton submit = new IndicatingAjaxButton("apply", new ResourceModel("submit")) {

            private static final long serialVersionUID = -958724007591692537L;

            @Override
            protected void onSubmit(final AjaxRequestTarget target, final Form form) {

                final SchemaTO schemaTO = (SchemaTO) form.getDefaultModelObject();

                schemaTO.setEnumerationValues(getEnumValuesAsString(enumerationValues.getView().getModelObject()));
                schemaTO.setEnumerationKeys(getEnumValuesAsString(enumerationKeys.getView().getModelObject()));

                if (schemaTO.isMultivalue() && schemaTO.isUniqueConstraint()) {
                    error(getString("multivalueAndUniqueConstr.validation"));
                    target.add(feedbackPanel);
                    return;
                }
View Full Code Here

TOP

Related Classes of org.apache.syncope.client.to.SchemaTO

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.