Created
September 30, 2014 15:24
-
-
Save dacrome/a04f2377f70676fc5230 to your computer and use it in GitHub Desktop.
This is an example how to make it easier to response the extensions from the OsiamController
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
import org.osiam.resources.scim.ExtensionFieldType; | |
import java.util.HashMap; | |
import java.util.Map; | |
public class ExtensionMap { | |
private String urn; | |
private Map<String, String> namedTypePairs = new HashMap<>(); | |
public ExtensionMap(String urn) { | |
this.urn = urn; | |
} | |
public String getUrn() { | |
return urn; | |
} | |
public void setUrn(String urn) { | |
this.urn = urn; | |
} | |
public Map<String, String> getNamedTypePairs() { | |
return namedTypePairs; | |
} | |
public void setNamedTypePairs(Map<String, String> namedTypePairs) { | |
this.namedTypePairs = namedTypePairs; | |
} | |
public void addPair(String fieldName, ExtensionFieldType type) { | |
namedTypePairs.put(fieldName, type.getName()); | |
} | |
} |
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
public List<ExtensionMap> getExtensions() { | |
List<Extension> extensions = fromEntity(dao.getAllExtensions()); | |
final List<ExtensionMap> extensionMaps = new ArrayList<>(); | |
for(Extension extension : extensions) { | |
final ExtensionMap extensionMap = new ExtensionMap(extension.getUrn()); | |
for(Map.Entry<String, Extension.Field> fieldEntry : extension.getFields().entrySet()){ | |
final String field = fieldEntry.getKey(); | |
final ExtensionFieldType type = fieldEntry.getValue().getType(); | |
extensionMap.addPair(field, type); | |
} | |
extensionMaps.add(extensionMap); | |
} | |
return extensionMaps; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment