-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup path configurable, better converters for configuration serial…
…ization
- Loading branch information
Showing
9 changed files
with
118 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...ea-plugin/src/main/java/com/evolveum/midpoint/studio/util/CleanupPathActionConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.evolveum.midpoint.studio.util; | ||
|
||
import com.evolveum.midpoint.studio.impl.configuration.CleanupPathAction; | ||
import com.intellij.util.xmlb.Converter; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class CleanupPathActionConverter extends Converter<CleanupPathAction> { | ||
|
||
@Override | ||
public @Nullable CleanupPathAction fromString(@NotNull String value) { | ||
return CleanupPathAction.getState(value); | ||
} | ||
|
||
@Override | ||
public @Nullable String toString(@NotNull CleanupPathAction value) { | ||
return value.value(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...idea-plugin/src/main/java/com/evolveum/midpoint/studio/util/ObjectTypesListConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.evolveum.midpoint.studio.util; | ||
|
||
import com.evolveum.midpoint.schema.constants.ObjectTypes; | ||
import com.intellij.util.xmlb.Converter; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Created by Viliam Repan (lazyman). | ||
*/ | ||
public class ObjectTypesListConverter extends Converter<List<ObjectTypes>> { | ||
|
||
public static @Nullable List<ObjectTypes> fromString(@NotNull String value, boolean ignoreWrongValue) { | ||
if (value == null || value.isEmpty()) { | ||
return new ArrayList<>(); | ||
} | ||
|
||
List<ObjectTypes> result = new ArrayList<>(); | ||
|
||
String[] types = value.split(","); | ||
for (String type : types) { | ||
try { | ||
ObjectTypes ot = ObjectTypes.getObjectType(type); | ||
if (ot != null) { | ||
result.add(ot); | ||
} | ||
} catch (RuntimeException ex) { | ||
if (!ignoreWrongValue) { | ||
throw ex; | ||
} | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|
||
@Override | ||
public @Nullable List<ObjectTypes> fromString(@NotNull String value) { | ||
return fromString(value, true); | ||
} | ||
|
||
@Override | ||
public @Nullable String toString(@NotNull List<ObjectTypes> value) { | ||
if (value == null || value.isEmpty()) { | ||
return null; | ||
} | ||
|
||
List<String> types = new ArrayList<>(); | ||
value.forEach(v -> types.add(v.getValue())); | ||
|
||
return StringUtils.join(types, ","); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters