本文整理了Java中org.dataconservancy.mhf.representation.api.Attribute
类的一些代码示例,展示了Attribute
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Attribute
类的具体详情如下:
包路径:org.dataconservancy.mhf.representation.api.Attribute
类名称:Attribute
暂无
代码示例来源:origin: org.dataconservancy.packaging/dcs-pkg-ingest-shared
/**
* Returns true if the attribute has a non-null value field.
*
* @param attribute the attribute
* @return true if the attribute has a non-null value field.
*/
private static boolean hasValue(Attribute attribute) {
return attribute.getValue() != null;
}
代码示例来源:origin: org.dataconservancy.packaging/dcs-pkg-ingest-shared
public AttributeImpl(Attribute toCopy) {
this.name = toCopy.getName();
this.type = toCopy.getType();
this.value = toCopy.getValue();
}
代码示例来源:origin: org.dataconservancy.packaging/dcs-pkg-ingest-services
@Override
public boolean matches(String attributeSetName, Attribute candidateToMatch) {
// The value of the candidate attribute must equal the id of the object
if (candidateToMatch.getValue().equals(s)) {
// And the name of the attribute must end with "-ResourceId" to insure that the semantics
// of the Attribute are correct
return IDENTIFIER_ATTR_NAME.matcher(candidateToMatch.getName()).matches();
}
return false;
}
});
代码示例来源:origin: org.dataconservancy.packaging/dcs-pkg-ingest-impl
private Map<String, Integer> getFileCountByFormat(Set<AttributeSet> fileAttributeSets) {
//TODO: map keyed by format's name. keyed by DcsFormat object would be more reliable. Report consumer can
//decide what field of DcsFormat to use. But IngestReport doesn't current support mapping keyed on DcsFormat type.
Map<String, Integer> fileCountByFormat = new HashMap<String, Integer>();
for (AttributeSet fileAttributeSet : fileAttributeSets) {
//extract file-formats
java.util.Collection<Attribute> matchingAttributes =
fileAttributeSet.getAttributesByName(Metadata.FILE_FORMAT);
for (Attribute attribute : matchingAttributes) {
if (attribute.getType().equals(AttributeValueType.DCS_FORMAT)) {
DcsFormat format = DcsFormat.parseDcsFormat(attribute.getValue());
// Only add the Pronom format to the report to be displayed or the unknown mime-type
// (application/octet-stream)
if (format.getSchemeUri().contains("PRONOM")
|| format.getName().equalsIgnoreCase("application/octet-stream")) {
// if an entry for this format does not exist yet
if (!fileCountByFormat.containsKey(format.getName())) {
// create the new entry
fileCountByFormat.put(format.getName(), 0);
}
// increase count for the format entry.
fileCountByFormat.put(format.getName(), fileCountByFormat.get(format.getName()) + 1);
}
}
}
}
return fileCountByFormat;
}
/**
代码示例来源:origin: org.dataconservancy.packaging/dcs-pkg-ingest-shared
/**
* Returns true if the attribute has a non-null name field.
*
* @param attribute the attribute
* @return true if the attribute has a non-null name field.
*/
private static boolean hasName(Attribute attribute) {
return attribute.getName() != null;
}
代码示例来源:origin: org.dataconservancy.packaging/dcs-pkg-ingest-shared
/**
* Returns true if the attribute has a non-null type field.
*
* @param attribute the attribute
* @return true if the attribute has a non-null type field.
*/
private static boolean hasType(Attribute attribute) {
return attribute.getType() != null;
}
代码示例来源:origin: org.dataconservancy.packaging/dcs-pkg-ingest-services
private boolean findAllAttributes(String depositId, IngestWorkflowState state, String attributeName, Set<String> ids) {
Attribute attributeToMatch = new AttributeImpl(attributeName, null, null);
Set<AttributeSet> matchingAttributeSets = state.getAttributeSetManager().matches(attributeToMatch);
for (AttributeSet attributeSet : matchingAttributeSets) {
for (Attribute matchingAttribute : attributeSet.getAttributes()) {
if (matchingAttribute.getName().equalsIgnoreCase(attributeName)) {
if (!ids.add(matchingAttribute.getValue())) {
DcsEvent event = state.getEventManager().newEvent(Package.Events.INGEST_FAIL);
String stackTrace = "";
for (StackTraceElement st : Thread.currentThread().getStackTrace()) {
stackTrace += st + "\n";
}
event.setDetail(stackTrace);
event.setOutcome("Duplicate Identifiers were found: " + matchingAttribute.getValue());
List<DcsEntityReference> refs = new ArrayList<DcsEntityReference>();
DcsEntityReference ref = new DcsEntityReference(matchingAttribute.getValue());
refs.add(ref);
event.setTargets(refs);
state.getEventManager().addEvent(depositId, event);
return false;
}
}
}
}
return true;
}
}
代码示例来源:origin: org.dataconservancy.packaging/dcs-pkg-ingest-services
detectedFormatAttributeValue = formatAttribute.getValue();
if (formatAttribute.getType().equals(AttributeValueType.DCS_FORMAT)) {
try {
detectedFormatUriString = createFormatURIString(DcsFormat.parseDcsFormat(detectedFormatAttributeValue));
log.info("File <" + fileNameAttribute.getValue() + "> did not have any matching ORE-ReM-File " +
"AttributeSet. No format verification will be performed for this file. ");
continue;
if (detectedFormatURIs.contains(fileFormatToVerify.getValue())) {
verifiedFormats.add(fileFormatToVerify.getValue());
} else {
failedVerificationFormats.add(fileFormatToVerify.getValue());
代码示例来源:origin: org.dataconservancy.packaging/dcs-pkg-ingest-shared
/**
* Returns true if the {@code matchExpression} and {@code candidate} have equal names.
*
* @param matchExpression the match expression
* @param candidate the candidate attribute to match
* @return true if the {@code matchExpression} and {@code candidate} have equal names
*/
private static boolean namesMatch(Attribute matchExpression, Attribute candidate) {
return matchExpression.getName().equals(candidate.getName());
}
代码示例来源:origin: org.dataconservancy.packaging/dcs-pkg-ingest-shared
/**
* Returns true if the {@code matchExpression} and {@code candidate} have equal types.
*
* @param matchExpression the match expression
* @param candidate the candidate attribute to match
* @return true if the {@code matchExpression} and {@code candidate} have equal types
*/
private static boolean typesMatch(Attribute matchExpression, Attribute candidate) {
return matchExpression.getType().equals(candidate.getType());
}
代码示例来源:origin: org.dataconservancy.packaging/dcs-pkg-ingest-shared
/**
* Returns true if the {@code matchExpression} and {@code candidate} have equal values.
*
* @param matchExpression the match expression
* @param candidate the candidate attribute to match
* @return true if the {@code matchExpression} and {@code candidate} have equal values
*/
private static boolean valuesMatch(Attribute matchExpression, Attribute candidate) {
return matchExpression.getValue().equals(candidate.getValue());
}
}
代码示例来源:origin: org.dataconservancy.packaging/dcs-pkg-ingest-shared
@Override
public int compare(Attribute one, Attribute two) {
if (one.getName().compareTo(two.getName()) != 0) {
return one.getName().compareTo(two.getName());
}
if (one.getType().compareTo(two.getType()) != 0) {
return one.getType().compareTo(two.getType());
}
return one.getValue().compareTo(two.getValue());
}
});
代码示例来源:origin: org.dataconservancy.packaging/dcs-pkg-ingest-services
if (bagitAttr.getName().equals(Metadata.BAGIT_CHECKSUM)){
String attrValue = bagitAttr.getValue();
Pair<String, Checksum> manifestChecksumPair = fileChecksumPairSerializer.deserialize(attrValue);
String thisFile = manifestChecksumPair.getKey();
if (fileAttr.getName().equals(Metadata.CALCULATED_CHECKSUM)) {
Pair<String, Checksum> fileChecksumPair = fileChecksumPairSerializer.deserialize(fileAttr.getValue());
String calculatedAlgorithm = fileChecksumPair.getValue().getAlgorithm();
String calculatedValue = fileChecksumPair.getValue().getValue();
代码示例来源:origin: org.dataconservancy.dcs/dcs-mhf-representations-impl
@Override
public Collection<Attribute> getAttributesByName(String attributeName) {
Collection<Attribute> matchingAttributes = new HashSet<Attribute>();
for (Attribute attribute : attributes) {
if (attribute.getName().trim().equals(attributeName.trim())) {
matchingAttributes.add(attribute);
}
}
return matchingAttributes;
}
代码示例来源:origin: org.dataconservancy.dcs/dcs-mhf-model-builder-impl
public DateTime dateTimeAttributeToDateTime(Attribute dateTimeAttribute) throws IllegalArgumentException {
DateTime dateTime = null;
try {
dateTime = isoDateTimeFormatter.parseDateTime(dateTimeAttribute.getValue());
} catch(IllegalArgumentException except) {
log.warn("Could not parse GQM date time string: " + except);
throw except;
}
return dateTime;
}
代码示例来源:origin: org.dataconservancy.packaging/dcs-pkg-ingest-shared
@Override
public int compare(Attribute a1, Attribute a2) {
if (!a1.getName().equals(a2.getName())) {
return a1.getName().compareTo(a2.getName());
}
if (!a1.getType().equals(a2.getType())) {
return a1.getType().compareTo(a2.getType());
}
return a1.getValue().compareTo(a2.getValue());
}
});
代码示例来源:origin: org.dataconservancy.mhf/dcs-mhf-representations-impl
@Override
public Collection<Attribute> getAttributesByName(String attributeName) {
Collection<Attribute> matchingAttributes = new HashSet<Attribute>();
for (Attribute attribute : attributes) {
if (attribute.getName().trim().equals(attributeName.trim())) {
matchingAttributes.add(attribute);
}
}
return matchingAttributes;
}
代码示例来源:origin: org.dataconservancy.mhf/dcs-mhf-model-builder-impl
public DateTime dateTimeAttributeToDateTime(Attribute dateTimeAttribute) throws IllegalArgumentException {
DateTime dateTime = null;
try {
dateTime = isoDateTimeFormatter.parseDateTime(dateTimeAttribute.getValue());
} catch(IllegalArgumentException except) {
log.warn("Could not parse GQM date time string: " + except);
throw except;
}
return dateTime;
}
代码示例来源:origin: org.dataconservancy.packaging/dcs-pkg-ingest-shared
hpp.incrementDepth();
for (Attribute attr : sorted) {
hpp.appendWithIndentAndNewLine("Name: '" + attr.getName() + "' Type: '" + attr.getType() +
"' Value: '" + attr.getValue() + "'");
代码示例来源:origin: org.dataconservancy.packaging/dcs-pkg-ingest-shared
/**
* {@inheritDoc}
*/
@Override
public Collection<Attribute> getAttributesByName(String attributeName) {
Collection<Attribute> matchingAttributes = new HashSet<Attribute>();
for (Attribute attribute : attributes) {
if (attribute.getName().trim().equals(attributeName.trim())) {
matchingAttributes.add(attribute);
}
}
return matchingAttributes;
}
内容来源于网络,如有侵权,请联系作者删除!